Class ContentData
- java.lang.Object
-
- org.alfresco.service.cmr.repository.ContentData
-
- All Implemented Interfaces:
Serializable
@AlfrescoPublicApi public class ContentData extends Object implements Serializable
The compound property representing content- Author:
- Derek Hulley
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description ContentData(String contentUrl, String mimetype, long size, String encoding)Create a content data using thedefault locale.ContentData(String contentUrl, String mimetype, long size, String encoding, Locale locale)Create a compound set of data representing a single instance of content.protectedContentData(ContentData original)Copy constructor for derived class
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ContentDatacreateContentProperty(String contentPropertyStr)Construct a content property from a stringbooleanequals(Object obj)StringgetContentUrl()StringgetEncoding()Gets the content's encoding.StringgetInfoUrl()LocalegetLocale()Get the content's locale.StringgetMimetype()Gets content's mimetype.longgetSize()Get the content's sizestatic booleanhasContent(ContentData contentData)Helper method to determine if the data represents any physical content or not.inthashCode()static ContentDatasetEncoding(ContentData existing, String encoding)Constructs a new instance using the existing one as a template, but replacing the encoding.static ContentDatasetMimetype(ContentData existing, String mimetype)Constructs a new instance using the existing one as a template, but replacing the mimetypeStringtoString()
-
-
-
Constructor Detail
-
ContentData
protected ContentData(ContentData original)
Copy constructor for derived class- Parameters:
original- the object to copy
-
ContentData
public ContentData(String contentUrl, String mimetype, long size, String encoding)
Create a content data using thedefault locale.
-
ContentData
public ContentData(String contentUrl, String mimetype, long size, String encoding, Locale locale)
Create a compound set of data representing a single instance of content.In order to ensure data integrity, the
mimetypemust be set if thecontent URLis set.- Parameters:
contentUrl- the content URL. If this value is non-null, then the mimetype must be supplied.mimetype- the content mimetype. This is mandatory if the contentUrl is specified.size- the content size.encoding- the content encoding. This is mandatory if the contentUrl is specified.locale- the locale of the content (may be null). If null, thedefault localewill be used.
-
-
Method Detail
-
createContentProperty
public static ContentData createContentProperty(String contentPropertyStr)
Construct a content property from a string- Parameters:
contentPropertyStr- the string representing the content details- Returns:
- Returns a bean version of the string
-
setMimetype
public static ContentData setMimetype(ContentData existing, String mimetype)
Constructs a new instance using the existing one as a template, but replacing the mimetype- Parameters:
existing- an existing set of content data, null to use default valuesmimetype- the mimetype to set- Returns:
- Returns a new, immutable instance of the data
-
setEncoding
public static ContentData setEncoding(ContentData existing, String encoding)
Constructs a new instance using the existing one as a template, but replacing the encoding.- Parameters:
existing- an existing set of content data, null to use default valuesencoding- the encoding to set- Returns:
- Returns a new, immutable instance of the data
-
hasContent
public static boolean hasContent(ContentData contentData)
Helper method to determine if the data represents any physical content or not.This method only cares if there is a binary (content URL) and makes no assumptions about the length of the binary.
- Parameters:
contentData- the content to check (may be null)- Returns:
- true if the content URL is non-null i.e. there is a binary available
-
toString
public String toString()
-
getInfoUrl
public String getInfoUrl()
- Returns:
- Returns a URL containing information on the content including the mimetype,
locale, encoding and size, the string is returned in the form:
contentUrl=xxx|mimetype=xxx|size=xxx|encoding=xxx|locale=xxx
-
getContentUrl
public String getContentUrl()
- Returns:
- Returns a URL identifying the specific location of the content. The URL must identify, within the context of the originating content store, the exact location of the content.
- Throws:
ContentIOException
-
getMimetype
public String getMimetype()
Gets content's mimetype.- Returns:
- Returns a standard mimetype for the content or null if the mimetype is unkown
-
getSize
public long getSize()
Get the content's size- Returns:
- Returns the size of the content
-
getEncoding
public String getEncoding()
Gets the content's encoding.- Returns:
- Returns a valid Java encoding, typically a character encoding, or null if the encoding is unkown
-
getLocale
public Locale getLocale()
Get the content's locale.- Returns:
- Returns a locale, or null if the locale is unknown
-
-