com.sun.tools.xjc.model

Class CPropertyInfo

public abstract class CPropertyInfo extends Object implements PropertyInfo<NType,NClass>, CCustomizable

Model of a property to be generated.
Field Summary
JTypebaseType
If the base type of the property is overriden, this field is set to non-null.
CDefaultValuedefaultValue
If non-null, keeps the default value in Java representation.
booleaninlineBinaryData
Property with @XmlInlineBinaryData.
Stringjavadoc
Javadoc for this property.
Locatorlocator
CClassInfoparent
FieldRendererrealization
Specifies how the field is generated by the backend.
Constructor Summary
protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator)
Method Summary
abstract <V> Vaccept(CPropertyVisitor<V> visitor)
QNamecollectElementNames(Map<QName,CPropertyInfo> table)
Puts the element names that this property possesses to the map, so that we can find two properties that own the same element name, which is an error.
StringdisplayName()
abstract CAdaptergetAdapter()
CCustomizationsgetCustomizations()
LocatorgetLocator()
StringgetName()
Name of the property.
StringgetName(boolean isPublic)
Gets the name of the property.
XSComponentgetSchemaComponent()
If this model object is built from XML Schema, this property returns a schema component from which the model is built.
booleanhasAnnotation(Class<? extends Annotation> annotationType)
booleaninlineBinaryData()
booleanisCollection()
booleanisOptionalPrimitive()
Returns true if this property needs to represent null just for the purpose of representing an absence of the property.
booleanisUnboxable()
Returns true if this property is "unboxable".
protected static booleanneedsExplicitTypeName(TypeUse type, QName typeName)
Checks if the given TypeUse would need an explicit XmlSchemaType annotation with the given type name.
CTypeInfoparent()
<A extends Annotation> AreadAnnotation(Class<A> annotationType)
abstract Collection<? extends CTypeInfo>ref()
voidsetName(boolean isPublic, String newName)
Overrides the name of the property.
voidsetParent(CClassInfo parent)

Field Detail

baseType

public JType baseType
If the base type of the property is overriden, this field is set to non-null.

defaultValue

public CDefaultValue defaultValue
If non-null, keeps the default value in Java representation. If isCollection is true, this field is always null, for we don't handle default values for a list.

inlineBinaryData

public boolean inlineBinaryData
Property with @XmlInlineBinaryData.

javadoc

public String javadoc
Javadoc for this property. Must not be null.

locator

final Locator locator

parent

CClassInfo parent

realization

FieldRenderer realization
Specifies how the field is generated by the backend.

Constructor Detail

CPropertyInfo

protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator)

Method Detail

accept

public abstract <V> V accept(CPropertyVisitor<V> visitor)

collectElementNames

public QName collectElementNames(Map<QName,CPropertyInfo> table)
Puts the element names that this property possesses to the map, so that we can find two properties that own the same element name, which is an error.

Returns: null if no conflict was found. Otherwise return the QName that has the collision.

displayName

public String displayName()

getAdapter

public abstract CAdapter getAdapter()

getCustomizations

public CCustomizations getCustomizations()

getLocator

public Locator getLocator()

getName

public String getName()

Deprecated: marked as deprecated so that we can spot the use of this method.

Name of the property.

This method is implemented to follow the contract of getName, and therefore it always returns the name of the annotated field.

This name is normally not useful for the rest of XJC, which usually wants to access the "public name" of the property. A "public name" of the property is a name like "FooBar" which is used as a seed for generating the accessor methods. This is the name controlled by the schema customization via users.

If the caller is calling this method statically, it's usually the sign of a mistake. Use CPropertyInfo method instead, which forces you to think about which name you want to get.

See Also: CPropertyInfo

getName

public String getName(boolean isPublic)
Gets the name of the property.

Parameters: isPublic if true, this method returns a name like "FooBar", which should be used as a seed for generating user-visible names (such as accessors like "getFooBar".)

if false, this method returns the "name of the property" as defined in the j2s side of the spec. This name is usually something like "fooBar", which often corresponds to the XML element/attribute name of this property (for taking advantage of annotation defaulting as much as possible)

getSchemaComponent

public final XSComponent getSchemaComponent()
If this model object is built from XML Schema, this property returns a schema component from which the model is built.

Returns: null if the model is built from sources other than XML Schema (such as DTD.)

hasAnnotation

public final boolean hasAnnotation(Class<? extends Annotation> annotationType)

inlineBinaryData

public boolean inlineBinaryData()

isCollection

public boolean isCollection()

isOptionalPrimitive

public boolean isOptionalPrimitive()
Returns true if this property needs to represent null just for the purpose of representing an absence of the property.

isUnboxable

public boolean isUnboxable()
Returns true if this property is "unboxable".

In general, a property often has to be capable of representing null to indicate the absence of the value. This requires properties to be generated as @XmlElement Float f, not as @XmlElement float f;. But this is slow.

Fortunately, there are cases where we know that the property can never legally be absent. When this condition holds we can generate the optimized "unboxed form".

The exact such conditions depend on the kind of properties, so refer to the implementation code for the details.

This method returns true when the property can be generated as "unboxed form", false otherwise.

When this property is a collection, this method returns true if items in the collection is unboxable. Obviously, the collection itself is always a reference type.

needsExplicitTypeName

protected static boolean needsExplicitTypeName(TypeUse type, QName typeName)
Checks if the given TypeUse would need an explicit XmlSchemaType annotation with the given type name.

parent

public CTypeInfo parent()

readAnnotation

public final <A extends Annotation> A readAnnotation(Class<A> annotationType)

ref

public abstract Collection<? extends CTypeInfo> ref()

setName

public void setName(boolean isPublic, String newName)
Overrides the name of the property. This method can be used from Plugin. But the caller should do so with the understanding that this is inherently dangerous method.

setParent

final void setParent(CClassInfo parent)