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

java.lang.Object
  extended by com.google.gdata.model.MetadataKey<D>
      extended by com.google.gdata.model.ElementKey<D,E>
Type Parameters:
D - the datatype of the element
E - the element type of the element
All Implemented Interfaces:
java.lang.Comparable<MetadataKey<?>>

public final class ElementKey<D,E extends Element>
extends MetadataKey<D>

A key referring to a particular element. Holds the ID of the element and the expected datatype and element type. Element keys support value-based equality, natural ordering, and matching.


Method Summary
 int compareTo(MetadataKey<?> other)
          Compares first on ID, then on element type, then on datatype.
 boolean equals(java.lang.Object obj)
           
 java.lang.Class<? extends E> getElementType()
          Returns the element type of the element.
 int hashCode()
           
 boolean matches(MetadataKey<?> other)
          Returns true if this key is a match for the given key.
static ElementKey<java.lang.String,Element> of(QName id)
          Return a default element key using a string datatype and Element as the element type.
static
<T,V extends Element>
ElementKey<T,V>
of(QName id, java.lang.Class<? extends T> datatype, java.lang.Class<? extends V> elementType)
          Construct an element key with the given id, datatype, and element type.
static
<V extends Element>
ElementKey<java.lang.Void,V>
of(QName id, java.lang.Class<? extends V> elementType)
          Construct an element key with the given id and element type, but with a Void datatype.
 java.lang.String toString()
           
 
Methods inherited from class com.google.gdata.model.MetadataKey
getDatatype, getId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

of

public static ElementKey<java.lang.String,Element> of(QName id)
Return a default element key using a string datatype and Element as the element type. The id must not be null.


of

public static <V extends Element> ElementKey<java.lang.Void,V> of(QName id,
                                                                  java.lang.Class<? extends V> elementType)
Construct an element key with the given id and element type, but with a Void datatype. This is used for elements without text content.

The elementType must not be null. A null id is only valid for element types that are a subclass of Element, and are used as a key referring to all instances of that element type.


of

public static <T,V extends Element> ElementKey<T,V> of(QName id,
                                                       java.lang.Class<? extends T> datatype,
                                                       java.lang.Class<? extends V> elementType)
Construct an element key with the given id, datatype, and element type. This is used for elements that contain text content.

The elementType must not be null. A null id is only valid for element types that are a subclass of Element, and are used as a key referring to all instances of that element type.


getElementType

public java.lang.Class<? extends E> getElementType()
Returns the element type of the element.


matches

public boolean matches(MetadataKey<?> other)
Returns true if this key is a match for the given key. This key is a match for the other key if the other key is also an element key and if the ID, datatype, and element types all match.

Specified by:
matches in class MetadataKey<D>

compareTo

public int compareTo(MetadataKey<?> other)
Compares first on ID, then on element type, then on datatype.


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class MetadataKey<D>