com.google.gdata.model
Interface ElementMetadata<D,E extends Element>

Type Parameters:
D - the datatype of the text node of the element. If the element has no text node this will be Void. See getKey().
E - the element type to use for this metadata. This is the type of the key and is used during parsing. See getKey().
All Superinterfaces:
Metadata<D>
All Known Implementing Classes:
ForwardingElementMetadata

public interface ElementMetadata<D,E extends Element>
extends Metadata<D>

Element metadata. This describes the metadata for an individual element, which extends the Metadata interface with an element type, element cardinality, validator, content requiredness, and attributes and child elements. To create new instances of ElementMetadata you should use MetadataRegistry.build(ElementKey).


Nested Class Summary
static class ElementMetadata.Cardinality
          Cardinality of an element.
static interface ElementMetadata.MultipleVirtualElement
          Defines a virtual element with multiple cardinality.
static interface ElementMetadata.SingleVirtualElement
          Defines a virtual element with single cardinality.
 
Nested classes/interfaces inherited from interface com.google.gdata.model.Metadata
Metadata.VirtualValue
 
Method Summary
 ElementKey<?,?> adapt(java.lang.String kind)
          Adapts this metadata to another type, based on the given kind.
 ElementMetadata<D,E> bind(MetadataContext context)
          Binds this element metadata to the given context.
<K> AttributeMetadata<K>
bindAttribute(AttributeKey<K> key)
          Binds the attribute metadata associated with a particular key.
<K,L extends Element>
ElementMetadata<K,L>
bindElement(ElementKey<K,L> key)
          Binds the child element metadata associated with a particular key.
 E createElement()
          Create an element with this metadata as the metadata for the element.
 AttributeKey<?> findAttribute(QName id)
          Finds an attribute of the given id on this element or any adaptations.
 ElementKey<?,?> findElement(QName id)
          Finds an element of the given id on this element or any adaptations.
 java.util.Collection<AttributeKey<?>> getAttributes()
          Returns an immutable collection of attribute keys in declaration order.
 ElementMetadata.Cardinality getCardinality()
          Returns the cardinality of this element.
 XmlNamespace getDefaultNamespace()
          Returns the best namespace to use as the default in documents if this element is the root type.
 java.util.Collection<ElementKey<?,?>> getElements()
          Returns an immutable set of child keys in declaration order.
 ElementKey<D,E> getKey()
          Returns the element key that this element is bound to.
 ElementMetadata.MultipleVirtualElement getMultipleVirtualElement()
          Returns the virtual element associated with this metadata with repeated cardinality.
 java.lang.Object getProperties()
          Returns the object properties associated with this metadata.
 java.util.Collection<XmlNamespace> getReferencedNamespaces()
          Returns an immutable collection of the namespaces that are referenced by this element, its attributes, and recursively within any declared children.
 ElementMetadata.SingleVirtualElement getSingleVirtualElement()
          Returns the virtual element associated with this metadata with single cardinality.
 ElementValidator getValidator()
          Returns an element validator that can be used to validate this content.
 boolean isContentRequired()
          Returns true if the text content of this element is required.
 boolean isDeclared(AttributeKey<?> key)
          Returns true if this metadata declares the given attribute.
 boolean isDeclared(ElementKey<?,?> element)
          Returns true if this metadata declares the given child element.
 boolean isFlattened()
          Returns true if the element has been flattened, which means its value should be output directly in its parent.
 boolean isReferenced()
          Returns true if the element type is referenced to generate the the output representation of the element type.
 boolean isSelected(Element e)
          Returns true if the element instance is selected for use in the current operation.
 void validate(ValidationContext vc, Element e)
          Validates an element using the specified validation context and the element validator associated with this element metadata.
 
Methods inherited from interface com.google.gdata.model.Metadata
generateValue, getContext, getName, getParent, getSchema, isRequired, isVisible, parseValue
 

Method Detail

adapt

ElementKey<?,?> adapt(java.lang.String kind)
Adapts this metadata to another type, based on the given kind. Will return the element key that the kind represents, or null if no adaptation was found.


bind

ElementMetadata<D,E> bind(MetadataContext context)
Binds this element metadata to the given context.


getKey

ElementKey<D,E> getKey()
Returns the element key that this element is bound to.

Specified by:
getKey in interface Metadata<D>

getCardinality

ElementMetadata.Cardinality getCardinality()
Returns the cardinality of this element.


isReferenced

boolean isReferenced()
Returns true if the element type is referenced to generate the the output representation of the element type. This generally means that the element may be visible or is required to evaluate a selection condition.


isSelected

boolean isSelected(Element e)
Returns true if the element instance is selected for use in the current operation.


isContentRequired

boolean isContentRequired()
Returns true if the text content of this element is required.


isFlattened

boolean isFlattened()
Returns true if the element has been flattened, which means its value should be output directly in its parent.


getValidator

ElementValidator getValidator()
Returns an element validator that can be used to validate this content.


validate

void validate(ValidationContext vc,
              Element e)
Validates an element using the specified validation context and the element validator associated with this element metadata.

Parameters:
vc - validation context.
e - element to be validate.

getProperties

java.lang.Object getProperties()
Returns the object properties associated with this metadata.


getAttributes

java.util.Collection<AttributeKey<?>> getAttributes()
Returns an immutable collection of attribute keys in declaration order.


bindAttribute

<K> AttributeMetadata<K> bindAttribute(AttributeKey<K> key)
Binds the attribute metadata associated with a particular key. Will return null if no such attribute is declared.


isDeclared

boolean isDeclared(AttributeKey<?> key)
Returns true if this metadata declares the given attribute.


findAttribute

AttributeKey<?> findAttribute(QName id)
Finds an attribute of the given id on this element or any adaptations. This can be used to find appropriate attribute metadata to parse into while parsing an element. This will include attributes that are not declared as part of this metadata, but are declared on adaptations.


getElements

java.util.Collection<ElementKey<?,?>> getElements()
Returns an immutable set of child keys in declaration order.


bindElement

<K,L extends Element> ElementMetadata<K,L> bindElement(ElementKey<K,L> key)
Binds the child element metadata associated with a particular key. Will return null if no such element is declared.


isDeclared

boolean isDeclared(ElementKey<?,?> element)
Returns true if this metadata declares the given child element.


findElement

ElementKey<?,?> findElement(QName id)
Finds an element of the given id on this element or any adaptations. This can be used to find appropriate element metadata to parse into while parsing an element.


getSingleVirtualElement

ElementMetadata.SingleVirtualElement getSingleVirtualElement()
Returns the virtual element associated with this metadata with single cardinality. A virtual element represents a completely virtual DOM element that can have its own attributes and child elements, all of which are pulled from elsewhere in the DOM.


getMultipleVirtualElement

ElementMetadata.MultipleVirtualElement getMultipleVirtualElement()
Returns the virtual element associated with this metadata with repeated cardinality. A virtual element represents a completely virtual DOM element that can have its own attributes and child elements, all of which are pulled from elsewhere in the DOM.


createElement

E createElement()
                                throws ContentCreationException
Create an element with this metadata as the metadata for the element.

Throws:
ContentCreationException - if the element could not be created.

getDefaultNamespace

XmlNamespace getDefaultNamespace()
Returns the best namespace to use as the default in documents if this element is the root type.


getReferencedNamespaces

java.util.Collection<XmlNamespace> getReferencedNamespaces()
Returns an immutable collection of the namespaces that are referenced by this element, its attributes, and recursively within any declared children.