com.sun.xml.bind.v2.model.impl
Class ElementInfoImpl.PropertyImpl

java.lang.Object
  extended by com.sun.xml.bind.v2.model.impl.ElementInfoImpl.PropertyImpl
All Implemented Interfaces:
AnnotationSource, ElementPropertyInfo<T,C>, NonElementRef<T,C>, PropertyInfo<T,C>, TypeRef<T,C>
Direct Known Subclasses:
RuntimeElementInfoImpl.RuntimePropertyImpl
Enclosing class:
ElementInfoImpl<T,C,F,M>

protected class ElementInfoImpl.PropertyImpl
extends Object
implements ElementPropertyInfo<T,C>, TypeRef<T,C>, AnnotationSource

Singleton instance of ElementPropertyInfo for this element.


Constructor Summary
protected ElementInfoImpl.PropertyImpl()
           
 
Method Summary
 String displayName()
          Gets the display name of the property.
 Adapter<T,C> getAdapter()
           
 String getDefaultValue()
          The default value for this element if any.
 javax.activation.MimeType getExpectedMimeType()
          Expected MIME type, if any.
 String getName()
          Gets the name of the property.
 QName getSchemaType()
          The effective value of XmlSchemaType annotation, if any.
 PropertyInfo<T,C> getSource()
          Gets the property which is the source of this reference.
 QName getTagName()
          The associated element name.
 NonElement<T,C> getTarget()
          Target of the reference.
 List<? extends TypeRef<T,C>> getTypes()
          Returns the information about the types allowed in this property.
 QName getXmlName()
          Gets the wrapper element name.
 boolean hasAnnotation(Class<? extends Annotation> annotationType)
          Returns true if the property has the specified annotation.
 ID id()
          Returns the IDness of the value of this element.
 boolean inlineBinaryData()
          If this is true and this property indeed represents a binary data, it should be always inlined.
 boolean isCollection()
          Returns true if this is a multi-valued collection property.
 boolean isCollectionNillable()
          Returns true if this property is nillable (meaning the absence of the value is treated as nil='true')
 boolean isCollectionRequired()
          Checks if the wrapper element is required.
 boolean isNillable()
          Returns true if this element is nillable.
 boolean isRequired()
          Returns true if this element is mandatory.
 boolean isValueList()
          For ElementInfos, a collection always means a list of values.
 PropertyKind kind()
          Gets the kind of this proeprty.
 ElementInfoImpl<T,C,F,M> parent()
          Gets the ClassInfo or ElementInfo to which this property belongs.
<A extends Annotation>
A
readAnnotation(Class<A> annotationType)
          Gets the value of the specified annotation from the given property.
 List<? extends NonElement<T,C>> ref()
          List of TypeInfos that this property references.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementInfoImpl.PropertyImpl

protected ElementInfoImpl.PropertyImpl()
Method Detail

getTarget

public NonElement<T,C> getTarget()
Description copied from interface: NonElementRef
Target of the reference.

Specified by:
getTarget in interface NonElementRef<T,C>
Returns:
never null

getTagName

public QName getTagName()
Description copied from interface: TypeRef
The associated element name.

Specified by:
getTagName in interface TypeRef<T,C>
Returns:
never null.

getTypes

public List<? extends TypeRef<T,C>> getTypes()
Description copied from interface: ElementPropertyInfo
Returns the information about the types allowed in this property.

In a simple case like the following, an element property only has one TypeRef that points to String and tag name "foo".

 @XmlElement
 String abc;
 

However, in a general case an element property can be heterogeneous, meaning you can put different types in it, each with a different tag name (and a few other settings.)

 // list can contain String or Integer.
 @XmlElements({
   @XmlElement(name="a",type=String.class),
   @XmlElement(name="b",type=Integer.class),
 })
 List<Object> abc;
 

In this case this method returns a list of two TypeRefs.

Specified by:
getTypes in interface ElementPropertyInfo<T,C>
Returns:
Always non-null. Contains at least one entry. If ElementPropertyInfo.isValueList()==true, there's always exactly one type.

ref

public List<? extends NonElement<T,C>> ref()
Description copied from interface: PropertyInfo
List of TypeInfos that this property references. This allows the caller to traverse the reference graph without getting into the details of each different property type.

Specified by:
ref in interface PropertyInfo<T,C>
Returns:
non-null read-only collection.

getXmlName

public QName getXmlName()
Description copied from interface: ElementPropertyInfo
Gets the wrapper element name.

Specified by:
getXmlName in interface ElementPropertyInfo<T,C>
Returns:
must be null if PropertyInfo.isCollection()==false or if ElementPropertyInfo.isValueList()==true. Otherwise, this can be null (in which case there'll be no wrapper), or it can be non-null (in which case there'll be a wrapper)

isCollectionRequired

public boolean isCollectionRequired()
Description copied from interface: ElementPropertyInfo
Checks if the wrapper element is required.

Specified by:
isCollectionRequired in interface ElementPropertyInfo<T,C>
Returns:
Always false if ElementPropertyInfo.getXmlName()==null.

isCollectionNillable

public boolean isCollectionNillable()
Description copied from interface: ElementPropertyInfo
Returns true if this property is nillable (meaning the absence of the value is treated as nil='true')

This method is only used when this property is a collection.

Specified by:
isCollectionNillable in interface ElementPropertyInfo<T,C>

isNillable

public boolean isNillable()
Description copied from interface: TypeRef
Returns true if this element is nillable.

Specified by:
isNillable in interface TypeRef<T,C>

getDefaultValue

public String getDefaultValue()
Description copied from interface: TypeRef
The default value for this element if any. Otherwise null.

Specified by:
getDefaultValue in interface TypeRef<T,C>

parent

public ElementInfoImpl<T,C,F,M> parent()
Description copied from interface: PropertyInfo
Gets the ClassInfo or ElementInfo to which this property belongs.

Specified by:
parent in interface PropertyInfo<T,C>

getName

public String getName()
Description copied from interface: PropertyInfo
Gets the name of the property.

For example, "foo" or "bar". Generally, a property name is different from XML, (although they are often related, as a property name is often computed from tag names / attribute names.) In fact, property names do not directly affect XML. The property name uniquely identifies a property within a class.

Specified by:
getName in interface PropertyInfo<T,C>
See Also:
XmlType.propOrder()

displayName

public String displayName()
Description copied from interface: PropertyInfo
Gets the display name of the property.

This is a convenience method for parent().getName()+'#'+getName().

Specified by:
displayName in interface PropertyInfo<T,C>

isCollection

public boolean isCollection()
Description copied from interface: PropertyInfo
Returns true if this is a multi-valued collection property. Otherwise false, in which case the property is a single value.

Specified by:
isCollection in interface PropertyInfo<T,C>

isValueList

public boolean isValueList()
For ElementInfos, a collection always means a list of values.

Specified by:
isValueList in interface ElementPropertyInfo<T,C>

isRequired

public boolean isRequired()
Description copied from interface: ElementPropertyInfo
Returns true if this element is mandatory. For collections, this property isn't used. TODO: define the semantics when this is a collection

Specified by:
isRequired in interface ElementPropertyInfo<T,C>

kind

public PropertyKind kind()
Description copied from interface: PropertyInfo
Gets the kind of this proeprty.

Specified by:
kind in interface PropertyInfo<T,C>
Returns:
always non-null.

getAdapter

public Adapter<T,C> getAdapter()
Specified by:
getAdapter in interface ElementPropertyInfo<T,C>
Specified by:
getAdapter in interface PropertyInfo<T,C>
Returns:
null if the property is not adapted.

id

public ID id()
Description copied from interface: PropertyInfo
Returns the IDness of the value of this element.

Specified by:
id in interface PropertyInfo<T,C>
Returns:
always non-null
See Also:
XmlID, XmlIDREF

getExpectedMimeType

public javax.activation.MimeType getExpectedMimeType()
Description copied from interface: PropertyInfo
Expected MIME type, if any.

Specified by:
getExpectedMimeType in interface PropertyInfo<T,C>

getSchemaType

public QName getSchemaType()
Description copied from interface: PropertyInfo
The effective value of XmlSchemaType annotation, if any.

If the property doesn't have XmlSchemaType annotation, this method returns null.

Since a type name is a property of a Java type, not a Java property, A schema type name of a Java type should be primarily obtained by using NonElement.getTypeName(). This method is to correctly implement the ugly semantics of XmlSchemaType (namely when this returns non-null, it overrides the type names of all types that are in this property.)

Specified by:
getSchemaType in interface PropertyInfo<T,C>

inlineBinaryData

public boolean inlineBinaryData()
Description copied from interface: PropertyInfo
If this is true and this property indeed represents a binary data, it should be always inlined.

Specified by:
inlineBinaryData in interface PropertyInfo<T,C>

getSource

public PropertyInfo<T,C> getSource()
Description copied from interface: NonElementRef
Gets the property which is the source of this reference.

Specified by:
getSource in interface NonElementRef<T,C>
Returns:
never null

readAnnotation

public <A extends Annotation> A readAnnotation(Class<A> annotationType)
Description copied from interface: AnnotationSource
Gets the value of the specified annotation from the given property.

When this method is used for a property that consists of a getter and setter, it returns the annotation on either of those methods. If both methods have the same annotation, it is an error.

Specified by:
readAnnotation in interface AnnotationSource
Returns:
null if the annotation is not present.

hasAnnotation

public boolean hasAnnotation(Class<? extends Annotation> annotationType)
Description copied from interface: AnnotationSource
Returns true if the property has the specified annotation.

Short for readAnnotation(annotationType)!=null, but this method is typically faster.

Specified by:
hasAnnotation in interface AnnotationSource