Class Content
- All Implemented Interfaces:
Cloneable
All content is determined by its mime type and the raw data that will be used to load the content. The type of the data is dependent on the mime type.
For example, images can be loaded from byte arrays and texts can be loaded from strings. If an unsupported data type is used or the format is incorrect, suitable exceptions will be thrown when the content is stored in the back-end.
- Since:
- 1.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionSets a named content attribute that will be converted internally to aString
value.Sets a named content attribute that will be converted internally to aString
value.Sets a named content attribute that will be converted internally to aString
value.Sets a named content attribute that will be converted internally to aString
value.Sets a named content attribute that will be converted internally to aString
value.Sets a named content attribute that will be converted internally to aString
value.Sets a named content attribute that will be converted internally to aString
value.Sets a named content attribute that will be converted internally to aString
value.Sets a named content attribute.attributes
(Map<String, String> attributes) Replaces the map of named content attributes.cachedLoadedData
(Object data) Sets the cached loaded data.clone()
Simply clones the instance with the default clone method since we want to create a shallow copyfragment
(boolean fragment) Sets whether the content data is a fragment.getAttribute
(String name) Retrieves the value of a named content attribute.Retrieves the map of named content attributes.Retrieves the cached loaded content data.getData()
Retrieves the data of the content.Retrieves the mime type of the content.getName()
Retrieves the name of the content.Retrieves the content properties.getProperty
(String name) Retrieves the value of a named content property.boolean
hasAttribute
(String name) Indicates whether a specific named content attribute is present.boolean
Indicates whether named content attributes are present.boolean
Indicates whether cached loaded content data is present.boolean
hasName()
Indicates whether the content data has a name.boolean
Indicates whether content properties are presentboolean
hasProperty
(String name) Indicates whether a specific named content property is present.boolean
Indicates whether the content data is a fragment.Sets the name of the content.properties
(Map<String, String> properties) Replaces the content properties.Sets a named content property that will be converted internally to aString
value.Sets a named content property that will be converted internally to aString
value.Sets a named content property that will be converted internally to aString
value.Sets a named content property that will be converted internally to aString
value.Sets a named content property that will be converted internally to aString
value.Sets a named content property that will be converted internally to aString
value.Sets a named content property that will be converted internally to aString
value.Sets a named content property that will be converted internally to aString
value.Sets a named content property.void
setAttributes
(Map<String, String> attributes) Replaces the map of named content attributes.void
setCachedLoadedData
(Object data) Sets the cached loaded data.void
Sets the data of the content.void
setFragment
(boolean fragment) Sets whether the content data is a fragment.void
Sets the name of the content.void
setProperties
(Map<String, String> properties) Replaces the content properties.
-
Constructor Details
-
Content
Creates a newContent
instance with the minimal required arguments.- Parameters:
mimeType
- the mime type as which the content will be stored in the back-end, note that this doesn't necessarily have to correspond to the mime type of the provided data. Image formats can for example be automatically detected and converted to the target mime type by image loading and conversion libraries.data
- the data of the content, if this isnull
, empty content should be stored- Since:
- 1.0
-
-
Method Details
-
getMimeType
Retrieves the mime type of the content.- Returns:
- the mime type of the content
- Since:
- 1.0
-
getData
Retrieves the data of the content.- Returns:
- the data of the content
- Since:
- 1.0
-
setData
Sets the data of the content.- Since:
- 1.4
-
fragment
Sets whether the content data is a fragment. A fragment means that it's not a complete document or a file, but rather a small part that is intended to be used within a larger document. For example an HTML snippet. This information is for example important when validating the data.- Parameters:
fragment
-true
if the content is a fragment; orfalse
otherwise- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
setFragment
public void setFragment(boolean fragment) Sets whether the content data is a fragment.- Parameters:
fragment
-true
if the content is a fragment; orfalse
otherwise- Since:
- 1.0
- See Also:
-
isFragment
public boolean isFragment()Indicates whether the content data is a fragment.- Returns:
true
if the content is a fragment; orfalse
otherwise- Since:
- 1.0
- See Also:
-
name
Sets the name of the content.- Parameters:
name
- the name- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
setName
Sets the name of the content.- Parameters:
name
- the name- Since:
- 1.0
- See Also:
-
getName
Retrieves the name of the content.- Returns:
null
if the content has no name; orthe name of the content
- Since:
- 1.0
- See Also:
-
hasName
public boolean hasName()Indicates whether the content data has a name.- Returns:
true
if the content has a name; orfalse
otherwise- Since:
- 1.0
- See Also:
-
attributes
Replaces the map of named content attributes.Note that attributes provide information about how to load, convert and transform content into its stored data form. If you want to provide meta information about the content, you should provide it through properties instead.
- Parameters:
attributes
- the map of named content attributes- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aString
value.- Parameters:
name
- the name of the attributevalue
- the value of the attribute- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aString
value.- Parameters:
name
- the name of the attributevalue
- the value of the attribute- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aString
value.- Parameters:
name
- the name of the attributevalue
- the value of the attribute- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aString
value.- Parameters:
name
- the name of the attributevalue
- the value of the attribute- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aString
value.- Parameters:
name
- the name of the attributevalue
- the value of the attribute- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aString
value.- Parameters:
name
- the name of the attributevalue
- the value of the attribute- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aString
value.- Parameters:
name
- the name of the attributevalue
- the value of the attribute- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aString
value.- Parameters:
name
- the name of the attributevalue
- the value of the attribute- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute.- Parameters:
name
- the name of the attributevalue
- the value of the attribute- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
setAttributes
Replaces the map of named content attributes.- Parameters:
attributes
- the map of named content attributes- Since:
- 1.0
- See Also:
-
getAttributes
Retrieves the map of named content attributes.- Returns:
- the map of named content attributes; or
null
if no attributes are present - Since:
- 1.0
- See Also:
-
hasAttributes
public boolean hasAttributes()Indicates whether named content attributes are present.- Returns:
true
if named content attributes are present; orfalse
otherwise- Since:
- 1.0
- See Also:
-
hasAttribute
Indicates whether a specific named content attribute is present.- Parameters:
name
- the name of the attribute- Returns:
true
if the name content attribute is present; orfalse
otherwise- Since:
- 1.0
- See Also:
-
getAttribute
Retrieves the value of a named content attribute.- Parameters:
name
- the name of the attribute- Returns:
- the value of the named content attribute; or
null
if no such attribute could be found - Since:
- 1.0
- See Also:
-
properties
Replaces the content properties.This is also internally used by content formatters to provide additional information about the content that's stored after formatting and transformation. Note that this is not the same as content attributes, who provide infomration about how to format and transform the provided data before storage. The content properties describe the result as it's stored in the back-end.
- Parameters:
properties
- the content properties- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aString
value.- Parameters:
name
- the name of the propertyvalue
- the value of the property- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aString
value.- Parameters:
name
- the name of the propertyvalue
- the value of the property- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aString
value.- Parameters:
name
- the name of the propertyvalue
- the value of the property- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aString
value.- Parameters:
name
- the name of the propertyvalue
- the value of the property- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aString
value.- Parameters:
name
- the name of the propertyvalue
- the value of the property- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aString
value.- Parameters:
name
- the name of the propertyvalue
- the value of the property- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aString
value.- Parameters:
name
- the name of the propertyvalue
- the value of the property- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aString
value.- Parameters:
name
- the name of the propertyvalue
- the value of the property- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
property
Sets a named content property.- Parameters:
name
- the name of the propertyvalue
- the value of the property- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
setProperties
Replaces the content properties.- Parameters:
properties
- the content properties- Since:
- 1.0
- See Also:
-
hasProperties
public boolean hasProperties()Indicates whether content properties are present- Returns:
true
if properties are present; orfalse
otherwise- Since:
- 1.0
- See Also:
-
hasProperty
Indicates whether a specific named content property is present.- Parameters:
name
- the name of the property- Returns:
true
if the name content property is present; orfalse
otherwise- Since:
- 1.0
- See Also:
-
getProperty
Retrieves the value of a named content property.- Parameters:
name
- the name of the property- Returns:
- the value of the named content property; or
null
if no such property could be found - Since:
- 1.0
- See Also:
-
getProperties
Retrieves the content properties.- Returns:
- the content properties; or
null
if no content properties are present - Since:
- 1.0
- See Also:
-
cachedLoadedData
Sets the cached loaded data.This is internally used by content loaders to prevent having to load and convert data to the specified mime type several times for the same content. It is for instance very resource intensive to detect an image format, validate the provided raw data and create a generic image instance for further processing. These operations are however required in several different locations in the content handling logic. Storing the result after the first successful loading and simply retrieving it later enhances the speed considerably.
- Parameters:
data
- the loaded data- Returns:
- the current
Content
instance - Since:
- 1.0
- See Also:
-
setCachedLoadedData
Sets the cached loaded data.- Parameters:
data
- the loaded data- Since:
- 1.0
- See Also:
-
hasCachedLoadedData
public boolean hasCachedLoadedData()Indicates whether cached loaded content data is present.- Returns:
true
if cached loaded content data is present; orfalse
otherwise- Since:
- 1.0
- See Also:
-
getCachedLoadedData
Retrieves the cached loaded content data.- Returns:
- the cached loaded content data; or
null
if no loaded content data has been cached - Since:
- 1.0
- See Also:
-
clone
Simply clones the instance with the default clone method since we want to create a shallow copy
-