01: /*
02: * $Id: IResourceStream.java 458456 2006-01-02 07:37:31Z jonl $ $Revision:
03: * 1.10 $ $Date: 2006-01-02 08:37:31 +0100 (Mon, 02 Jan 2006) $
04: *
05: * ==============================================================================
06: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
07: * use this file except in compliance with the License. You may obtain a copy of
08: * the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15: * License for the specific language governing permissions and limitations under
16: * the License.
17: */
18: package wicket.util.resource;
19:
20: import java.io.IOException;
21: import java.io.InputStream;
22: import java.io.Serializable;
23: import java.util.Locale;
24:
25: import wicket.util.watch.IModifiable;
26:
27: /**
28: * Interface to a streamed resource. The resource stream can be retrieved by
29: * calling getInputStream(), but the resource should later be closed by calling
30: * close() on the IResourceStream (as opposed to calling close on the
31: * InputStream returned by getInputStream()).
32: * <p>
33: * Once a resource has been closed with a call to close(), it is normally
34: * possible to call getInputStream() again to retrieve a new input stream on the
35: * same resource.
36: * <p>
37: * Implementations of this interface are typically unsafe for use from multiple
38: * threads.
39: *
40: * @author Jonathan Locke
41: */
42: public interface IResourceStream extends IModifiable, Serializable {
43: /**
44: * Gets the mime type of this resource
45: *
46: * @return The mime type of this resource, such as "image/jpeg" or
47: * "text/html"
48: */
49: String getContentType();
50:
51: /**
52: * Gets the size of this resource
53: *
54: * @return The size of this resource in the number of bytes
55: */
56: long length();
57:
58: /**
59: * Gets the resource stream. You should not directly close this stream.
60: * Instead call the close() method on IResourceStream.
61: *
62: * @see IResourceStream#close()
63: * @return Returns the inputStream.
64: * @throws ResourceStreamNotFoundException
65: */
66: InputStream getInputStream() throws ResourceStreamNotFoundException;
67:
68: /**
69: * Closes the resource. Normally, this includes closing any underlying input
70: * stream returned by getInputStream().
71: *
72: * @throws IOException
73: */
74: void close() throws IOException;
75:
76: /**
77: * @return The Locale where this stream did resolve to
78: */
79: Locale getLocale();
80:
81: /**
82: * This method shouldn't be used for the outside, It is used by the Loaders
83: * to set the resolved locale.
84: *
85: * @param locale
86: * The Locale where this stream did resolve to.
87: */
88: void setLocale(Locale locale);
89: }
|