Interface ContentAccessor
-
- All Known Subinterfaces:
ContentReader,ContentWriter,FileContentReader
@AlfrescoPublicApi public interface ContentAccessor
Interface for instances that provide read and write access to content.- Author:
- Derek Hulley
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(ContentStreamListener listener)Use this method to register any interest in events against underlying content streams.ContentDatagetContentData()Get the data representation of the content being accessed.StringgetContentUrl()Retrieve the URL that this accessor referencesStringgetEncoding()Get the encoding of the content being accessedLocalegetLocale()Get the locale of the content being accessedStringgetMimetype()Get the content mimetypelonggetSize()Gets the size of the content that this reader references.booleanisChannelOpen()Gets the open/close state of the underlying IO Channel.voidsetEncoding(String encoding)Set theStringencoding for this accessorvoidsetLocale(Locale locale)Set theLocalefor this accessorvoidsetMimetype(String mimetype)Set the mimetype that must be used for accessing the content.
-
-
-
Method Detail
-
isChannelOpen
boolean isChannelOpen()
Gets the open/close state of the underlying IO Channel.- Returns:
- Returns true if the underlying IO Channel is open
-
addListener
void addListener(ContentStreamListener listener)
Use this method to register any interest in events against underlying content streams.This method can only be used before the content stream has been retrieved.
When the stream has been closed, all listeners will be called. The listener is responsible for using a retrying transaction to protect the implementation of the callback when required.
- Parameters:
listener- a listener that will be called for output stream event notification
-
getSize
long getSize()
Gets the size of the content that this reader references.- Returns:
- Returns the document byte length, or
OLif the content doesn't exist.
-
getContentData
ContentData getContentData()
Get the data representation of the content being accessed.The content
mimetypemust be set before this method is called as the content data requires a mimetype whenever the content URL is specified.- Returns:
- Returns the content data
- See Also:
ContentData(String, String, long, String)
-
getContentUrl
String getContentUrl()
Retrieve the URL that this accessor references- Returns:
- the content URL
-
getMimetype
String getMimetype()
Get the content mimetype- Returns:
- Returns a content mimetype
-
setMimetype
void setMimetype(String mimetype)
Set the mimetype that must be used for accessing the content.When dealing with a
ContentWriter, you may wish to useContentWriter.guessMimetype(String)to have this set for you based on the filename and contents.- Parameters:
mimetype- the content mimetype
-
getEncoding
String getEncoding()
Get the encoding of the content being accessed- Returns:
- Returns a valid java String encoding
-
setEncoding
void setEncoding(String encoding)
Set theStringencoding for this accessorWhen dealing with a
ContentWriter, you may wish to useContentWriter.guessMimetype(String)to have this set for you based on the contents.- Parameters:
encoding- a java-recognised encoding format
-
getLocale
Locale getLocale()
Get the locale of the content being accessed- Returns:
- Returns a valid java Locale
-
setLocale
void setLocale(Locale locale)
Set theLocalefor this accessor- Parameters:
locale- a java-recognised locale
-
-