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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets a named content attribute that will be converted internally to aStringvalue.Sets a named content attribute that will be converted internally to aStringvalue.Sets a named content attribute that will be converted internally to aStringvalue.Sets a named content attribute that will be converted internally to aStringvalue.Sets a named content attribute that will be converted internally to aStringvalue.Sets a named content attribute that will be converted internally to aStringvalue.Sets a named content attribute that will be converted internally to aStringvalue.Sets a named content attribute that will be converted internally to aStringvalue.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.booleanhasAttribute(String name) Indicates whether a specific named content attribute is present.booleanIndicates whether named content attributes are present.booleanIndicates whether cached loaded content data is present.booleanhasName()Indicates whether the content data has a name.booleanIndicates whether content properties are presentbooleanhasProperty(String name) Indicates whether a specific named content property is present.booleanIndicates 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 aStringvalue.Sets a named content property that will be converted internally to aStringvalue.Sets a named content property that will be converted internally to aStringvalue.Sets a named content property that will be converted internally to aStringvalue.Sets a named content property that will be converted internally to aStringvalue.Sets a named content property that will be converted internally to aStringvalue.Sets a named content property that will be converted internally to aStringvalue.Sets a named content property that will be converted internally to aStringvalue.Sets a named content property.voidsetAttributes(Map<String, String> attributes) Replaces the map of named content attributes.voidsetCachedLoadedData(Object data) Sets the cached loaded data.voidSets the data of the content.voidsetFragment(boolean fragment) Sets whether the content data is a fragment.voidSets the name of the content.voidsetProperties(Map<String, String> properties) Replaces the content properties.
-
Constructor Details
-
Content
Creates a newContentinstance 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-trueif the content is a fragment; orfalseotherwise- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
setFragment
public void setFragment(boolean fragment) Sets whether the content data is a fragment.- Parameters:
fragment-trueif the content is a fragment; orfalseotherwise- Since:
- 1.0
- See Also:
-
isFragment
public boolean isFragment()Indicates whether the content data is a fragment.- Returns:
trueif the content is a fragment; orfalseotherwise- Since:
- 1.0
- See Also:
-
name
Sets the name of the content.- Parameters:
name- the name- Returns:
- the current
Contentinstance - 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:
nullif 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:
trueif the content has a name; orfalseotherwise- 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
Contentinstance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aStringvalue.- Parameters:
name- the name of the attributevalue- the value of the attribute- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aStringvalue.- Parameters:
name- the name of the attributevalue- the value of the attribute- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aStringvalue.- Parameters:
name- the name of the attributevalue- the value of the attribute- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aStringvalue.- Parameters:
name- the name of the attributevalue- the value of the attribute- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aStringvalue.- Parameters:
name- the name of the attributevalue- the value of the attribute- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aStringvalue.- Parameters:
name- the name of the attributevalue- the value of the attribute- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aStringvalue.- Parameters:
name- the name of the attributevalue- the value of the attribute- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
attribute
Sets a named content attribute that will be converted internally to aStringvalue.- Parameters:
name- the name of the attributevalue- the value of the attribute- Returns:
- the current
Contentinstance - 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
Contentinstance - 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
nullif no attributes are present - Since:
- 1.0
- See Also:
-
hasAttributes
public boolean hasAttributes()Indicates whether named content attributes are present.- Returns:
trueif named content attributes are present; orfalseotherwise- Since:
- 1.0
- See Also:
-
hasAttribute
Indicates whether a specific named content attribute is present.- Parameters:
name- the name of the attribute- Returns:
trueif the name content attribute is present; orfalseotherwise- 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
nullif 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
Contentinstance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aStringvalue.- Parameters:
name- the name of the propertyvalue- the value of the property- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aStringvalue.- Parameters:
name- the name of the propertyvalue- the value of the property- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aStringvalue.- Parameters:
name- the name of the propertyvalue- the value of the property- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aStringvalue.- Parameters:
name- the name of the propertyvalue- the value of the property- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aStringvalue.- Parameters:
name- the name of the propertyvalue- the value of the property- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aStringvalue.- Parameters:
name- the name of the propertyvalue- the value of the property- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aStringvalue.- Parameters:
name- the name of the propertyvalue- the value of the property- Returns:
- the current
Contentinstance - Since:
- 1.0
- See Also:
-
property
Sets a named content property that will be converted internally to aStringvalue.- Parameters:
name- the name of the propertyvalue- the value of the property- Returns:
- the current
Contentinstance - 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
Contentinstance - 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:
trueif properties are present; orfalseotherwise- Since:
- 1.0
- See Also:
-
hasProperty
Indicates whether a specific named content property is present.- Parameters:
name- the name of the property- Returns:
trueif the name content property is present; orfalseotherwise- 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
nullif no such property could be found - Since:
- 1.0
- See Also:
-
getProperties
Retrieves the content properties.- Returns:
- the content properties; or
nullif 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
Contentinstance - 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:
trueif cached loaded content data is present; orfalseotherwise- Since:
- 1.0
- See Also:
-
getCachedLoadedData
Retrieves the cached loaded content data.- Returns:
- the cached loaded content data; or
nullif 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
-