@AlfrescoPublicApi public abstract class AbstractContentReader extends AbstractContentAccessor implements ContentReader
createReader() to read content from the repositorygetDirectReadableChannel() to provide direct storage accessAbstractContentAccessor.CallbackFileChannel, AbstractContentAccessor.ChannelCloseCallbackAdvise| Modifier | Constructor and Description |
|---|---|
protected |
AbstractContentReader(String contentUrl) |
| Modifier and Type | Method and Description |
|---|---|
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(File file) |
void |
getContent(OutputStream os)
Copies the
input stream to the given
OutputStream |
InputStream |
getContentInputStream() |
String |
getContentString()
Makes use of the encoding, if available, to convert bytes to a string.
|
String |
getContentString(int length) |
protected abstract ReadableByteChannel |
getDirectReadableChannel()
Provides low-level access to read content from the repository.
|
FileChannel |
getFileChannel() |
TransformationOptionLimits |
getLimits() |
ReadableByteChannel |
getReadableChannel() |
ContentReader |
getReader()
Performs checks and copies required reader attributes
|
TransformerDebug |
getTransformerDebug() |
boolean |
getUseBufferedInputStream() |
boolean |
isChannelOpen() |
boolean |
isClosed()
An automatically created listener sets the flag
|
void |
setLimits(TransformationOptionLimits limits) |
void |
setTransformerDebug(TransformerDebug transformerDebug) |
void |
setUseBufferedInputStream(boolean useBufferedInputStream) |
channelOpened, finalize, getCallbackFileChannel, getContentData, getContentUrl, getEncoding, getLocale, getMimetype, setContentUrl, setEncoding, setLocale, setMimetype, toStringclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitexists, getLastModifiedgetContentData, getContentUrl, getEncoding, getLocale, getMimetype, getSize, setEncoding, setLocale, setMimetypeprotected AbstractContentReader(String contentUrl)
contentUrl - the content URL - this should be relative to the root of the store
and not absolute: to enable moving of the storespublic void setLimits(TransformationOptionLimits limits)
public TransformationOptionLimits getLimits()
public void setTransformerDebug(TransformerDebug transformerDebug)
public TransformerDebug getTransformerDebug()
public void setUseBufferedInputStream(boolean useBufferedInputStream)
public boolean getUseBufferedInputStream()
public void addListener(ContentStreamListener listener)
addListener in interface ContentAccessorprotected 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.
ContentIOExceptionpublic final ContentReader getReader() throws ContentIOException
getReader in interface ContentReaderContentIOExceptionpublic final boolean isClosed()
isClosed in interface ContentReaderpublic boolean isChannelOpen()
isChannelOpen in interface ContentAccessorprotected abstract 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 ReadableByteChannel getReadableChannel() throws ContentIOException
getReadableChannel in interface ContentReaderContentIOExceptiongetDirectReadableChannel(),
getCallbackReadableChannel(ReadableByteChannel, List)public FileChannel getFileChannel() throws ContentIOException
getFileChannel in interface ContentReaderContentIOExceptionpublic InputStream getContentInputStream() throws ContentIOException
getContentInputStream in interface ContentReaderContentIOExceptionChannels.newInputStream(java.nio.channels.ReadableByteChannel)public final void getContent(OutputStream os) throws ContentIOException
input stream to the given
OutputStreamgetContent in interface ContentReaderContentIOExceptionpublic final void getContent(File file) throws ContentIOException
getContent in interface ContentReaderContentIOExceptionpublic final String getContentString(int length) throws ContentIOException
getContentString in interface ContentReaderContentIOExceptionpublic final String getContentString() throws ContentIOException
All the content is streamed into memory. So, like the interface said, be careful with this method.
getContentString in interface ContentReaderContentIOExceptionContentAccessor.getEncoding()public static boolean compareContentReaders(ContentReader left, ContentReader right) throws ContentIOException
compared.ContentIOExceptionCopyright © 2005–2021 Alfresco Software. All rights reserved.