de.ispsoft.jaxme.generator
Class SchemaElement

java.lang.Object
  extended byde.ispsoft.jaxme.generator.SchemaAnnotationOwner
      extended byde.ispsoft.jaxme.generator.SchemaElement
Direct Known Subclasses:
SchemaAbstractSimpleElement, SchemaComplexElement

public abstract class SchemaElement
extends SchemaAnnotationOwner

Represents a single SchemaElement.

Author:
Jochen Wiedmann

Nested Class Summary
protected  class SchemaElement.ClassExtension
           
protected  class SchemaElement.ImplementedInterface
           
protected  class SchemaElement.PieceOfJavaSource
           
 
Constructor Summary
SchemaElement(SchemaAnnotationOwner pParent)
          Creates a new SchemaElement instance.
 
Method Summary
 void addClassExtension(java.lang.String pExtendedClassName, java.lang.String pExtendingClassName)
          Adds an item to the list of extension declarations.
 void addElementDecorator(ElementDecoratorFactory pFactory, ElementDecorator pElement)
          Adds an ElementDecorator to the list of registered decorators.
 void addImplementedInterface(java.lang.String pInterface, java.lang.String pClass)
          Adds an interface name to the list of interfaces implemented by the specified class.
 void addJavaSource(java.lang.String pSource, java.lang.String pClass)
          Adds a piece of Java source being included into the generated classes.
 void addOption(java.lang.Object pOption)
          Adds an option to the list of options configuring the element.
 void clearClassExtensions()
          Clears the list of class extension declarations.
 void clearImplementedInterfaces()
          Clears the list of interfaces implemented by the generated classes.
 void clearJavaSources()
          Clears the list of Java source pieces being included into the generated classes.
 void clearOptions()
          Clears the elements list of options.
protected  java.lang.String convertNameToJavaName(java.lang.String pName)
           
 java.lang.String getAddMethodName()
          If this element has accessor methods: Returns the name of the get method.
 java.lang.String getAssignmentFrom()
          Returns Java code that reads the fields value.
 java.lang.String getAssignmentTo(java.lang.String pValue)
          Returns Java code that assigns a value to this field.
 java.lang.String getClassExtension(java.lang.String pPackage, java.lang.String pClass)
          Returns a class extended by the given class or null, if no matching declaration was found.
 java.lang.String getClassName()
          Returns this elements class name.
 java.lang.String getClone(java.lang.String pValue)
          Returns Java code that creates a clone of this element.
 java.lang.String getDefaultFieldName()
          Returns this elements default field name.
 java.lang.String getDisplayName()
          Returns a human readable version of the element name.
 org.w3c.dom.Element getDOMNode()
          If this element was generated from an XML schema: The xs:element or xs:attribute node defining the element or attribute.
 ElementDecorator getElementDecorator(ElementDecoratorFactory pFactory)
          Returns an ElementDecorator registered for the given ElementDecoratorFactory.
 java.util.Iterator getElementDecorators()
          Returns an iterator to the list of registered ElementDecorator instances.
 SchemaElement getExtendedElement()
          Returns an element extended by the current element.
 java.lang.String getFieldName()
          Returns this elements field name.
abstract  java.lang.String getFieldType()
          Returns the Java type that this element has as a field in a parent element: If getMultiple() returns true, then the field type is java.util.List.
 java.lang.String getGetMethodName()
          If this element has accessor methods: Returns the name of the get method.
 java.lang.String[] getImplementedInterfaces(java.lang.String pPackage, java.lang.String pClass)
          Returns the array of interfaces implemented by the given class.
abstract  java.lang.String getInstanceType()
          Returns the Java type that this element would has or would have in the absence of a maxOccurs attribute.
 java.lang.String[] getJavaSources(java.lang.String pPackage, java.lang.String pClass)
          Returns Java source being included into the given class.
 java.lang.String getManagerClassName()
          Returns the manager class name.
 int getMaxOccurs()
          Returns the maximum number of occurrences.
 int getMinOccurs()
          Returns the minimum number of occurrences.
 java.lang.String getName()
          Returns the elements local name.
 java.lang.String getNamespace()
          Returns the elements namespace.
 java.lang.String getNamespacePrefix()
          Returns the elements preferred namespace prefix.
 java.util.Iterator getOptions()
          Returns an iterator to the elements options.
 SchemaAnnotationOwner getParent()
           
 java.lang.String getPrefix()
          Returns the prefix being used for default field names.
 java.lang.String getQClassName()
          Returns the fully qualified class name, including a package name.
 Schema getSchema()
          Returns the schema.
 SchemaType getSchemaType()
          Returns this elements SchemaType.
 java.lang.String getSetMethodName()
          If this element has accessor methods: Returns the name of the set method.
 boolean getSuppress()
          Returns whether this element should be suppressed.
 java.lang.String getSystemId()
          Returns the SchemaElements SystemId.
 boolean getTypeIsExplicit()
          Returns whether the elements type was explicitly specified.
abstract  boolean isAttribute()
          Returns whether the element is actually an attribute.
abstract  boolean isComplex()
          Returns whether the element is complex.
 boolean isMultiple()
          Returns whether this element or attribute can occur multiple times.
 void setAddMethodName(java.lang.String pAddMethodName)
          Sets the name of the add method.
 void setClassName(java.lang.String pClassName)
          Sets this elements class name.
 void setDOMNode(org.w3c.dom.Element pNode)
          If this element was generated from an XML schema: Sets the xs:element or xs:attribute node defining the element or attribute.
 void setExtendedElement(SchemaElement pExtendedElement)
          Sets an element extended by the current element.
 void setFieldName(java.lang.String pFieldName)
          Sets this elements field name.
 void setGetMethodName(java.lang.String pGetMethodName)
          Sets the name of the get method.
 void setManagerClassName(java.lang.String pManagerClassName)
          Sets the manager class name.
 void setMaxOccurs(int pMaxOccurs)
          Sets the maximum number of occurrences; -1 for unbounded.
 void setMinOccurs(int pMinOccurs)
          Sets the minimum number of occurrences.
 void setName(java.lang.String pName)
          Sets the elements local name.
 void setNamespace(java.lang.String pNamespace)
          Sets the elements namespace.
 void setNamespacePrefix(java.lang.String pPrefix)
          Sets the elements preferred namespace prefix.
 void setPrefix(java.lang.String pPrefix)
          Sets the prefix being used for default field names.
 void setSchemaType(SchemaType pSchemaType)
          Sets this elements SchemaType.
 void setSetMethodName(java.lang.String pSetMethodName)
          Sets the name of the set method.
 void setSuppress(boolean pSuppress)
          Sets whether this element should be suppressed.
 void setSystemId(java.lang.String pSystemId)
          Sets the SchemaElements SystemId.
 void setTypeIsExplicit(boolean pTypeIsExplicit)
          Sets whether the elements type was explicitly specified.
 
Methods inherited from class de.ispsoft.jaxme.generator.SchemaAnnotationOwner
getAccessors, getDocumentation, getExtendsClassName, getPackageName, setAccessors, setDocumentation, setExtendsClassName, setPackageName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaElement

public SchemaElement(SchemaAnnotationOwner pParent)
Creates a new SchemaElement instance.

Method Detail

getParent

public SchemaAnnotationOwner getParent()

getSchema

public Schema getSchema()
Description copied from class: SchemaAnnotationOwner

Returns the schema.

Specified by:
getSchema in class SchemaAnnotationOwner

isComplex

public abstract boolean isComplex()

Returns whether the element is complex.


isAttribute

public abstract boolean isAttribute()

Returns whether the element is actually an attribute.


setNamespace

public void setNamespace(java.lang.String pNamespace)

Sets the elements namespace.


getNamespace

public java.lang.String getNamespace()

Returns the elements namespace.

Returns:
The namespace URI or the empty string.

setName

public void setName(java.lang.String pName)

Sets the elements local name.


getName

public java.lang.String getName()

Returns the elements local name.


setSchemaType

public void setSchemaType(SchemaType pSchemaType)

Sets this elements SchemaType.


getSchemaType

public SchemaType getSchemaType()

Returns this elements SchemaType.


setFieldName

public void setFieldName(java.lang.String pFieldName)

Sets this elements field name.


getDefaultFieldName

public java.lang.String getDefaultFieldName()

Returns this elements default field name.


getFieldName

public java.lang.String getFieldName()

Returns this elements field name.


setClassName

public void setClassName(java.lang.String pClassName)

Sets this elements class name.


getClassName

public java.lang.String getClassName()

Returns this elements class name.


getQClassName

public java.lang.String getQClassName()

Returns the fully qualified class name, including a package name.


setSuppress

public void setSuppress(boolean pSuppress)

Sets whether this element should be suppressed.


getSuppress

public boolean getSuppress()

Returns whether this element should be suppressed.


convertNameToJavaName

protected java.lang.String convertNameToJavaName(java.lang.String pName)

setMinOccurs

public void setMinOccurs(int pMinOccurs)

Sets the minimum number of occurrences.


getMinOccurs

public int getMinOccurs()

Returns the minimum number of occurrences.


setMaxOccurs

public void setMaxOccurs(int pMaxOccurs)

Sets the maximum number of occurrences; -1 for unbounded.


getMaxOccurs

public int getMaxOccurs()

Returns the maximum number of occurrences.


isMultiple

public boolean isMultiple()

Returns whether this element or attribute can occur multiple times. Same as

   getMaxOccurs() > 1  ||  getMaxOccurs() == -1
 


setSystemId

public void setSystemId(java.lang.String pSystemId)

Sets the SchemaElements SystemId.


getSystemId

public java.lang.String getSystemId()

Returns the SchemaElements SystemId.


getDisplayName

public java.lang.String getDisplayName()

Returns a human readable version of the element name.


setPrefix

public void setPrefix(java.lang.String pPrefix)

Sets the prefix being used for default field names.

See Also:
getFieldName()

getPrefix

public java.lang.String getPrefix()

Returns the prefix being used for default field names.

See Also:
getFieldName()

setGetMethodName

public void setGetMethodName(java.lang.String pGetMethodName)

Sets the name of the get method. Used only if getAccessor() returns true.


getGetMethodName

public java.lang.String getGetMethodName()

If this element has accessor methods: Returns the name of the get method.


setSetMethodName

public void setSetMethodName(java.lang.String pSetMethodName)

Sets the name of the set method. Used only if getAccessor() returns true.


getSetMethodName

public java.lang.String getSetMethodName()

If this element has accessor methods: Returns the name of the set method.


setAddMethodName

public void setAddMethodName(java.lang.String pAddMethodName)

Sets the name of the add method. Used only if getAccessor() returns true.


getAddMethodName

public java.lang.String getAddMethodName()

If this element has accessor methods: Returns the name of the get method.


getAssignmentTo

public java.lang.String getAssignmentTo(java.lang.String pValue)

Returns Java code that assigns a value to this field.


getAssignmentFrom

public java.lang.String getAssignmentFrom()

Returns Java code that reads the fields value.


getFieldType

public abstract java.lang.String getFieldType()

Returns the Java type that this element has as a field in a parent element:

  1. If getMultiple() returns true, then the field type is java.util.List.
  2. Otherwise, if isComplex() is true, the field type is getClassName().
  3. Otherwise the field type is pChild.getSchemaType().getRuntimeType().getName().


getInstanceType

public abstract java.lang.String getInstanceType()

Returns the Java type that this element would has or would have in the absence of a maxOccurs attribute.

  1. Otherwise, if isComplex() is true, the field type is getClassName().
  2. Otherwise the field type is pChild.getSchemaType().getRuntimeType().getName().


getClone

public java.lang.String getClone(java.lang.String pValue)

Returns Java code that creates a clone of this element.


addOption

public void addOption(java.lang.Object pOption)

Adds an option to the list of options configuring the element.


clearOptions

public void clearOptions()

Clears the elements list of options.


getOptions

public java.util.Iterator getOptions()

Returns an iterator to the elements options.


setManagerClassName

public void setManagerClassName(java.lang.String pManagerClassName)

Sets the manager class name.


getManagerClassName

public java.lang.String getManagerClassName()

Returns the manager class name.


getExtendedElement

public SchemaElement getExtendedElement()

Returns an element extended by the current element. It is a JaxMe design flaw, that the XML schema standard doesn't define extension of elements, but extension of types.


setExtendedElement

public void setExtendedElement(SchemaElement pExtendedElement)

Sets an element extended by the current element. It is a JaxMe design flaw, that the XML schema standard doesn't define extension of elements, but extension of types.


getTypeIsExplicit

public boolean getTypeIsExplicit()

Returns whether the elements type was explicitly specified.


setTypeIsExplicit

public void setTypeIsExplicit(boolean pTypeIsExplicit)

Sets whether the elements type was explicitly specified.


addJavaSource

public void addJavaSource(java.lang.String pSource,
                          java.lang.String pClass)

Adds a piece of Java source being included into the generated classes.


clearJavaSources

public void clearJavaSources()

Clears the list of Java source pieces being included into the generated classes.


getJavaSources

public java.lang.String[] getJavaSources(java.lang.String pPackage,
                                         java.lang.String pClass)

Returns Java source being included into the given class.


addImplementedInterface

public void addImplementedInterface(java.lang.String pInterface,
                                    java.lang.String pClass)

Adds an interface name to the list of interfaces implemented by the specified class.


clearImplementedInterfaces

public void clearImplementedInterfaces()

Clears the list of interfaces implemented by the generated classes.


getImplementedInterfaces

public java.lang.String[] getImplementedInterfaces(java.lang.String pPackage,
                                                   java.lang.String pClass)

Returns the array of interfaces implemented by the given class.


addClassExtension

public void addClassExtension(java.lang.String pExtendedClassName,
                              java.lang.String pExtendingClassName)

Adds an item to the list of extension declarations.

Parameters:
pExtendedClassName - Name of the class being extended
pExtendingClassName - Name of the extending class

clearClassExtensions

public void clearClassExtensions()

Clears the list of class extension declarations.


getClassExtension

public java.lang.String getClassExtension(java.lang.String pPackage,
                                          java.lang.String pClass)

Returns a class extended by the given class or null, if no matching declaration was found.


addElementDecorator

public void addElementDecorator(ElementDecoratorFactory pFactory,
                                ElementDecorator pElement)

Adds an ElementDecorator to the list of registered decorators. If another decorator is already registered for the same factory, is is removed and the new decorator is registered instead.

Parameters:
pFactory - The ElementDecoratorFactory that created the decorator.
pElement - The ElementDecorator being registered. May be null to remove a previously registered decorator.

getElementDecorator

public ElementDecorator getElementDecorator(ElementDecoratorFactory pFactory)

Returns an ElementDecorator registered for the given ElementDecoratorFactory.

Parameters:
pFactory - The ElementDecoratorFactory that was used as the first argument in a previous call to addElementDecorator to register a decorator.
Returns:
An ElementDecorator or null, if no decorator was registered for the given factory.

getElementDecorators

public java.util.Iterator getElementDecorators()

Returns an iterator to the list of registered ElementDecorator instances.


setNamespacePrefix

public void setNamespacePrefix(java.lang.String pPrefix)

Sets the elements preferred namespace prefix.


getNamespacePrefix

public java.lang.String getNamespacePrefix()

Returns the elements preferred namespace prefix.


getDOMNode

public org.w3c.dom.Element getDOMNode()

If this element was generated from an XML schema: The xs:element or xs:attribute node defining the element or attribute.


setDOMNode

public void setDOMNode(org.w3c.dom.Element pNode)

If this element was generated from an XML schema: Sets the xs:element or xs:attribute node defining the element or attribute.