Class ContentData
- java.lang.Object
-
- org.alfresco.service.cmr.repository.ContentData
-
- All Implemented Interfaces:
java.io.Serializable
@AlfrescoPublicApi public class ContentData extends java.lang.Object implements java.io.SerializableThe compound property representing content- Author:
- Derek Hulley
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description ContentData(java.lang.String contentUrl, java.lang.String mimetype, long size, java.lang.String encoding)Create a content data using thedefault locale.ContentData(java.lang.String contentUrl, java.lang.String mimetype, long size, java.lang.String encoding, java.util.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(java.lang.String contentPropertyStr)Construct a content property from a stringbooleanequals(java.lang.Object obj)java.lang.StringgetContentUrl()java.lang.StringgetEncoding()Gets the content's encoding.java.lang.StringgetInfoUrl()java.util.LocalegetLocale()Get the content's locale.java.lang.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, java.lang.String encoding)Constructs a new instance using the existing one as a template, but replacing the encoding.static ContentDatasetMimetype(ContentData existing, java.lang.String mimetype)Constructs a new instance using the existing one as a template, but replacing the mimetypejava.lang.StringtoString()
-
-
-
Constructor Detail
-
ContentData
protected ContentData(ContentData original)
Copy constructor for derived class- Parameters:
original- the object to copy
-
ContentData
public ContentData(java.lang.String contentUrl, java.lang.String mimetype, long size, java.lang.String encoding)Create a content data using thedefault locale.
-
ContentData
public ContentData(java.lang.String contentUrl, java.lang.String mimetype, long size, java.lang.String encoding, java.util.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(java.lang.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, java.lang.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, java.lang.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
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- Returns a string of form:
contentUrl=xxx|mimetype=xxx|size=xxx|encoding=xxx|locale=xxx
-
getInfoUrl
public java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.util.Locale getLocale()
Get the content's locale.- Returns:
- Returns a locale, or null if the locale is unknown
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode
-
-