org.apache.wicket.util.resource
Class PackageResourceStream

java.lang.Object
  extended by org.apache.wicket.util.resource.AbstractResourceStream
      extended by org.apache.wicket.util.resource.PackageResourceStream
All Implemented Interfaces:
java.io.Serializable, IClusterable, IResourceStream, IStringResourceStream, IModifiable

public class PackageResourceStream
extends AbstractResourceStream

An IResourceStream that reads data from a resource in the classpath. It simply delegates all operations to the IResourceStream returned by the application's IResourceStreamLocator.

Author:
Jean-Baptiste Quenot
See Also:
Serialized Form

Constructor Summary
PackageResourceStream(java.lang.Class scope, java.lang.String path)
          Obtains an IResourceStream from the application's IResourceStreamLocator.locate(Class, String)
 
Method Summary
 void close()
          Closes the resource.
 java.lang.String getContentType()
          Gets the mime type of this resource
 java.io.InputStream getInputStream()
          Gets the resource stream.
 Time lastModifiedTime()
          Gets the last time this modifiable thing changed.
 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
 
Methods inherited from class org.apache.wicket.util.resource.AbstractResourceStream
asString, getCharset, getLocale, setCharset, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PackageResourceStream

public PackageResourceStream(java.lang.Class scope,
                             java.lang.String path)
Obtains an IResourceStream from the application's IResourceStreamLocator.locate(Class, String)

Parameters:
scope - This argument will be used to get the class loader for loading the package resource, and to determine what package it is in.
path - The path to the resource
Method Detail

close

public void close()
           throws java.io.IOException
Description copied from interface: IResourceStream
Closes the resource. Normally, this includes closing any underlying input stream returned by getInputStream().

Throws:
java.io.IOException

getContentType

public java.lang.String getContentType()
Description copied from interface: IResourceStream
Gets the mime type of this resource

Specified by:
getContentType in interface IResourceStream
Overrides:
getContentType in class AbstractResourceStream
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:
IResourceStream.getContentType()

getInputStream

public java.io.InputStream getInputStream()
                                   throws ResourceStreamNotFoundException
Description copied from interface: IResourceStream
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:
IResourceStream.close()

length

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

Specified by:
length in interface IResourceStream
Overrides:
length in class AbstractResourceStream
Returns:
The size of this resource in the number of bytes, or -1 if unknown
See Also:
IResourceStream.length()

lastModifiedTime

public Time lastModifiedTime()
Description copied from interface: IModifiable
Gets the last time this modifiable thing changed.

Specified by:
lastModifiedTime in interface IModifiable
Overrides:
lastModifiedTime in class AbstractResourceStream
Returns:
the last modification Time
See Also:
IModifiable.lastModifiedTime()


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