Class ElementDeclaration

java.lang.Object
org.eclipse.persistence.jaxb.compiler.ElementDeclaration

public class ElementDeclaration extends Object

An ElementDeclaration object is used to represent the information that is associated with a global element in XML.

ElementDeclarations will be created for classes with an XMLRootElement annotation, for TypeMappingInfo objects which have an xml tag name specified.

  • Constructor Details

    • ElementDeclaration

      public ElementDeclaration(QName name, JavaClass javaType, String javaTypeName, boolean isList)
      Create a new ElementDeclaration. By default the scope of this ElementDeclaration will be XmlElementDecl.GLOBAL
      Parameters:
      name - The QName of this element
      javaType - The JavaClass of this element
      javaTypeName - The String name of the javaType
      isList - A boolean representing if this corresponds to an xsd:list
    • ElementDeclaration

      public ElementDeclaration(QName name, JavaClass javaType, String javaTypeName, boolean isList, Class scopeClass)
      Create a new ElementDeclaration and set the scope.
      Parameters:
      name - The QName of this element
      javaType - The JavaClass of this element
      javaTypeName - The String name of the javaType
      isList - A boolean representing if this corresponds to an xsd:list
      scopeClass - The class representing the scope of this element
  • Method Details

    • getElementName

      public QName getElementName()
      Get the QName representing this element
      Returns:
      the QName associated with this element.
    • getJavaTypeName

      public String getJavaTypeName()
      Get the name of the java type associated with this global element. This may be set through the constructor or will be set when setJavaType(JavaClass) is called.
      Returns:
      the name of the java type that corresponds to this element
    • getSubstitutableElements

      public List<ElementDeclaration> getSubstitutableElements()
      The list of elements which can be substituted for this element (ie: has this element in their substitutionGroup)
      Returns:
      the list of element declarations which can be substituted for this element
    • addSubstitutableElement

      public void addSubstitutableElement(ElementDeclaration element)
      Add an element to the list of elements which can be substituted for this element (ie: has this element in their substitutionGroup)
    • setSubstitutionHead

      public void setSubstitutionHead(QName rootElement)
      If this element has a substitutionGroup this will be set.
      Parameters:
      rootElement - the QName value of the substitutionGroup
    • getSubstitutionHead

      public QName getSubstitutionHead()
      If this element has a substitutionGroup this will be set.
      Returns:
      the value of the substitutionGroup
    • isXmlRootElement

      public boolean isXmlRootElement()
      Track if this element had an @XmlRootElement annotation
      Returns:
      if the element has an @XmlRootElement
    • setIsXmlRootElement

      public void setIsXmlRootElement(boolean isXmlRoot)
      Mark if this element had an @XmlRootElement annotation
      Parameters:
      isXmlRoot - if the element has an @XmlRootElement
    • isNillable

      public boolean isNillable()
      Return if the global element will be marked as nillable
      Returns:
    • setNillable

      public void setNillable(boolean nillable)
      Set if the global element should be marked as nillable
      Parameters:
      nillable -
    • getJavaType

      public JavaClass getJavaType()
      The javaType associated with this element. Maybe set by the constructor or by setJavaType.
      Returns:
      the javaType associated with this element.
    • setJavaType

      public void setJavaType(JavaClass type)
      Set the javaType associated with this element. This will also set the java type name associated with this element to type.getQualifiedName()
      Parameters:
      type - the javaType associated with this element.
    • isList

      public boolean isList()
      Return if this element is a list
      Returns:
      isList true if the element is a list
    • setList

      public void setList(boolean isList)
      Mark if this element is a list
      Parameters:
      isList - true if the element is a list
    • getJavaTypeAdapterClass

      public Class getJavaTypeAdapterClass()
      Get the java type adapter class associated with the element
      Returns:
      the java type adapater class associated with this element. May return null.
    • setJavaTypeAdapterClass

      public void setJavaTypeAdapterClass(Class javaTypeAdapterClass)
      Set the java type adapter class associated with this element if applicable.
      Parameters:
      javaTypeAdapterClass - Class of the java type adapter associated with this element.
    • getAdaptedJavaType

      public JavaClass getAdaptedJavaType()
      Get the adapted java type. Only set when an XmlJavaTypeAdapter is present.
      Returns:
      the JavaClass of the adapted java type. May return null.
    • setAdaptedJavaType

      public void setAdaptedJavaType(JavaClass adaptedJavaType)
      Set the adapted java type if there is an XmlJavaTypeAdapter associated with this element This will also set the adaptedJavaTypeName (getAdaptedJavaTypeName)
      Parameters:
      adaptedJavaType - set the JavaClass representing the adapted Java type
    • getAdaptedJavaTypeName

      public String getAdaptedJavaTypeName()
      Get the adapted java type name. Only set when an XmlJavaTypeAdapter is present. Will be set to adaptedJavaType.getQualifiedName when setAdaptedJavaType is called
      Returns:
      the name of the class of the adapted java type. May return null.
    • getScopeClass

      public Class getScopeClass()
      Get the scope class associated with this element. By default the scope of this ElementDeclaration will be XmlElementDecl.GLOBAL
      Returns:
      the scope class associated with this element
    • setScopeClass

      public void setScopeClass(Class scopeClass)
      Set the scope class associated with this element. Default setting is XmlElementDecl.GLOBAL
      Parameters:
      scopeClass - associated with this element.
    • getDefaultValue

      public String getDefaultValue()
      This will be set if XmlElementDecl has a defaultValue specified
      Returns:
      the default value associated with this element. May return null.
    • setDefaultValue

      public void setDefaultValue(String value)
      Set the default value associated with this element.
      Parameters:
      value - the default value that corresponds to this element.
    • getTypeMappingInfo

      public TypeMappingInfo getTypeMappingInfo()
      Get the TypeMappingInfo object if this ElementDeclaration was created from a TypeMappingInfo
      Returns:
      the corresponding TypeMappingInfo. May return null.
    • setTypeMappingInfo

      public void setTypeMappingInfo(TypeMappingInfo info)
      Set the TypeMappingInfo object if this ElementDeclaration was created from a TypeMappingInfo
      Parameters:
      info - The TypeMappingInfo object used to create this ElementDeclaration
    • getXmlMimeType

      public String getXmlMimeType()
      Return the mimeType specified on this element.
      Returns:
      the mimeType specified on this element. May return null.
    • setXmlMimeType

      public void setXmlMimeType(String xmlMimeType)
      Set of this element has an XmlMimeType annotation
      Parameters:
      xmlMimeType - set the name of the mime type if specified for this element
    • isXmlAttachmentRef

      public boolean isXmlAttachmentRef()
      Return if this element is associated with an XmlAttachmentRef annotation
      Returns:
      if this element is associated with an XmlAttachmentRef annotation
    • setXmlAttachmentRef

      public void setXmlAttachmentRef(boolean xmlAttachmentRef)
      Set if there is an XmlAttachmentRef annotations associated with this element.
      Parameters:
      xmlAttachmentRef - true if there is an XmlAttachmentRef annotation