|
1 | | -/* |
2 | | - * Copyright 2002-2018 the original author or authors. |
3 | | - * |
4 | | - * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | - * you may not use this file except in compliance with the License. |
6 | | - * You may obtain a copy of the License at |
7 | | - * |
8 | | - * https://www.apache.org/licenses/LICENSE-2.0 |
9 | | - * |
10 | | - * Unless required by applicable law or agreed to in writing, software |
11 | | - * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | - * See the License for the specific language governing permissions and |
14 | | - * limitations under the License. |
15 | | - */ |
| 1 | +// Generated automatically from org.springframework.core.io.Resource for testing purposes |
16 | 2 |
|
17 | 3 | package org.springframework.core.io; |
18 | 4 |
|
19 | 5 | import java.io.File; |
20 | | -import java.io.IOException; |
21 | | -import java.io.InputStream; |
22 | 6 | import java.net.URI; |
23 | 7 | import java.net.URL; |
24 | | -import java.nio.channels.Channels; |
25 | 8 | import java.nio.channels.ReadableByteChannel; |
26 | | - |
27 | | -import org.springframework.lang.Nullable; |
28 | | - |
29 | | -/** |
30 | | - * Interface for a resource descriptor that abstracts from the actual |
31 | | - * type of underlying resource, such as a file or class path resource. |
32 | | - * |
33 | | - * <p>An InputStream can be opened for every resource if it exists in |
34 | | - * physical form, but a URL or File handle can just be returned for |
35 | | - * certain resources. The actual behavior is implementation-specific. |
36 | | - * |
37 | | - * @author Juergen Hoeller |
38 | | - * @since 28.12.2003 |
39 | | - * @see #getInputStream() |
40 | | - * @see #getURL() |
41 | | - * @see #getURI() |
42 | | - * @see #getFile() |
43 | | - * @see WritableResource |
44 | | - * @see ContextResource |
45 | | - * @see UrlResource |
46 | | - * @see FileUrlResource |
47 | | - * @see FileSystemResource |
48 | | - * @see ClassPathResource |
49 | | - * @see ByteArrayResource |
50 | | - * @see InputStreamResource |
51 | | - */ |
52 | | -public interface Resource extends InputStreamSource { |
53 | | - |
54 | | - /** |
55 | | - * Determine whether this resource actually exists in physical form. |
56 | | - * <p>This method performs a definitive existence check, whereas the |
57 | | - * existence of a {@code Resource} handle only guarantees a valid |
58 | | - * descriptor handle. |
59 | | - */ |
60 | | - boolean exists(); |
61 | | - |
62 | | - /** |
63 | | - * Indicate whether non-empty contents of this resource can be read via |
64 | | - * {@link #getInputStream()}. |
65 | | - * <p>Will be {@code true} for typical resource descriptors that exist |
66 | | - * since it strictly implies {@link #exists()} semantics as of 5.1. |
67 | | - * Note that actual content reading may still fail when attempted. |
68 | | - * However, a value of {@code false} is a definitive indication |
69 | | - * that the resource content cannot be read. |
70 | | - * @see #getInputStream() |
71 | | - * @see #exists() |
72 | | - */ |
73 | | - default boolean isReadable() { |
74 | | - return exists(); |
75 | | - } |
76 | | - |
77 | | - /** |
78 | | - * Indicate whether this resource represents a handle with an open stream. |
79 | | - * If {@code true}, the InputStream cannot be read multiple times, |
80 | | - * and must be read and closed to avoid resource leaks. |
81 | | - * <p>Will be {@code false} for typical resource descriptors. |
82 | | - */ |
83 | | - default boolean isOpen() { |
84 | | - return false; |
85 | | - } |
86 | | - |
87 | | - /** |
88 | | - * Determine whether this resource represents a file in a file system. |
89 | | - * A value of {@code true} strongly suggests (but does not guarantee) |
90 | | - * that a {@link #getFile()} call will succeed. |
91 | | - * <p>This is conservatively {@code false} by default. |
92 | | - * @since 5.0 |
93 | | - * @see #getFile() |
94 | | - */ |
95 | | - default boolean isFile() { |
96 | | - return false; |
97 | | - } |
98 | | - |
99 | | - /** |
100 | | - * Return a URL handle for this resource. |
101 | | - * @throws IOException if the resource cannot be resolved as URL, |
102 | | - * i.e. if the resource is not available as descriptor |
103 | | - */ |
104 | | - URL getURL() throws IOException; |
105 | | - |
106 | | - /** |
107 | | - * Return a URI handle for this resource. |
108 | | - * @throws IOException if the resource cannot be resolved as URI, |
109 | | - * i.e. if the resource is not available as descriptor |
110 | | - * @since 2.5 |
111 | | - */ |
112 | | - URI getURI() throws IOException; |
113 | | - |
114 | | - /** |
115 | | - * Return a File handle for this resource. |
116 | | - * @throws java.io.FileNotFoundException if the resource cannot be resolved as |
117 | | - * absolute file path, i.e. if the resource is not available in a file system |
118 | | - * @throws IOException in case of general resolution/reading failures |
119 | | - * @see #getInputStream() |
120 | | - */ |
121 | | - File getFile() throws IOException; |
122 | | - |
123 | | - /** |
124 | | - * Return a {@link ReadableByteChannel}. |
125 | | - * <p>It is expected that each call creates a <i>fresh</i> channel. |
126 | | - * <p>The default implementation returns {@link Channels#newChannel(InputStream)} |
127 | | - * with the result of {@link #getInputStream()}. |
128 | | - * @return the byte channel for the underlying resource (must not be {@code null}) |
129 | | - * @throws java.io.FileNotFoundException if the underlying resource doesn't exist |
130 | | - * @throws IOException if the content channel could not be opened |
131 | | - * @since 5.0 |
132 | | - * @see #getInputStream() |
133 | | - */ |
134 | | - default ReadableByteChannel readableChannel() throws IOException { |
135 | | - return Channels.newChannel(getInputStream()); |
136 | | - } |
137 | | - |
138 | | - /** |
139 | | - * Determine the content length for this resource. |
140 | | - * @throws IOException if the resource cannot be resolved |
141 | | - * (in the file system or as some other known physical resource type) |
142 | | - */ |
143 | | - long contentLength() throws IOException; |
144 | | - |
145 | | - /** |
146 | | - * Determine the last-modified timestamp for this resource. |
147 | | - * @throws IOException if the resource cannot be resolved |
148 | | - * (in the file system or as some other known physical resource type) |
149 | | - */ |
150 | | - long lastModified() throws IOException; |
151 | | - |
152 | | - /** |
153 | | - * Create a resource relative to this resource. |
154 | | - * @param relativePath the relative path (relative to this resource) |
155 | | - * @return the resource handle for the relative resource |
156 | | - * @throws IOException if the relative resource cannot be determined |
157 | | - */ |
158 | | - Resource createRelative(String relativePath) throws IOException; |
159 | | - |
160 | | - /** |
161 | | - * Determine a filename for this resource, i.e. typically the last |
162 | | - * part of the path: for example, "myfile.txt". |
163 | | - * <p>Returns {@code null} if this type of resource does not |
164 | | - * have a filename. |
165 | | - */ |
166 | | - @Nullable |
167 | | - String getFilename(); |
168 | | - |
169 | | - /** |
170 | | - * Return a description for this resource, |
171 | | - * to be used for error output when working with the resource. |
172 | | - * <p>Implementations are also encouraged to return this value |
173 | | - * from their {@code toString} method. |
174 | | - * @see Object#toString() |
175 | | - */ |
176 | | - String getDescription(); |
177 | | - |
| 9 | +import org.springframework.core.io.InputStreamSource; |
| 10 | + |
| 11 | +public interface Resource extends InputStreamSource |
| 12 | +{ |
| 13 | + File getFile(); |
| 14 | + Resource createRelative(String p0); |
| 15 | + String getDescription(); |
| 16 | + String getFilename(); |
| 17 | + URI getURI(); |
| 18 | + URL getURL(); |
| 19 | + boolean exists(); |
| 20 | + default ReadableByteChannel readableChannel(){ return null; } |
| 21 | + default boolean isFile(){ return false; } |
| 22 | + default boolean isOpen(){ return false; } |
| 23 | + default boolean isReadable(){ return false; } |
| 24 | + long contentLength(); |
| 25 | + long lastModified(); |
178 | 26 | } |
0 commit comments