@AlfrescoPublicApi public abstract class AbstractContentReader extends AbstractContentAccessor implements org.alfresco.service.cmr.repository.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(org.alfresco.service.cmr.repository.ContentStreamListener listener)
Adds the listener after checking that the output stream isn't already in
use.
|
static boolean |
compareContentReaders(org.alfresco.service.cmr.repository.ContentReader left,
org.alfresco.service.cmr.repository.ContentReader right)
Does a comparison of the binaries associated with two readers.
|
protected abstract org.alfresco.service.cmr.repository.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() |
org.alfresco.service.cmr.repository.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, toString
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
protected 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(org.alfresco.service.cmr.repository.ContentStreamListener listener)
addListener
in interface org.alfresco.service.cmr.repository.ContentAccessor
protected abstract org.alfresco.service.cmr.repository.ContentReader createReader() throws org.alfresco.service.cmr.repository.ContentIOException
ContentReader.getReader()
method.
Only the instance need be constructed. The required mimetype, encoding, etc will be copied across by this class.
org.alfresco.service.cmr.repository.ContentIOException
public final org.alfresco.service.cmr.repository.ContentReader getReader() throws org.alfresco.service.cmr.repository.ContentIOException
getReader
in interface org.alfresco.service.cmr.repository.ContentReader
org.alfresco.service.cmr.repository.ContentIOException
public final boolean isClosed()
isClosed
in interface org.alfresco.service.cmr.repository.ContentReader
public boolean isChannelOpen()
isChannelOpen
in interface org.alfresco.service.cmr.repository.ContentAccessor
protected abstract ReadableByteChannel getDirectReadableChannel() throws org.alfresco.service.cmr.repository.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.
org.alfresco.service.cmr.repository.ContentIOException
- if the channel could not be opened or the underlying content
has disappearedpublic final ReadableByteChannel getReadableChannel() throws org.alfresco.service.cmr.repository.ContentIOException
getReadableChannel
in interface org.alfresco.service.cmr.repository.ContentReader
org.alfresco.service.cmr.repository.ContentIOException
getDirectReadableChannel()
,
getCallbackReadableChannel(ReadableByteChannel, List)
public FileChannel getFileChannel() throws org.alfresco.service.cmr.repository.ContentIOException
getFileChannel
in interface org.alfresco.service.cmr.repository.ContentReader
org.alfresco.service.cmr.repository.ContentIOException
public InputStream getContentInputStream() throws org.alfresco.service.cmr.repository.ContentIOException
getContentInputStream
in interface org.alfresco.service.cmr.repository.ContentReader
org.alfresco.service.cmr.repository.ContentIOException
Channels.newInputStream(java.nio.channels.ReadableByteChannel)
public final void getContent(OutputStream os) throws org.alfresco.service.cmr.repository.ContentIOException
input stream
to the given
OutputStream
getContent
in interface org.alfresco.service.cmr.repository.ContentReader
org.alfresco.service.cmr.repository.ContentIOException
public final void getContent(File file) throws org.alfresco.service.cmr.repository.ContentIOException
getContent
in interface org.alfresco.service.cmr.repository.ContentReader
org.alfresco.service.cmr.repository.ContentIOException
public final String getContentString(int length) throws org.alfresco.service.cmr.repository.ContentIOException
getContentString
in interface org.alfresco.service.cmr.repository.ContentReader
org.alfresco.service.cmr.repository.ContentIOException
public final String getContentString() throws org.alfresco.service.cmr.repository.ContentIOException
All the content is streamed into memory. So, like the interface said, be careful with this method.
getContentString
in interface org.alfresco.service.cmr.repository.ContentReader
org.alfresco.service.cmr.repository.ContentIOException
ContentAccessor.getEncoding()
public static boolean compareContentReaders(org.alfresco.service.cmr.repository.ContentReader left, org.alfresco.service.cmr.repository.ContentReader right) throws org.alfresco.service.cmr.repository.ContentIOException
compared
.org.alfresco.service.cmr.repository.ContentIOException
Copyright © 2005–2017 Alfresco Software. All rights reserved.