Class CPropertyInfo
- All Implemented Interfaces:
CCustomizable
,AnnotationSource
,PropertyInfo<NType,
NClass>
- Direct Known Subclasses:
CAttributePropertyInfo
,CElementPropertyInfo
,CReferencePropertyInfo
,CValuePropertyInfo
- Author:
- Kohsuke Kawaguchi
-
Field Summary
FieldsModifier and TypeFieldDescriptionIf the base type of the property is overriden, this field is set to non-null.If non-null, keeps the default value in Java representation.boolean
Property annotated withXmlInlineBinaryData
.Javadoc for this property.final Locator
Specifies how the field is generated by the backend. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CPropertyInfo
(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator) -
Method Summary
Modifier and TypeMethodDescriptionabstract <V> V
accept
(CPropertyVisitor<V> visitor) abstract <R,
P> R accept
(CPropertyVisitor2<R, P> visitor, P p) 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.Gets the display name of the property.abstract CAdapter
Gets the list of customizations attached to this model component.Gets the source location in the schema from which this model component is created.getName()
Deprecated.marked as deprecated so that we can spot the use of this method.getName
(boolean isPublic) Gets the name of the property.final XSComponent
If this model object is built from XML Schema, this property returns a schema component from which the model is built.final boolean
hasAnnotation
(Class<? extends Annotation> annotationType) Returns true if the property has the specified annotation.boolean
If this is true and this property indeed represents a binary data, it should be always inlined.boolean
Returns true if this is a multi-valued collection property.boolean
Returns true if this property needs to represent null just for the purpose of representing an absence of the property.boolean
Returns true if this property is "unboxable".protected static boolean
needsExplicitTypeName
(TypeUse type, QName typeName) Checks if the givenTypeUse
would need an explicitXmlSchemaType
annotation with the given type name.parent()
Gets theClassInfo
orElementInfo
to which this property belongs.final <A extends Annotation>
AreadAnnotation
(Class<A> annotationType) Gets the value of the specified annotation from the given property.abstract Collection<? extends CTypeInfo>
ref()
List ofTypeInfo
s that this property references.void
Overrides the name of the property.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.sun.xml.bind.v2.model.core.PropertyInfo
getExpectedMimeType, getSchemaType, id, kind
-
Field Details
-
locator
-
baseType
If the base type of the property is overriden, this field is set to non-null. -
javadoc
Javadoc for this property. Must not be null. -
inlineBinaryData
public boolean inlineBinaryDataProperty annotated withXmlInlineBinaryData
. -
realization
Specifies how the field is generated by the backend. -
defaultValue
If non-null, keeps the default value in Java representation. IfisCollection
is true, this field is always null, for we don't handle default values for a list.
-
-
Constructor Details
-
CPropertyInfo
protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator)
-
-
Method Details
-
parent
Description copied from interface:PropertyInfo
Gets theClassInfo
orElementInfo
to which this property belongs.- Specified by:
parent
in interfacePropertyInfo<NType,
NClass>
-
getLocator
Description copied from interface:CCustomizable
Gets the source location in the schema from which this model component is created.- Specified by:
getLocator
in interfaceCCustomizable
- Returns:
- never null.
-
getSchemaComponent
If this model object is built from XML Schema, this property returns a schema component from which the model is built.- Specified by:
getSchemaComponent
in interfaceCCustomizable
- Returns:
- null if the model is built from sources other than XML Schema (such as DTD.)
-
getAdapter
- Specified by:
getAdapter
in interfacePropertyInfo<NType,
NClass> - Returns:
- null if the property is not adapted.
-
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
PropertyInfo.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
getName(boolean)
method instead, which forces you to think about which name you want to get.- Specified by:
getName
in interfacePropertyInfo<NType,
NClass> - See Also:
-
getName
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)
-
setName
Overrides the name of the property. This method can be used fromPlugin.postProcessModel(Model, ErrorHandler)
. But the caller should do so with the understanding that this is inherently dangerous method. -
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 interfacePropertyInfo<NType,
NClass>
-
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 interfacePropertyInfo<NType,
NClass>
-
ref
Description copied from interface:PropertyInfo
List ofTypeInfo
s 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 interfacePropertyInfo<NType,
NClass> - Returns:
- non-null read-only collection.
-
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.
-
isOptionalPrimitive
public boolean isOptionalPrimitive()Returns true if this property needs to represent null just for the purpose of representing an absence of the property. -
getCustomizations
Description copied from interface:CCustomizable
Gets the list of customizations attached to this model component.- Specified by:
getCustomizations
in interfaceCCustomizable
- Returns:
- can be an empty list but never be null. The returned list is read-only. Do not modify.
- See Also:
-
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 interfacePropertyInfo<NType,
NClass>
-
accept
-
accept
-
needsExplicitTypeName
Checks if the givenTypeUse
would need an explicitXmlSchemaType
annotation with the given type name. -
collectElementNames
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.
-
readAnnotation
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 interfaceAnnotationSource
- Returns:
- null if the annotation is not present.
-
hasAnnotation
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 interfaceAnnotationSource
-