Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

org.alfresco.repo.content.filestore
Class FileContentReader
java.lang.Object
  org.alfresco.repo.content.AbstractContentReader
      org.alfresco.repo.content.filestore.FileContentReader
All Implemented Interfaces:
ContentReader, ContentAccessor

public class FileContentReader
extends AbstractContentReader
implements ContentReader
Provides direct access to a local file.

This class does not provide remote access to the file.

Author:
Derek Hulley

Field Summary
static String
MSG_MISSING_CONTENT
          message key for missing content.
Constructor Summary
FileContentReader(File file)
          Constructor that builds a URL based on the absolute path of the file.
FileContentReader(File file, String url)
          Constructor that explicitely sets the URL that the reader represents.
Method Summary
boolean
canWrite()
protected ContentReader
createReader()
          The URL of the write is known from the start and this method contract states that no consideration needs to be taken w.r.t.
boolean
exists()
          Check if the underlying content is present.
getDirectReadableChannel()
          Provides low-level access to read content from the repository.
getFile()
          Provides access to the underlying File that this Reader accesses.
long
getLastModified()
          Gets the time of the last modification of the underlying content.
getSafeContentReader(ContentReader existingReader, String msgTemplate, Object... args)
          Checks the existing reader provided and replaces it with a reader onto some fake content if required.
long
getSize()
          Gets the size of the content that this reader references.
Methods inherited from class org.alfresco.repo.content.AbstractContentReader
addListener, channelOpened, compareContentReaders, finalize, getCallbackFileChannel, getContent, getContent, getContentData, getContentInputStream, getContentString, getContentString, getContentUrl, getEncoding, getFileChannel, getLimits, getLocale, getMimetype, getReadableChannel, getReader, getTransformerDebug, getUseBufferedInputStream, isChannelOpen, isClosed, setContentUrl, setEncoding, setLimits, setLocale, setMimetype, setTransformerDebug, setUseBufferedInputStream, toString
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
MSG_MISSING_CONTENT
public static final String MSG_MISSING_CONTENT
message key for missing content. Parameters are
See Also:
Constant Field Values
Constructor Detail
FileContentReader
public FileContentReader(File file)
Constructor that builds a URL based on the absolute path of the file.
Parameters:
file - the file for reading. This will most likely be directly related to the content URL.

FileContentReader
public FileContentReader(File file,
                         String url)
Constructor that explicitely sets the URL that the reader represents.
Parameters:
file - the file for reading. This will most likely be directly related to the content URL.
url - the relative url that the reader represents
Method Detail
getSafeContentReader
public static ContentReader getSafeContentReader(ContentReader existingReader,
                                                 String msgTemplate,
                                                 Object... args)
Checks the existing reader provided and replaces it with a reader onto some fake content if required. If the existing reader is invalid, an debug message will be logged under this classname category.

It is a convenience method that clients can use to cheaply get a reader that is valid, regardless of whether the initial reader is valid.

Parameters:
existingReader - a potentially invalid reader or null
msgTemplate - the template message that will used to format the final fake content
args - arguments to put into the fake content
Returns:
Returns a the existing reader or a new reader onto some generated text content

getFile
public File getFile()
Provides access to the underlying File that this Reader accesses.
Returns:
Returns the file that this reader accesses

exists
public boolean exists()
Description copied from interface: ContentReader
Check if the underlying content is present.
Specified by:
exists in interface ContentReader
Returns:
Whether the file exists or not

getSize
public long getSize()
Description copied from interface: ContentAccessor
Gets the size of the content that this reader references.
Specified by:
getSize in interface ContentAccessor
Returns:
Returns the document byte length, or OL if the content doesn't exist.
See Also:
File.length()

getLastModified
public long getLastModified()
Description copied from interface: ContentReader
Gets the time of the last modification of the underlying content.
Specified by:
getLastModified in interface ContentReader
Returns:
Returns the last modification time using the standard long time, or 0L if the content doesn't exist.
See Also:
File.lastModified()

createReader
protected ContentReader createReader()
                              throws ContentIOException
The URL of the write is known from the start and this method contract states that no consideration needs to be taken w.r.t. the stream state.
Overrides:
createReader in class AbstractContentReader
Returns:
Returns a reader onto the location referenced by this instance. The instance must always be a new instance.
Throws:
ContentIOException

getDirectReadableChannel
protected ReadableByteChannel getDirectReadableChannel()
                                                throws ContentIOException
Description copied from class: AbstractContentReader
Provides low-level access to read content from the repository.

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.

Overrides:
getDirectReadableChannel in class AbstractContentReader
Returns:
Returns a channel from which content can be read
Throws:
ContentIOException - if the channel could not be opened or the underlying content has disappeared

canWrite
public boolean canWrite()
Returns:
Returns false as this is a reader

Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005–2016 Alfresco Software. All rights reserved.

Java API documentation generated with DocFlex/Javadoc 1.6.1 using JavadocPro template set.