org.apache.wicket.util.resource
Class FileResourceStream

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

public class FileResourceStream
extends AbstractResourceStream
implements IFixedLocationResourceStream

A FileResourceStream is an IResource implementation for files.

Author:
Jonathan Locke
See Also:
IResourceStream, IModifiable, Serialized Form

Constructor Summary
FileResourceStream(File file)
          Constructor.
FileResourceStream(java.io.File file)
          Constructor.
 
Method Summary
 void close()
          Closes this resource.
 java.lang.String getContentType()
          Gets the mime type of this resource
 File getFile()
           
 java.io.InputStream getInputStream()
          Gets the resource stream.
 Time lastModifiedTime()
          Gets the last time this modifiable thing changed.
 Bytes length()
          Gets the size of this resource
 java.lang.String locationAsString()
           
 java.lang.String toString()
           
 
Methods inherited from class org.apache.wicket.util.resource.AbstractResourceStream
getLocale, getStyle, getVariation, setLocale, setStyle, setVariation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileResourceStream

public FileResourceStream(File file)
Constructor.

Parameters:
file - File containing resource

FileResourceStream

public FileResourceStream(java.io.File file)
Constructor.

Parameters:
file - File containing resource
Method Detail

close

public void close()
           throws java.io.IOException
Closes this resource.

Specified by:
close in interface java.io.Closeable
Specified by:
close in interface IResourceStream
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 ResourceStreamRequestHandler handle the Content-Type automatically
See Also:
WebResponse#detectContentType(org.apache.wicket.RequestCycle, String)

getFile

public File getFile()
Returns:
The file this resource resides in, if any.

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.

Specified by:
getInputStream in interface IResourceStream
Returns:
A readable input stream for this resource. The same input stream is returned until FileResourceStream.close() is invoked.
Throws:
ResourceStreamNotFoundException
See Also:
IResourceStream.close()

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 time this resource was modified
See Also:
IModifiable.lastModifiedTime()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

length

public Bytes length()
Description copied from interface: IResourceStream
Gets the size of this resource

Specified by:
length in interface IResourceStream
Overrides:
length in class AbstractResourceStream
Returns:
The size of this resource in the number of bytes, or null if unknown

locationAsString

public java.lang.String locationAsString()
Specified by:
locationAsString in interface IFixedLocationResourceStream
Returns:
The fixed location as a string, e.g. the file name or the URL. Return null to avoid caching the markup.


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