Package com.tridion.meta
Class CustomMeta
java.lang.Object
com.tridion.meta.CustomMeta
- All Implemented Interfaces:
Serializable
Container for custom metadata of pages or components.
A Custom Meta represents a named custom metadata element and a set of key-value pairs.
In addition, a CustomMeta may embed child CustomMetas forming a Tree-like structure.
Note that this is the only class in the API for the sole reason that the API needs to be backward compatible.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCustomMeta(String name, Map<String, NameValuePair> nameValues, Map<String, CustomMeta> children) Create a new Custom Meta out of the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionReturns a childCustomMetaidentified by [name].Returns a map of child CustomMetas.getFirstValue(String key) Returns the value for the given key [name], the type of object can be a Date, Float or String.getName()Name of this CustomMeta instance.Returns all key-value pairs of this CustomMeta as a Map.Deprecated.This method is only for backwards compatibility reasons and should not be used anymore.booleanisEmpty()This allows checking if the metadata contains actual name / value pairs.
-
Constructor Details
-
CustomMeta
public CustomMeta(String name, Map<String, NameValuePair> nameValues, Map<String, CustomMeta> children) Create a new Custom Meta out of the given parameters.TT57244: Added a null check if children are null, and if so make it an empty list. This occurs when working with a database source, because of the way CustomMetaData is stored in a database. A simple check to see if empty children are passed prevents NullPointerExceptions in the getChild and getChildren methods.
- Parameters:
name- Name of this custom meta elementnameValues- Key-values pairs for this CustomMetachildren- Child CustomMetas for this CustomMeta
-
-
Method Details
-
isEmpty
public boolean isEmpty()This allows checking if the metadata contains actual name / value pairs.- Returns:
- True if there are actual name / value pairs, False if not
-
getName
Name of this CustomMeta instance.- Returns:
- name of this CustomMeta instance
-
getChildren
Returns a map of child CustomMetas. The map [String, CustomMeta] contains the named children of this CustomMeta.- Returns:
- a map of child CustomMetas
-
getNameValues
Returns all key-value pairs of this CustomMeta as a Map.- Returns:
- all key-value pairs of this CustomMeta as a Map
-
getValue
Deprecated.This method is only for backwards compatibility reasons and should not be used anymore. New method to be used isgetFirstValue(String).Returns the value for the given key [name], the type of object can be a Date, Float or String.- Parameters:
key- key to return the value for- Returns:
- the value for the given key [name] or null if no value exists for the given key
-
getFirstValue
Returns the value for the given key [name], the type of object can be a Date, Float or String.- Parameters:
key- key to return the value for- Returns:
- the value for the given key [name] or null if no value exists for the given key
-
getChild
Returns a childCustomMetaidentified by [name].- Parameters:
key- of the child Custom Meta to return- Returns:
- a child CustomMeta identified by the given name or null if such a child CustomMeta does not exist
-