Class XMLBindingComponent

java.lang.Object
org.exolab.castor.builder.binding.XMLBindingComponent
All Implemented Interfaces:
BindingComponent

public final class XMLBindingComponent extends Object implements BindingComponent
This class is the implementation of BindingComponent from an XML Schema point of view. This specific implementation wraps an XML Schema annotated structure.

The XML Schema structure can be only of four different types:

  • Element: it represents an XML Schema element.
  • ComplexType: it represents an XML Schema complexType.
  • ModelGroup: it represents an XML Schema Model group definition.
  • Group: it represents an XML Schema Model Group.

The three first items can be customized using a binding file. Thus the XMLBindingComponent class takes into account the presence or not of a custom binding document in the computation of the needed information for the Source Generator to generate java classes from an XML Schema.

The customizable items are detailled in the binding file documentation.

This class acts like a window on a particular XML Schema structure that the user controls by changing the view on the Annotated Structure he is interested in.

Version:
$Revision: 7983 $ $Date: 2006-04-25 15:08:23 -0600 (Tue, 25 Apr 2006) $
Author:
Arnaud Blandin, Keith Visco
See Also:
  • Field Summary

    Fields inherited from interface org.exolab.castor.builder.BindingComponent

    CLASS, CONTENT_MEMBER_TYPE, ENUM_TYPE, INTERFACE, MEMBER
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an XMLBindingComponent from an XML Schema Component.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the binding of this XMLBindingComponent will require the generation of 2 java classes.
    boolean
    equals(Object object)
    Returns true if the given Object is equal to this instance of XMLBindingComponent.
    Returns the XML Schema annotated structure used in this XMLBindingComponent.
    Returns the Binding Object Model on which this XMLBindingComponent will query information.
    Returns the collection name specified in the binding file.
    Returns the ComponentBinding used in that XMLBindingComponent to retrieve customized information.
    Returns the name 'override' of a content member as specified in a binding file.
    Returns the EnumBindingType instance for the active binding component.
    Returns the name of a super class for the current XMLBinding.
    Returns an array of the different interface names implemented by the class that will represent the current XMLBindingComponent.
    Returns a valid Java Class Name corresponding to this XMLBindingComponent.
    Returns a valid Java Member Name corresponding to this XMLBindingComponent.
    Returns the java package associated with this XML BindingComponent.
    Returns the XSType that corresponds to the Java type chosen to represent the XML Schema component represented by this XMLBindingComponent.
    int
    Returns the lower bound of the collection that is generated from this BindingComponent.
    Returns the fully qualified name used for generating a java name that represents this XMLBindingComponent.
    Returns the underlying Schema of the wrapped structure.
    Returns the schemaLocation of the parent schema of the wrapped structure.
    Returns the targetNamespace of the parent schema of the wrapped structure.
    short
    Returns the type of this component binding.
    int
    Returns the upper bound of the collection that is generated from this BindingComponent.
    Returns the fully qualified name of the Validator to use.
    Returns the value specified in the XML Schema for the XML Schema component wrapped in this XMLBindingComponent.
    Returns the visibility of the Java member to generate.
    Returns the fully qualified name of the XMLFieldHandler to use.
    Returns the XML name declared in the XML Schema for this XMLBindingComponent.
    Returns the XMLType of the underlying structure.
    boolean
    Returns true if bound properties must be generated for the class that will represent the current XMLBindingComponent.
    boolean
    Returns true if equal method must be generated for the class that will represent the current XMLBindingComponent.
    int
    Returns the hashCode value for this object.
    boolean
    Returns true if the class that will represent the current XMLBindingComponent must be abstract.
    boolean
    Returns true if the class that will represent the current XMLBindingComponent must be final.
    boolean
    Returns true if the wrapped XML Schema component is fixed (i.e the value used is fixed).
    boolean
    Returns true if the wrapped XML Schema component is nillable.
    void
    Sets the Binding Object Model on which this XMLBindingComponent will query information.
    void
    setView(Annotated annotated)
    Sets the window on the given Annotated XML Schema structure.
    boolean
    Returns true if the member represented by that XMLBindingComponent is to be represented by an Object wrapper.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • XMLBindingComponent

      public XMLBindingComponent(BuilderConfiguration config, GroupNaming groupNaming)
      Constructs an XMLBindingComponent from an XML Schema Component.
      Parameters:
      config - the BuilderConfiguration instance (must not be null).
      groupNaming - The group naming scheme to be used.
  • Method Details

    • getBinding

      public ExtendedBinding getBinding()
      Returns the Binding Object Model on which this XMLBindingComponent will query information.
      Returns:
      the Extended Binding Object Model that wraps the information located in a binding file
    • setBinding

      public void setBinding(ExtendedBinding binding)
      Sets the Binding Object Model on which this XMLBindingComponent will query information.
      Parameters:
      binding - the Extended Binding Object Model that wraps the information located in a binding file
    • setView

      public void setView(Annotated annotated)
      Sets the window on the given Annotated XML Schema structure. Once the window is set on a particular XML Schema structure all the information returned by this class are relative to that XML Schema structure.
      Parameters:
      annotated - an Annotated XML Schema structure.
      See Also:
    • equals

      public boolean equals(Object object)
      Returns true if the given Object is equal to this instance of XMLBindingComponent.
      Specified by:
      equals in interface BindingComponent
      Overrides:
      equals in class Object
      Parameters:
      object - the object to compare to this instance
      Returns:
      true if the given Object is equal to this instance of XMLBindingComponent.
      See Also:
    • hashCode

      public int hashCode()
      Returns the hashCode value for this object.
      Specified by:
      hashCode in interface BindingComponent
      Overrides:
      hashCode in class Object
      Returns:
      the hashcode value for this object.
      See Also:
    • getComponentBinding

      protected ComponentBindingType getComponentBinding()
      Returns the ComponentBinding used in that XMLBindingComponent to retrieve customized information.
      Returns:
      the ComponentBinding used in that XMLBinding.
    • getAnnotated

      public Annotated getAnnotated()
      Returns the XML Schema annotated structure used in this XMLBindingComponent.
      Returns:
      the XML Schema annotated structure used in this XMLBindingComponent.
    • createGroupItem

      public boolean createGroupItem()
      Returns true if the binding of this XMLBindingComponent will require the generation of 2 java classes. Indeed an a nested Model Group that can occur more than once is described by the SourceGenerator with a wrapper class.
      Returns:
      true if the binding of this XMLBindingComponent will require the generation of 2 java classes.
    • getSchemaLocation

      public String getSchemaLocation()
      Returns the schemaLocation of the parent schema of the wrapped structure.
      Returns:
      the schemaLocation of the parent schema of the wrapped structure.
    • getTargetNamespace

      public String getTargetNamespace()
      Returns the targetNamespace of the parent schema of the wrapped structure.
      Returns:
      the targetNamespace of the parent schema of the wrapped structure.
    • getSchema

      public Schema getSchema()
      Returns the underlying Schema of the wrapped structure.
      Returns:
      the parent schema of the wrapped structure.
    • getXMLType

      public XMLType getXMLType()
      Returns the XMLType of the underlying structure. The XMLType of an element being its XML Schema type, the XMLType of a ComplexType being itself and the XMLType of an attribute being its XML Schema simpleType. Null is returned for a Model Group.
      Returns:
      the XMLType of the underlying structure.
    • getXMLName

      public String getXMLName()
      Returns the XML name declared in the XML Schema for this XMLBindingComponent.
      Returns:
      the XML name declared in the XML Schema for this XMLBindingComponent.
    • getValue

      public String getValue()
      Returns the value specified in the XML Schema for the XML Schema component wrapped in this XMLBindingComponent. The value returned is the default or fixed value for an Element or an Attribute.
      Specified by:
      getValue in interface BindingComponent
      Returns:
      the value specified in the XML Schema for the XML Schema annotated structure wrapped in this XMLBindingComponent.
    • getJavaClassName

      public String getJavaClassName()
      Returns a valid Java Class Name corresponding to this XMLBindingComponent. This name is not qualified, this is only a local Java class name.
      Specified by:
      getJavaClassName in interface BindingComponent
      Returns:
      a valid Java Class Name corresponding to this XMLBindingComponent. This name is not qualified, this is only a local Java class name.
      See Also:
    • getJavaMemberName

      public String getJavaMemberName()
      Returns a valid Java Member Name corresponding to this XMLBindingComponent. This name is not qualified, this is only a local Java Member name.
      Specified by:
      getJavaMemberName in interface BindingComponent
      Returns:
      a valid Java Member Name corresponding to this XMLBindingComponent. This name is not qualified, this is only a local Java member name.
      See Also:
    • getQualifiedName

      public String getQualifiedName()
      Returns the fully qualified name used for generating a java name that represents this XMLBindingComponent.

      The fully qualified name is computed according the following priority order:

      • If the XMLBinding wraps a class binding then the package name is the name defined locally in the <java-class> element. More precisely the package name will be the value of the attribute package.
      • Else the package name will be computed from the schemaLocation of the parent schema.
      • Else the package name will be computed from the target namespace of the parent schema.
      Note: the computation of the namespace is a direct look-up for a defined mapping (Namespace, package) or (schema location, package).
      Specified by:
      getQualifiedName in interface BindingComponent
      Returns:
      the fully qualified name used for generating a java name that represents this XMLBindingComponent.
    • getJavaPackage

      public String getJavaPackage()
      Returns the java package associated with this XML BindingComponent. The algorithm used to resolve the package is defined according to the following priorities:
      1. The package defined locally in the class declaration inside the binding file is used.
      2. If no package has been defined locally then a lookup to a defined mapping {targetNamespace, package name} is performed.
      3. If no package has been defined locally then a lookup to a defined mapping {schema location, package name} is performed.
      Specified by:
      getJavaPackage in interface BindingComponent
      Returns:
      the java package associated with this XML BindingComponent.
    • getUpperBound

      public int getUpperBound()
      Returns the upper bound of the collection that is generated from this BindingComponent. The upper bound is a positive integer. -1 is returned to indicate that the upper bound is unbounded.

      In the case of an XML Schema component, the upper bound corresponds to the XML Schema maxOccurs attribute, if any.

      Specified by:
      getUpperBound in interface BindingComponent
      Returns:
      an int representing the lower bound of the collection generated from this BindingComponent. -1 is returned to indicate that the upper bound is unbounded. 1 is the default value.
    • getLowerBound

      public int getLowerBound()
      Returns the lower bound of the collection that is generated from this BindingComponent. The lower bound is a positive integer. In the case of an XML Schema component, it corresponds to the XML Schema minOccurs attribute, if any.
      Specified by:
      getLowerBound in interface BindingComponent
      Returns:
      an int representing the lower bound of the collection generated from this BindingComponent. 0 is returned by default.
    • getExtends

      public String getExtends()
      Returns the name of a super class for the current XMLBinding. Null is returned if this XMLBinding is not meant to be mapped to a java class.
      Specified by:
      getExtends in interface BindingComponent
      Returns:
      the name of a super class for the current XMLBinding. Null is returned if this XMLBinding is not meant to be mapped to a java class
    • getImplements

      public String[] getImplements()
      Returns an array of the different interface names implemented by the class that will represent the current XMLBindingComponent. Null is returned if no class binding is defined for the wrapped XML Schema structure.
      Specified by:
      getImplements in interface BindingComponent
      Returns:
      array of interface names
    • hasBoundProperties

      public boolean hasBoundProperties()
      Returns true if bound properties must be generated for the class that will represent the current XMLBindingComponent.
      Specified by:
      hasBoundProperties in interface BindingComponent
      Returns:
      true if bound properties must be generated for the class the class that will represent the current XMLBindingComponent.
    • hasEquals

      public boolean hasEquals()
      Returns true if equal method must be generated for the class that will represent the current XMLBindingComponent.
      Specified by:
      hasEquals in interface BindingComponent
      Returns:
      true if equal method must be generated for the class the class that will represent the current XMLBindingComponent.
    • isAbstract

      public boolean isAbstract()
      Returns true if the class that will represent the current XMLBindingComponent must be abstract.
      Specified by:
      isAbstract in interface BindingComponent
      Returns:
      true if the class that will represent the current XMLBindingComponent must be abstract.
    • isFinal

      public boolean isFinal()
      Returns true if the class that will represent the current XMLBindingComponent must be final.
      Specified by:
      isFinal in interface BindingComponent
      Returns:
      true if the class that will represent the current XMLBindingComponent must be final.
    • isFixed

      public boolean isFixed()
      Returns true if the wrapped XML Schema component is fixed (i.e the value used is fixed).
      Returns:
      true if the wrapped XML Schema component is fixed (i.e the value used is fixed).
    • isNillable

      public boolean isNillable()
      Returns true if the wrapped XML Schema component is nillable.
      Returns:
      true if the wrapped XML Schema component is nillable.
    • useWrapper

      public boolean useWrapper()
      Returns true if the member represented by that XMLBindingComponent is to be represented by an Object wrapper. For instance an int will be represented by a java Integer if the property is set to true.
      Specified by:
      useWrapper in interface BindingComponent
      Returns:
      true if the member represented by that XMLBindingComponent is to be represented by an Object wrapper.
    • getJavaType

      public XSType getJavaType()
      Returns the XSType that corresponds to the Java type chosen to represent the XML Schema component represented by this XMLBindingComponent. An XSType is an abstraction of a Java type used in the Source Generator. It wraps a JType as well as the necessary methods to convert to/from String.

      If a name of java type is specified then this name will have higher priority than the simpleType resolution.

      Specified by:
      getJavaType in interface BindingComponent
      Returns:
      an XSType
    • getCollectionType

      public String getCollectionType()
      Returns the collection name specified in the binding file. If no collection was specified, null will be returned and the default collection settings will be used.
      Specified by:
      getCollectionType in interface BindingComponent
      Returns:
      a string that represents the collection name specified in the binding file. If no collection was specified, null will be returned and the default collection settings will be used.
    • getValidator

      public String getValidator()
      Returns the fully qualified name of the Validator to use.
      Specified by:
      getValidator in interface BindingComponent
      Returns:
      the fully qualified name of the Validator to use.
    • getXMLFieldHandler

      public String getXMLFieldHandler()
      Returns the fully qualified name of the XMLFieldHandler to use.
      Specified by:
      getXMLFieldHandler in interface BindingComponent
      Returns:
      the fully qualified name of the XMLFieldHandler to use.
    • getVisiblity

      public String getVisiblity()
      Returns the visibility of the Java member to generate.
      Returns:
      the visibility of the Java member to generate.
    • getType

      public short getType()
      Returns the type of this component binding. A component binding can be of three different types:
      • Interface: it represents the binding to a java interface.
      • Class: it represents the binding to a java class.
      • Member: it represents the binding to a java class member.

      -1 is returned if the component binding is null.

      Specified by:
      getType in interface BindingComponent
      Returns:
      the type of this component binding.
    • getEnumBinding

      public EnumBindingType getEnumBinding()
      Returns the EnumBindingType instance for the active binding component.
      Specified by:
      getEnumBinding in interface BindingComponent
      Returns:
      The EnumBindingType instance
    • getContentMemberName

      public String getContentMemberName()
      Returns the name 'override' of a content member as specified in a binding file.
      Returns:
      the name of the name 'override' for the content member.