com.sun.tools.xjc.reader.xmlschema.bindinfo
Class BIProperty

java.lang.Object
  extended by com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty
All Implemented Interfaces:
BIDeclaration

public final class BIProperty
extends java.lang.Object

Property customization. This customization turns an arbitrary schema component into a Java property (some restrictions apply.)

All the getter methods (such as getBaseType or getBindStyle) honors the delegation chain of property customization specified in the spec. Namely, if two property customizations are attached to an attribute use and an attribute decl, then anything unspecified in the attribute use defaults to attribute decl.

Property customizations are acknowledged (1) when they are actually used, and (2) when they are given at the component, which is mapped to a class. (so-called "point of declaration" customization)


Field Summary
static javax.xml.namespace.QName NAME
          Name of this declaration.
protected  BindInfo parent
           
 
Constructor Summary
protected BIProperty()
           
  BIProperty(org.xml.sax.Locator loc, java.lang.String _propName, java.lang.String _javadoc, com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty.BaseTypeBean _baseType, com.sun.tools.xjc.reader.xmlschema.bindinfo.CollectionTypeAttribute collectionType, java.lang.Boolean isConst, OptionalPropertyMode optionalProperty, java.lang.Boolean genElemProp)
           
 
Method Summary
 CAttributePropertyInfo createAttributeProperty(com.sun.xml.xsom.XSAttributeUse use, TypeUse tu)
           
 CReferencePropertyInfo createContentExtendedMixedReferenceProperty(java.lang.String defaultName, com.sun.xml.xsom.XSComponent source, RawTypeSet types)
           
 CReferencePropertyInfo createDummyExtendedMixedReferenceProperty(java.lang.String defaultName, com.sun.xml.xsom.XSComponent source, RawTypeSet types)
           
 CPropertyInfo createElementOrReferenceProperty(java.lang.String defaultName, boolean forConstant, com.sun.xml.xsom.XSParticle source, RawTypeSet types)
           
 CElementPropertyInfo createElementProperty(java.lang.String defaultName, boolean forConstant, com.sun.xml.xsom.XSParticle source, RawTypeSet types)
           
 CReferencePropertyInfo createReferenceProperty(java.lang.String defaultName, boolean forConstant, com.sun.xml.xsom.XSComponent source, RawTypeSet types, boolean isMixed, boolean dummy, boolean content, boolean isMixedExtended)
           
 CValuePropertyInfo createValueProperty(java.lang.String defaultName, boolean forConstant, com.sun.xml.xsom.XSComponent source, TypeUse tu, javax.xml.namespace.QName typeName)
           
 com.sun.codemodel.JType getBaseType()
           
protected  BGMBuilder getBuilder()
           
 java.util.Collection<BIDeclaration> getChildren()
          Gets child BIDeclarations if any.
protected  com.sun.codemodel.JCodeModel getCodeModel()
           
 BIConversion getConv()
           
static BIProperty getCustomization(com.sun.xml.xsom.XSComponent c)
          Finds a property customization that describes how the given component should be mapped to a property (if it's mapped to a property at all.)
protected  BIProperty getDefault()
          Finds a BIProperty which this object should delegate to.
 java.lang.String getJavadoc()
          Gets the associated javadoc.
 org.xml.sax.Locator getLocation()
          Gets the source location where this declaration was written.
 javax.xml.namespace.QName getName()
          Gets the name of this binding declaration, which is the same as the tag name of the binding element.
 OptionalPropertyMode getOptionalPropertyMode()
           
protected  com.sun.xml.xsom.XSComponent getOwner()
           
 java.lang.String getPropertyName(boolean forConstant)
          Returns the customized property name.
 boolean isAcknowledged()
          Checks if this declaration was acknowledged.
 boolean isConstantProperty()
          Gets the inherited value of the "fixedAttrToConstantProperty" customization.
 void markAsAcknowledged()
          Marks this declaration to be acknowledged -- either actually used or the existence is admitted (for example when a property customization is given at the point of definition.)
 void onSetOwner()
          Called when the parent BindInfo got its owner set.
 void setParent(BindInfo parent)
          Sets the parent BindInfo object of this declaration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final javax.xml.namespace.QName NAME
Name of this declaration.


parent

protected BindInfo parent
Constructor Detail

BIProperty

public BIProperty(org.xml.sax.Locator loc,
                  java.lang.String _propName,
                  java.lang.String _javadoc,
                  com.sun.tools.xjc.reader.xmlschema.bindinfo.BIProperty.BaseTypeBean _baseType,
                  com.sun.tools.xjc.reader.xmlschema.bindinfo.CollectionTypeAttribute collectionType,
                  java.lang.Boolean isConst,
                  OptionalPropertyMode optionalProperty,
                  java.lang.Boolean genElemProp)

BIProperty

protected BIProperty()
Method Detail

getChildren

public java.util.Collection<BIDeclaration> getChildren()
Description copied from interface: BIDeclaration
Gets child BIDeclarations if any.

Specified by:
getChildren in interface BIDeclaration
Returns:
can be empty but always non-null. read-only.

setParent

public void setParent(BindInfo parent)
Description copied from interface: BIDeclaration
Sets the parent BindInfo object of this declaration. A declaration object can use this pointer to access context information, such as other customizations.

This method can be only called from BindInfo, and only once. This is a good opportunity to do some follow-up initialization after JAXB unmarshalling populated BIDeclaration.

Specified by:
setParent in interface BIDeclaration

getPropertyName

public java.lang.String getPropertyName(boolean forConstant)
Returns the customized property name. This method honors the "enableJavaNamingConvention" customization and formats the property name accordingly if necessary. Thus the caller should NOT apply the XML-to-Java name conversion algorithm to the value returned from this method.

Parameters:
forConstant - If the property name is intended for a constant property name, set to true. This will change the result
Returns:
This method can return null if the customization doesn't specify the name.

getJavadoc

public java.lang.String getJavadoc()
Gets the associated javadoc.

Returns:
null if none is specfieid.

getBaseType

public com.sun.codemodel.JType getBaseType()

getOptionalPropertyMode

public OptionalPropertyMode getOptionalPropertyMode()

isConstantProperty

public boolean isConstantProperty()
Gets the inherited value of the "fixedAttrToConstantProperty" customization.

Note that returning true from this method doesn't necessarily mean that a property needs to be mapped to a constant property. It just means that it's mapped to a constant property if an attribute use carries a fixed value.

I don't like this semantics but that's what the spec implies.


createValueProperty

public CValuePropertyInfo createValueProperty(java.lang.String defaultName,
                                              boolean forConstant,
                                              com.sun.xml.xsom.XSComponent source,
                                              TypeUse tu,
                                              javax.xml.namespace.QName typeName)

createAttributeProperty

public CAttributePropertyInfo createAttributeProperty(com.sun.xml.xsom.XSAttributeUse use,
                                                      TypeUse tu)

createElementProperty

public CElementPropertyInfo createElementProperty(java.lang.String defaultName,
                                                  boolean forConstant,
                                                  com.sun.xml.xsom.XSParticle source,
                                                  RawTypeSet types)
Parameters:
defaultName - If the name is not customized, this name will be used as the default. Note that the name conversion MUST be applied before this method is called if necessary.
source - Source schema component from which a field is built.

createDummyExtendedMixedReferenceProperty

public CReferencePropertyInfo createDummyExtendedMixedReferenceProperty(java.lang.String defaultName,
                                                                        com.sun.xml.xsom.XSComponent source,
                                                                        RawTypeSet types)

createContentExtendedMixedReferenceProperty

public CReferencePropertyInfo createContentExtendedMixedReferenceProperty(java.lang.String defaultName,
                                                                          com.sun.xml.xsom.XSComponent source,
                                                                          RawTypeSet types)

createReferenceProperty

public CReferencePropertyInfo createReferenceProperty(java.lang.String defaultName,
                                                      boolean forConstant,
                                                      com.sun.xml.xsom.XSComponent source,
                                                      RawTypeSet types,
                                                      boolean isMixed,
                                                      boolean dummy,
                                                      boolean content,
                                                      boolean isMixedExtended)

createElementOrReferenceProperty

public CPropertyInfo createElementOrReferenceProperty(java.lang.String defaultName,
                                                      boolean forConstant,
                                                      com.sun.xml.xsom.XSParticle source,
                                                      RawTypeSet types)

markAsAcknowledged

public void markAsAcknowledged()
Description copied from interface: BIDeclaration
Marks this declaration to be acknowledged -- either actually used or the existence is admitted (for example when a property customization is given at the point of definition.)

Declarations that are not acknowledged will be considered as an error.

Specified by:
markAsAcknowledged in interface BIDeclaration

getDefault

protected BIProperty getDefault()
Finds a BIProperty which this object should delegate to.

Returns:
always return non-null for normal BIProperties. If this object is contained in the BIGlobalBinding, then this method returns null to indicate that there's no more default.

getCustomization

public static BIProperty getCustomization(com.sun.xml.xsom.XSComponent c)
Finds a property customization that describes how the given component should be mapped to a property (if it's mapped to a property at all.)

Consider an attribute use that does NOT carry a property customization. This schema component is nonetheless considered to carry a (sort of) implicit property customization, whose values are defaulted.

This method can be think of the method that returns this implied property customization.

Note that this doesn't mean the given component needs to be mapped to a property. But if it does map to a property, it needs to follow this customization. I think this semantics is next to non-sense but I couldn't think of any other way to follow the spec.

Parameters:
c - A customization effective on this component will be returned. Can be null just to get the global customization.
Returns:
Always return non-null valid object.

getName

public javax.xml.namespace.QName getName()
Description copied from interface: BIDeclaration
Gets the name of this binding declaration, which is the same as the tag name of the binding element.


getConv

public BIConversion getConv()

getLocation

public org.xml.sax.Locator getLocation()
Description copied from interface: BIDeclaration
Gets the source location where this declaration was written. For declarations that are generated by XJC itself, this method returns null.

Specified by:
getLocation in interface BIDeclaration

getOwner

protected final com.sun.xml.xsom.XSComponent getOwner()

getBuilder

protected final BGMBuilder getBuilder()

getCodeModel

protected final com.sun.codemodel.JCodeModel getCodeModel()

isAcknowledged

public final boolean isAcknowledged()
Description copied from interface: BIDeclaration
Checks if this declaration was acknowledged.

Specified by:
isAcknowledged in interface BIDeclaration

onSetOwner

public void onSetOwner()
Description copied from interface: BIDeclaration
Called when the parent BindInfo got its owner set. This is when declarations are connected to BGMBuilder and its sibling components.

Specified by:
onSetOwner in interface BIDeclaration