|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.restlet.representation.Variant
org.restlet.representation.RepresentationInfo
org.restlet.representation.Representation
org.restlet.representation.FileRepresentation
public class FileRepresentation
Representation based on a static file. Note that in order for Web clients to
display a download box upon reception of a file representation, it needs an
additional call to Disposition.setType(String) with a
Disposition.TYPE_ATTACHMENT value.
| Field Summary |
|---|
| Fields inherited from class org.restlet.representation.Representation |
|---|
UNKNOWN_SIZE |
| Constructor Summary | |
|---|---|
FileRepresentation(File file,
MediaType mediaType)
Constructor that does not set an expiration date for file |
|
FileRepresentation(File file,
MediaType mediaType,
int timeToLive)
Constructor. |
|
FileRepresentation(String path,
MediaType mediaType)
Constructor that does not set an expiration date for path |
|
FileRepresentation(String path,
MediaType mediaType,
int timeToLive)
Constructor. |
|
| Method Summary | |
|---|---|
FileChannel |
getChannel()
Returns a readable byte channel. |
File |
getFile()
Returns the file handle. |
Reader |
getReader()
Returns a characters reader with the representation's content. |
long |
getSize()
Returns the total size in bytes if known, UNKNOWN_SIZE (-1) otherwise. |
FileInputStream |
getStream()
Returns a stream with the representation's content. |
String |
getText()
Note that this method relies on getStream(). |
boolean |
isAutoDeleting()
Indicates if this file should be automatically deleted on release of the representation. |
void |
release()
Releases the file handle. |
void |
setAutoDeleting(boolean autoDeleting)
Indicates if this file should be automatically deleted on release of the representation. |
void |
setFile(File file)
Sets the file handle. |
void |
write(OutputStream outputStream)
Writes the representation to a byte stream. |
void |
write(WritableByteChannel writableChannel)
Writes the representation to a byte channel. |
void |
write(Writer writer)
Writes the representation to a characters writer. |
| Methods inherited from class org.restlet.representation.Representation |
|---|
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransient |
| Methods inherited from class org.restlet.representation.RepresentationInfo |
|---|
getModificationDate, getTag, setModificationDate, setTag |
| Methods inherited from class org.restlet.representation.Variant |
|---|
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public FileRepresentation(File file,
MediaType mediaType)
file
file - The represented file.mediaType - The representation's media type.FileRepresentation(File, MediaType, int)
public FileRepresentation(File file,
MediaType mediaType,
int timeToLive)
file - The represented file.mediaType - The representation's media type.timeToLive - The time to live before it expires (in seconds).
public FileRepresentation(String path,
MediaType mediaType)
path
path - The path name or file URI of the represented file (either in
system format or in 'file:///' format).mediaType - The representation's media type.FileRepresentation(String, MediaType, int)
public FileRepresentation(String path,
MediaType mediaType,
int timeToLive)
path - The path name or file URI of the represented file (either in
system format or in 'file:///' format).mediaType - The representation's media type.timeToLive - The time to live before it expires (in seconds).File.File(String)| Method Detail |
|---|
public FileChannel getChannel()
throws IOException
getChannel in class RepresentationIOExceptionpublic File getFile()
public Reader getReader()
throws IOException
Representation
getReader in class RepresentationIOExceptionpublic long getSize()
RepresentationRepresentation.getAvailableSize() method.
getSize in class RepresentationRepresentation.isEmpty()
public FileInputStream getStream()
throws IOException
Representation
getStream in class RepresentationIOException
public String getText()
throws IOException
getStream(). This stream is
closed once fully read.
getText in class RepresentationIOExceptionpublic boolean isAutoDeleting()
public void release()
release in class Representationpublic void setAutoDeleting(boolean autoDeleting)
autoDeleting - True if this file should be automatically deleted on release
of the representation.public void setFile(File file)
file - The file handle.
public void write(OutputStream outputStream)
throws IOException
RepresentationOutputStream after writing to it as this will be handled by
the Restlet connectors automatically.
write in class RepresentationoutputStream - The output stream.
IOException
public void write(WritableByteChannel writableChannel)
throws IOException
write in class RepresentationwritableChannel - A writable byte channel.
IOException
public void write(Writer writer)
throws IOException
RepresentationWriter after writing to it as this will be handled
by the Restlet connectors automatically.
write in class Representationwriter - The characters writer.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||