|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.alfresco.repo.content.AbstractContentAccessor
org.alfresco.repo.content.AbstractContentReader
public abstract class AbstractContentReader
Implements all the convenience methods of the interface. The only methods that need to be implemented, i.e. provide low-level content access are:
AbstractContentReader.createReader()
to read content from the repositoryAbstractContentReader.getDirectReadableChannel()
to provide direct storage access
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.alfresco.repo.content.AbstractContentAccessor |
---|
AbstractContentAccessor.CallbackFileChannel, AbstractContentAccessor.ChannelCloseCallbackAdvise |
Constructor Summary | |
---|---|
protected |
AbstractContentReader(java.lang.String contentUrl)
|
Method Summary | |
---|---|
void |
addListener(ContentStreamListener listener)
Adds the listener after checking that the output stream isn't already in use. |
static boolean |
compareContentReaders(ContentReader left,
ContentReader right)
Does a comparison of the binaries associated with two readers. |
protected abstract ContentReader |
createReader()
A factory method for subclasses to implement that will ensure the proper implementation of the ContentReader.getReader() method. |
void |
getContent(java.io.File file)
Gets content from the repository direct to file |
void |
getContent(java.io.OutputStream os)
Copies the input stream to the given
OutputStream |
java.io.InputStream |
getContentInputStream()
Get a stream to read from the underlying channel |
java.lang.String |
getContentString()
Makes use of the encoding, if available, to convert bytes to a string. |
java.lang.String |
getContentString(int length)
Gets content from the repository direct to String , but limiting
the string size to a given number of characters. |
protected abstract java.nio.channels.ReadableByteChannel |
getDirectReadableChannel()
Provides low-level access to read content from the repository. |
java.nio.channels.FileChannel |
getFileChannel()
Provides read-only, random-access to the underlying content. |
java.nio.channels.ReadableByteChannel |
getReadableChannel()
Provides low-level access to the underlying content. |
ContentReader |
getReader()
Performs checks and copies required reader attributes |
boolean |
isChannelOpen()
Gets the open/close state of the underlying IO Channel. |
boolean |
isClosed()
An automatically created listener sets the flag |
Methods inherited from class org.alfresco.repo.content.AbstractContentAccessor |
---|
channelOpened, finalize, getCallbackFileChannel, getContentData, getContentUrl, getEncoding, getLocale, getMimetype, setContentUrl, setEncoding, setLocale, setMimetype, setRetryingTransactionHelper, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.alfresco.service.cmr.repository.ContentReader |
---|
exists, getLastModified |
Methods inherited from interface org.alfresco.service.cmr.repository.ContentAccessor |
---|
getContentData, getContentUrl, getEncoding, getLocale, getMimetype, getSize, setEncoding, setLocale, setMimetype, setRetryingTransactionHelper |
Constructor Detail |
---|
protected AbstractContentReader(java.lang.String contentUrl)
contentUrl
- the content URL - this should be relative to the root of the store
and not absolute: to enable moving of the storesMethod Detail |
---|
public void addListener(ContentStreamListener listener)
addListener
in interface ContentAccessor
listener
- a listener that will be called for output stream
event notificationContentAccessor.setRetryingTransactionHelper(RetryingTransactionHelper)
protected abstract ContentReader createReader() throws ContentIOException
ContentReader.getReader()
method.
Only the instance need be constructed. The required mimetype, encoding, etc will be copied across by this class.
ContentIOException
public final ContentReader getReader() throws ContentIOException
getReader
in interface ContentReader
ContentIOException
public final boolean isClosed()
isClosed
in interface ContentReader
public boolean isChannelOpen()
ContentAccessor
isChannelOpen
in interface ContentAccessor
protected abstract java.nio.channels.ReadableByteChannel getDirectReadableChannel() throws ContentIOException
This is the only of the content reading methods that needs to be implemented by derived classes. All other content access methods make use of this in their underlying implementations.
ContentIOException
- if the channel could not be opened or the underlying content
has disappearedpublic final java.nio.channels.ReadableByteChannel getReadableChannel() throws ContentIOException
ContentReader
Once the stream is provided to a client it should remain active (subject to any timeouts) until closed by the client.
getReadableChannel
in interface ContentReader
ContentIOException
AbstractContentReader.getDirectReadableChannel()
,
AbstractContentReader.getCallbackReadableChannel(ReadableByteChannel, List)
public java.nio.channels.FileChannel getFileChannel() throws ContentIOException
ContentReader.getReadableChannel()
.
getFileChannel
in interface ContentReader
ContentIOException
ContentReader.getReadableChannel()
,
RandomAccessFile.getChannel()
public java.io.InputStream getContentInputStream() throws ContentIOException
ContentReader
getContentInputStream
in interface ContentReader
ContentIOException
Channels.newInputStream(java.nio.channels.ReadableByteChannel)
public final void getContent(java.io.OutputStream os) throws ContentIOException
input stream
to the given
OutputStream
getContent
in interface ContentReader
os
- the stream to which to write the content
ContentIOException
ContentReader.getReadableChannel()
public final void getContent(java.io.File file) throws ContentIOException
ContentReader
All resources will be closed automatically.
getContent
in interface ContentReader
file
- the file to write the content to - it will be overwritten
ContentIOException
ContentReader.getContentInputStream()
public final java.lang.String getContentString(int length) throws ContentIOException
ContentReader
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.
getContentString
in interface ContentReader
length
- the maximum number of characters to retrieve
ContentIOException
ContentReader.getContentString()
,
ContentReader.getContentInputStream()
,
String.String(byte[])
public final java.lang.String getContentString() throws ContentIOException
All the content is streamed into memory. So, like the interface said, be careful with this method.
getContentString
in interface ContentReader
ContentIOException
ContentAccessor.getEncoding()
public static boolean compareContentReaders(ContentReader left, ContentReader right) throws ContentIOException
compared
.
ContentIOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |