Class CustomMeta

java.lang.Object
com.tridion.meta.CustomMeta
All Implemented Interfaces:
Serializable

public class CustomMeta extends Object implements 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 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 element
      nameValues - Key-values pairs for this CustomMeta
      children - 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

      public String getName()
      Name of this CustomMeta instance.
      Returns:
      name of this CustomMeta instance
    • getChildren

      public Map<String,CustomMeta> 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

      public Map<String,NameValuePair> 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 public Object getValue(String key)
      Deprecated.
      This method is only for backwards compatibility reasons and should not be used anymore. New method to be used is getFirstValue(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

      public Object getFirstValue(String key)
      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

      public CustomMeta getChild(String key)
      Returns a child CustomMeta identified 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