|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.vfs.provider.DefaultFileContent
public final class DefaultFileContent
The content of a file.
| Nested Class Summary | |
|---|---|
private class |
DefaultFileContent.FileContentInputStream
An input stream for reading content. |
(package private) class |
DefaultFileContent.FileContentOutputStream
An output stream for writing content. |
private class |
DefaultFileContent.FileRandomAccessContent
An input/output stream for reading/writing content on random positions |
| Field Summary | |
|---|---|
private java.util.Map |
attrs
|
private AbstractFileObject |
file
|
private FileContentInfo |
fileContentInfo
|
private FileContentInfoFactory |
fileContentInfoFactory
|
private int |
openStreams
open streams counter for this file |
private java.util.Map |
roAttrs
|
(package private) static int |
STATE_CLOSED
|
(package private) static int |
STATE_OPENED
|
private java.lang.ThreadLocal |
threadData
|
| Constructor Summary | |
|---|---|
DefaultFileContent(AbstractFileObject file,
FileContentInfoFactory fileContentInfoFactory)
|
|
| Method Summary | |
|---|---|
void |
close()
Closes all resources used by the content, including all streams, readers and writers. |
private void |
endInput(DefaultFileContent.FileContentInputStream instr)
Handles the end of input stream. |
private void |
endOutput()
Handles the end of output stream. |
private void |
endRandomAccess(RandomAccessContent rac)
Handles the end of random access. |
java.lang.Object |
getAttribute(java.lang.String attrName)
Gets the value of an attribute. |
java.lang.String[] |
getAttributeNames()
Lists the attributes of this file. |
java.util.Map |
getAttributes()
Returns a read-only map of this file's attributes. |
java.security.cert.Certificate[] |
getCertificates()
Returns the certificates used to sign this file. |
FileContentInfo |
getContentInfo()
get the content info. |
FileObject |
getFile()
Returns the file that this is the content of. |
java.io.InputStream |
getInputStream()
Returns an input stream for reading the content. |
long |
getLastModifiedTime()
Returns the last-modified timestamp. |
java.io.OutputStream |
getOutputStream()
Returns an output stream for writing the content. |
java.io.OutputStream |
getOutputStream(boolean bAppend)
Returns an output stream for writing the content in append mode. |
RandomAccessContent |
getRandomAccessContent(RandomAccessMode mode)
Returns an input/output stream to use to read and write the content of the file in an random manner. |
long |
getSize()
Returns the size of the content (in bytes). |
private FileContentThreadData |
getThreadData()
|
boolean |
isOpen()
check if a input and/or output stream is open. This checks only the scope of the current thread. |
boolean |
isOpenGlobal()
check if a input and/or output stream is open. This checks all threads. |
void |
setAttribute(java.lang.String attrName,
java.lang.Object value)
Sets the value of an attribute. |
void |
setLastModifiedTime(long modTime)
Sets the last-modified timestamp. |
(package private) void |
streamClosed()
|
(package private) void |
streamOpened()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final int STATE_CLOSED
static final int STATE_OPENED
private final AbstractFileObject file
private java.util.Map attrs
private java.util.Map roAttrs
private FileContentInfo fileContentInfo
private final FileContentInfoFactory fileContentInfoFactory
private final java.lang.ThreadLocal threadData
private int openStreams
| Constructor Detail |
|---|
public DefaultFileContent(AbstractFileObject file,
FileContentInfoFactory fileContentInfoFactory)
| Method Detail |
|---|
private FileContentThreadData getThreadData()
void streamOpened()
void streamClosed()
public FileObject getFile()
getFile in interface FileContent
public long getSize()
throws FileSystemException
getSize in interface FileContentFileSystemException - If the file does not exist, or is being written to, or on error
determining the size.
public long getLastModifiedTime()
throws FileSystemException
getLastModifiedTime in interface FileContentFileSystemException - If the file does not exist, or is being written to, or on error
determining the last-modified timestamp.
public void setLastModifiedTime(long modTime)
throws FileSystemException
setLastModifiedTime in interface FileContentmodTime - The time to set the last-modified timestamp to.
FileSystemException - If the file is read-only, or is being written to, or on error
setting the last-modified timestamp.
public java.util.Map getAttributes()
throws FileSystemException
getAttributes in interface FileContentFileSystemException - If the file does not exist, or does not support attributes.
public java.lang.String[] getAttributeNames()
throws FileSystemException
getAttributeNames in interface FileContentFileSystemException - If the file does not exist, or does not support attributes.
public java.lang.Object getAttribute(java.lang.String attrName)
throws FileSystemException
getAttribute in interface FileContentattrName - The name of the attribute. Attribute names are case insensitive.
FileSystemException - If the file does not exist, or does not support attributes.
public void setAttribute(java.lang.String attrName,
java.lang.Object value)
throws FileSystemException
setAttribute in interface FileContentattrName - The name of the attribute.value - The value of the attribute.
FileSystemException - If the file does not exist, or is read-only, or does not support
attributes, or on error setting the attribute.
public java.security.cert.Certificate[] getCertificates()
throws FileSystemException
getCertificates in interface FileContentFileSystemException - If the file does not exist, or is being written.
public java.io.InputStream getInputStream()
throws FileSystemException
getInputStream in interface FileContentBufferedInputStream.
FileSystemException - If the file does not exist, or is being read, or is being written,
or on error opening the stream.
public RandomAccessContent getRandomAccessContent(RandomAccessMode mode)
throws FileSystemException
getRandomAccessContent in interface FileContentFileSystemException - If the file is read-only, or is being read, or is being written,
or on error opening the stream.
public java.io.OutputStream getOutputStream()
throws FileSystemException
getOutputStream in interface FileContentBufferedOutputStream.
FileSystemException - If the file is read-only, or is being read, or is being written,
or on error opening the stream.
public java.io.OutputStream getOutputStream(boolean bAppend)
throws FileSystemException
getOutputStream in interface FileContentbAppend - true if you would like to append to the file
BufferedOutputStream.
FileSystemException - If the file is read-only, or is being read, or is being written,
or on error opening the stream.
public void close()
throws FileSystemException
close in interface FileContentFileSystemExceptionprivate void endInput(DefaultFileContent.FileContentInputStream instr)
private void endRandomAccess(RandomAccessContent rac)
private void endOutput()
throws java.lang.Exception
java.lang.Exceptionpublic boolean isOpen()
isOpen in interface FileContentpublic boolean isOpenGlobal()
public FileContentInfo getContentInfo()
throws FileSystemException
getContentInfo in interface FileContentFileSystemException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||