org.apache.wicket.util.resource
Interface IResourceStream

All Superinterfaces:
Closeable, IClusterable, IModifiable, Serializable
All Known Subinterfaces:
IResourceStreamWriter, IStringResourceStream
All Known Implementing Classes:
AbstractResourceStream, AbstractResourceStreamWriter, AbstractStringResourceStream, CompressedPackageResource.CompressingResourceStream, CssTemplate, FileResourceStream, JavascriptPackageResource.FilteringResourceStream, JavaScriptTemplate, MarkupResourceStream, PackagedTextTemplate, PackageResourceStream, StringBufferResourceStream, StringResourceStream, TextTemplate, TextTemplateDecorator, UrlResourceStream, WebExternalResourceStream, XSLTResourceStream, ZipResourceStream

public interface IResourceStream
extends IModifiable, IClusterable, Closeable

Interface to a streamed resource. The resource stream can be retrieved by calling getInputStream(), but the resource should later be closed by calling close() on the IResourceStream (as opposed to calling close on the InputStream returned by getInputStream()).

Once a resource has been closed with a call to close(), it is normally possible to call getInputStream() again to retrieve a new input stream on the same resource.

Implementations of this interface are typically unsafe for use from multiple threads.

Author:
Jonathan Locke

Method Summary
 void close()
          Closes the resource.
 String getContentType()
          Gets the mime type of this resource
 InputStream getInputStream()
          Gets the resource stream.
 Locale getLocale()
           
 long length()
          Gets the size of this resource in bytes TODO 1.5: rename to lengthInBytes() or let it return some sort of size object
 void setLocale(Locale locale)
          This method shouldn't be used for the outside, It is used by the Loaders to set the resolved locale.
 
Methods inherited from interface org.apache.wicket.util.watch.IModifiable
lastModifiedTime
 

Method Detail

getContentType

String getContentType()
Gets the mime type of this resource

Returns:
The mime type of this resource, such as "image/jpeg" or "text/html". Return null to let ResourceStreamRequestTarget handle the Content-Type automatically
See Also:
Response.detectContentType(org.apache.wicket.RequestCycle, String)

length

long length()
Gets the size of this resource in bytes TODO 1.5: rename to lengthInBytes() or let it return some sort of size object

Returns:
The size of this resource in the number of bytes, or -1 if unknown

getInputStream

InputStream getInputStream()
                           throws ResourceStreamNotFoundException
Gets the resource stream. You should not directly close this stream. Instead call the close() method on IResourceStream.

Returns:
Returns the inputStream.
Throws:
ResourceStreamNotFoundException
See Also:
close()

close

void close()
           throws IOException
Closes the resource. Normally, this includes closing any underlying input stream returned by getInputStream().

Specified by:
close in interface Closeable
Throws:
IOException

getLocale

Locale getLocale()
Returns:
The Locale where this stream did resolve to

setLocale

void setLocale(Locale locale)
This method shouldn't be used for the outside, It is used by the Loaders to set the resolved locale.

Parameters:
locale - The Locale where this stream did resolve to.


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.