com.google.gdata.model
Class ForwardingElementMetadata<D,E extends Element>

java.lang.Object
  extended by com.google.gdata.model.ForwardingElementMetadata<D,E>
All Implemented Interfaces:
ElementMetadata<D,E>, Metadata<D>

public abstract class ForwardingElementMetadata<D,E extends Element>
extends java.lang.Object
implements ElementMetadata<D,E>

The ForwardingElementMetadata abstract class provides a simple delegating ElementMetadata implementation. It can be subclassed to create transient element metadata instances that override or modify selected behaviors without requiring the creation of a new registered metadata type.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.google.gdata.model.ElementMetadata
ElementMetadata.Cardinality, ElementMetadata.MultipleVirtualElement, ElementMetadata.SingleVirtualElement
 
Nested classes/interfaces inherited from interface com.google.gdata.model.Metadata
Metadata.VirtualValue
 
Constructor Summary
ForwardingElementMetadata()
           
 
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.
protected abstract  ElementMetadata<D,E> delegate()
          Returns the delegate element metadata instance that is the delegation target for this forwarding instance.
 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.lang.Object generateValue(Element element, ElementMetadata<?,?> metadata)
          Generate the value of this property on the given element.
 java.util.Collection<AttributeKey<?>> getAttributes()
          Returns an immutable collection of attribute keys in declaration order.
 ElementMetadata.Cardinality getCardinality()
          Returns the cardinality of this element.
 MetadataContext getContext()
          Returns the metadata context that this metadata was created for, or null if this metadata is not part of a context.
 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.
 QName getName()
          Returns the qualified name of the property, used during parsing and generation.
 ElementKey<?,?> getParent()
          Returns the parent of this metadata instance, or null if this metadata does not take the parent key into account.
 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.
 Schema getSchema()
          Returns the Schema that this metadata is a part of.
 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 isRequired()
          Returns true if this property is required.
 boolean isSelected(Element e)
          Returns true if the element instance is selected for use in the current operation.
 boolean isVisible()
          Returns true if this property is visible.
 void parseValue(Element element, ElementMetadata<?,?> metadata, java.lang.Object value)
          Parses the value of this property into the given element.
 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForwardingElementMetadata

public ForwardingElementMetadata()
Method Detail

delegate

protected abstract ElementMetadata<D,E> delegate()
Returns the delegate element metadata instance that is the delegation target for this forwarding instance.


adapt

public ElementKey<?,?> adapt(java.lang.String kind)
Description copied from interface: ElementMetadata
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.

Specified by:
adapt in interface ElementMetadata<D,E extends Element>

bind

public ElementMetadata<D,E> bind(MetadataContext context)
Description copied from interface: ElementMetadata
Binds this element metadata to the given context.

Specified by:
bind in interface ElementMetadata<D,E extends Element>

bindAttribute

public <K> AttributeMetadata<K> bindAttribute(AttributeKey<K> key)
Description copied from interface: ElementMetadata
Binds the attribute metadata associated with a particular key. Will return null if no such attribute is declared.

Specified by:
bindAttribute in interface ElementMetadata<D,E extends Element>

bindElement

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

Specified by:
bindElement in interface ElementMetadata<D,E extends Element>

createElement

public E createElement()
                                throws ContentCreationException
Description copied from interface: ElementMetadata
Create an element with this metadata as the metadata for the element.

Specified by:
createElement in interface ElementMetadata<D,E extends Element>
Throws:
ContentCreationException - if the element could not be created.

findAttribute

public AttributeKey<?> findAttribute(QName id)
Description copied from interface: ElementMetadata
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.

Specified by:
findAttribute in interface ElementMetadata<D,E extends Element>

findElement

public ElementKey<?,?> findElement(QName id)
Description copied from interface: ElementMetadata
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.

Specified by:
findElement in interface ElementMetadata<D,E extends Element>

getAttributes

public java.util.Collection<AttributeKey<?>> getAttributes()
Description copied from interface: ElementMetadata
Returns an immutable collection of attribute keys in declaration order.

Specified by:
getAttributes in interface ElementMetadata<D,E extends Element>

getCardinality

public ElementMetadata.Cardinality getCardinality()
Description copied from interface: ElementMetadata
Returns the cardinality of this element.

Specified by:
getCardinality in interface ElementMetadata<D,E extends Element>

getElements

public java.util.Collection<ElementKey<?,?>> getElements()
Description copied from interface: ElementMetadata
Returns an immutable set of child keys in declaration order.

Specified by:
getElements in interface ElementMetadata<D,E extends Element>

getKey

public ElementKey<D,E> getKey()
Description copied from interface: ElementMetadata
Returns the element key that this element is bound to.

Specified by:
getKey in interface ElementMetadata<D,E extends Element>
Specified by:
getKey in interface Metadata<D>

getProperties

public java.lang.Object getProperties()
Description copied from interface: ElementMetadata
Returns the object properties associated with this metadata.

Specified by:
getProperties in interface ElementMetadata<D,E extends Element>

getValidator

public ElementValidator getValidator()
Description copied from interface: ElementMetadata
Returns an element validator that can be used to validate this content.

Specified by:
getValidator in interface ElementMetadata<D,E extends Element>

isContentRequired

public boolean isContentRequired()
Description copied from interface: ElementMetadata
Returns true if the text content of this element is required.

Specified by:
isContentRequired in interface ElementMetadata<D,E extends Element>

isDeclared

public boolean isDeclared(AttributeKey<?> key)
Description copied from interface: ElementMetadata
Returns true if this metadata declares the given attribute.

Specified by:
isDeclared in interface ElementMetadata<D,E extends Element>

isDeclared

public boolean isDeclared(ElementKey<?,?> element)
Description copied from interface: ElementMetadata
Returns true if this metadata declares the given child element.

Specified by:
isDeclared in interface ElementMetadata<D,E extends Element>

isReferenced

public boolean isReferenced()
Description copied from interface: ElementMetadata
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.

Specified by:
isReferenced in interface ElementMetadata<D,E extends Element>

isSelected

public boolean isSelected(Element e)
Description copied from interface: ElementMetadata
Returns true if the element instance is selected for use in the current operation.

Specified by:
isSelected in interface ElementMetadata<D,E extends Element>

isFlattened

public boolean isFlattened()
Description copied from interface: ElementMetadata
Returns true if the element has been flattened, which means its value should be output directly in its parent.

Specified by:
isFlattened in interface ElementMetadata<D,E extends Element>

validate

public void validate(ValidationContext vc,
                     Element e)
Description copied from interface: ElementMetadata
Validates an element using the specified validation context and the element validator associated with this element metadata.

Specified by:
validate in interface ElementMetadata<D,E extends Element>
Parameters:
vc - validation context.
e - element to be validate.

generateValue

public java.lang.Object generateValue(Element element,
                                      ElementMetadata<?,?> metadata)
Description copied from interface: Metadata
Generate the value of this property on the given element. If the property is virtual, it will be used to generate the value, otherwise the regular property value will be used.

Specified by:
generateValue in interface Metadata<D>

getContext

public MetadataContext getContext()
Description copied from interface: Metadata
Returns the metadata context that this metadata was created for, or null if this metadata is not part of a context.

Specified by:
getContext in interface Metadata<D>

getName

public QName getName()
Description copied from interface: Metadata
Returns the qualified name of the property, used during parsing and generation. For atom this will usually be the same as the id, but for json or other alt types it may be different.

Specified by:
getName in interface Metadata<D>
Returns:
the qualified name of the property.

getParent

public ElementKey<?,?> getParent()
Description copied from interface: Metadata
Returns the parent of this metadata instance, or null if this metadata does not take the parent key into account.

Specified by:
getParent in interface Metadata<D>

getSchema

public Schema getSchema()
Description copied from interface: Metadata
Returns the Schema that this metadata is a part of.

Specified by:
getSchema in interface Metadata<D>

isRequired

public boolean isRequired()
Description copied from interface: Metadata
Returns true if this property is required. If a property is required it must appear in its parent element for that parent element to be valid.

Specified by:
isRequired in interface Metadata<D>
Returns:
true if the property is required in its parent element.

isVisible

public boolean isVisible()
Description copied from interface: Metadata
Returns true if this property is visible. If a property is visible it will be included in the output generation for its parent element, if it is hidden (not visible) it will not be included.

Specified by:
isVisible in interface Metadata<D>
Returns:
true if the property is visible in its parent element.

parseValue

public void parseValue(Element element,
                       ElementMetadata<?,?> metadata,
                       java.lang.Object value)
                throws ParseException
Description copied from interface: Metadata
Parses the value of this property into the given element. If the property is virtual, it will be used to parse the value, otherwise the value will be stored directly in the property.

Specified by:
parseValue in interface Metadata<D>
Throws:
ParseException - if parsing fails.

getMultipleVirtualElement

public ElementMetadata.MultipleVirtualElement getMultipleVirtualElement()
Description copied from interface: ElementMetadata
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.

Specified by:
getMultipleVirtualElement in interface ElementMetadata<D,E extends Element>

getSingleVirtualElement

public ElementMetadata.SingleVirtualElement getSingleVirtualElement()
Description copied from interface: ElementMetadata
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.

Specified by:
getSingleVirtualElement in interface ElementMetadata<D,E extends Element>

getDefaultNamespace

public XmlNamespace getDefaultNamespace()
Description copied from interface: ElementMetadata
Returns the best namespace to use as the default in documents if this element is the root type.

Specified by:
getDefaultNamespace in interface ElementMetadata<D,E extends Element>

getReferencedNamespaces

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

Specified by:
getReferencedNamespaces in interface ElementMetadata<D,E extends Element>