@AlfrescoPublicApi public interface ContentReader extends ContentAccessor
Implementations of this interface might be Serializable
but client code could should check suitability before attempting to serialize
it.
Implementations that are able to provide inter-VM streaming, such as accessing
WebDAV, would be Serializable
. An accessor that has to access a
local file on the server could not provide inter-VM streaming unless it specifically
makes remote calls and opens sockets, etc.
ContentWriter
Modifier and Type | Method and Description |
---|---|
boolean |
exists()
Check if the
underlying content is present. |
void |
getContent(File file)
Gets content from the repository direct to file
|
void |
getContent(OutputStream os)
Gets content from the repository.
|
InputStream |
getContentInputStream()
Get a stream to read from the underlying channel
|
String |
getContentString()
Gets content from the repository direct to
String . |
String |
getContentString(int length)
Gets content from the repository direct to
String , but limiting
the string size to a given number of characters. |
FileChannel |
getFileChannel()
Provides read-only, random-access to the underlying content.
|
long |
getLastModified()
Gets the time of the last modification of the underlying content.
|
ReadableByteChannel |
getReadableChannel()
Provides low-level access to the underlying content.
|
ContentReader |
getReader()
Convenience method to get another reader onto the underlying content.
|
boolean |
isClosed()
Convenience method to find out if this reader has been closed.
|
addListener, getContentData, getContentUrl, getEncoding, getLocale, getMimetype, getSize, isChannelOpen, setEncoding, setLocale, setMimetype
ContentReader getReader() throws ContentIOException
ContentIOException
boolean exists()
underlying content
is present.long getLastModified()
0L
if the content doesn't exist
.System.currentTimeMillis()
boolean isClosed()
ReadableByteChannel getReadableChannel() throws ContentIOException
Once the stream is provided to a client it should remain active (subject to any timeouts) until closed by the client.
ContentIOException
FileChannel getFileChannel() throws ContentIOException
getReadableChannel()
.ContentIOException
getReadableChannel()
,
RandomAccessFile.getChannel()
InputStream getContentInputStream() throws ContentIOException
ContentIOException
getReadableChannel()
void getContent(OutputStream os) throws ContentIOException
All resources will be closed automatically.
Care must be taken that the bytes read from the stream are properly
decoded according to the encoding
property.
os
- the stream to which to write the contentContentIOException
getReadableChannel()
void getContent(File file) throws ContentIOException
All resources will be closed automatically.
file
- the file to write the content to - it will be overwrittenContentIOException
getContentInputStream()
String getContentString() throws ContentIOException
String
.
If the encoding
is known then it will be used
otherwise the default system byte[] to String conversion
will be used.
All resources will be closed automatically.
WARNING: This should only be used when the size of the content is known in advance.
ContentIOException
getContentString(int)
,
getContentInputStream()
,
String.String(byte[])
String getContentString(int length) throws ContentIOException
String
, but limiting
the string size to a given number of characters.
If the encoding
is known then it will be used
otherwise the default system byte[] to String conversion
will be used.
All resources will be closed automatically.
length
- the maximum number of characters to retrieveContentIOException
IllegalArgumentException
- if the length is < 0 or > Integer.MAX_VALUE
getContentString()
,
getContentInputStream()
,
String.String(byte[])
Copyright © 2005–2018 Alfresco Software. All rights reserved.