org.jibx.binding.model
Class StructureElement

java.lang.Object
  extended by org.jibx.binding.model.ElementBase
      extended by org.jibx.binding.model.NestingElementBase
          extended by org.jibx.binding.model.ContainerElementBase
              extended by org.jibx.binding.model.StructureElementBase
                  extended by org.jibx.binding.model.StructureElement
All Implemented Interfaces:
IComponent

public class StructureElement
extends StructureElementBase

Model component for structure element of binding definition.

Author:
Dennis M. Sosnoski

Field Summary
private  TemplateElementBase m_effectiveMapping
          Binding to use for this object.
private  boolean m_hasMappingName
          Flag for structure has a concrete mapping, possibly indeterminant.
private  java.lang.String m_mapAsName
          Mapping type name to use for this object.
private  QName m_mapAsQName
          Mapping qualified type name to use for this object.
static StringArray s_allowedAttributes
          Enumeration of allowed attribute names
 
Fields inherited from class org.jibx.binding.model.ElementBase
BINDING_ELEMENT, COLLECTION_ELEMENT, ELEMENT_NAMES, FORMAT_ELEMENT, INCLUDE_ELEMENT, INPUT_ELEMENT, MAPPING_ELEMENT, NAMESPACE_ELEMENT, OUTPUT_ELEMENT, SPLIT_ELEMENT, STRUCTURE_ELEMENT, TEMPLATE_ELEMENT, VALUE_ELEMENT
 
Constructor Summary
StructureElement()
          Default constructor.
 
Method Summary
private  void checkNamespaceUsage(TemplateElementBase base, ValidationContext vctx)
          Check for conflicts on namespace prefix usage.
protected  void classifyComponents(ValidationContext vctx)
          Classify child components as contributing attributes, content, or both.
 TemplateElementBase getEffectiveMapping()
          Get actual type mapping.
 java.lang.String getMapAsName()
          Get name of mapping type.
 QName getMapAsQName()
          Get qualified name of mapping type.
 java.lang.String getName()
          Get name.
private  java.lang.String getQualifiedMapAs(IMarshallingContext ictx)
          JiBX access method to get mapping type name as qualified name.
 IClass getType()
          Get value type information.
 java.lang.String getUri()
          Get specified namespace URI.
 boolean hasAttribute()
          Check if component defines one or more attribute values of the containing element.
 boolean hasContent()
          Check if component defines one or more elements or text values as children of the containing element.
 boolean hasDirectName()
          Check if this structure defines a name directly.
 boolean hasName()
          Check if component has a name.
private  void mergeNamespaces(DefinitionContext defc, DefinitionContext addc, ValidationContext vctx)
          Merge namespaces from an implicit context to those defined for a reference.
private  void preSet(IUnmarshallingContext uctx)
          Make sure all attributes are defined.
 void setMapAsName(java.lang.String name)
          Set name of mapping type.
 void setMapAsQName(QName name)
          Set qualified name of mapping type.
private  void setMappingReference(ValidationContext vctx, DefinitionContext dctx, IClass type)
          Validate mapping reference.
private  void setQualifiedMapAs(java.lang.String text, IUnmarshallingContext ictx)
          JiBX access method to set mapping type name as qualified name.
 void validate(ValidationContext vctx)
          Validate element information.
 
Methods inherited from class org.jibx.binding.model.StructureElementBase
getDeclaredType, getField, getFieldName, getFlag, getGet, getGetName, getGetType, getNamespace, getObjectType, getPrefix, getSet, getSetName, getSetType, getTest, getTestName, getUsage, getUsageName, hasObject, hasProperty, isFlagOnly, isImplicit, isOptional, prevalidate, setDeclaredType, setFieldName, setFlagName, setGetName, setName, setPrefix, setSetName, setTestName, setUri, setUsage, setUsageName
 
Methods inherited from class org.jibx.binding.model.ContainerElementBase
checkCompatibleChildren, getAttributeComponents, getChildObjectType, getContentComponents, getCreateClass, getCreateType, getFactory, getFactoryName, getId, getLabel, getMarshaller, getMarshallerName, getPostset, getPostsetName, getPreget, getPregetName, getPreset, getPresetName, getUnmarshaller, getUnmarshallerName, getUsing, isAllowRepeats, isChoice, isClassified, isFlexible, isNillable, isOrdered, setAllowRepeats, setChoice, setComponents, setCreateType, setFactoryName, setFlexible, setIdChild, setLabel, setMarshallerName, setNillable, setOrdered, setPostsetName, setPreget, setPresetName, setUnmarshallerName, setUsing, verifyConstruction
 
Methods inherited from class org.jibx.binding.model.NestingElementBase
addChild, childIterator, children, getDefaultStyle, getDefinitions, getStyle, getStyleName, setDefinitions, setStyleName
 
Methods inherited from class org.jibx.binding.model.ElementBase
getComment, name, setComment, toString, type, validateAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

s_allowedAttributes

public static final StringArray s_allowedAttributes
Enumeration of allowed attribute names


m_mapAsName

private java.lang.String m_mapAsName
Mapping type name to use for this object.


m_mapAsQName

private QName m_mapAsQName
Mapping qualified type name to use for this object.


m_hasMappingName

private boolean m_hasMappingName
Flag for structure has a concrete mapping, possibly indeterminant.


m_effectiveMapping

private TemplateElementBase m_effectiveMapping
Binding to use for this object.

Constructor Detail

StructureElement

public StructureElement()
Default constructor.

Method Detail

getMapAsName

public java.lang.String getMapAsName()
Get name of mapping type.

Returns:
mapping type name (or null if none)

setMapAsName

public void setMapAsName(java.lang.String name)
Set name of mapping type. This method changes the qualified name to match the mapping type.

Parameters:
name - mapping type name (or null if none)

getMapAsQName

public QName getMapAsQName()
Get qualified name of mapping type.

Returns:
mapping qualified type name (or null if none)

setMapAsQName

public void setMapAsQName(QName name)
Set qualified name of mapping type. This method changes the mapping name to match the qualified name.

Parameters:
name - mapping qualified type name (or null if none)

getEffectiveMapping

public TemplateElementBase getEffectiveMapping()
Get actual type mapping. This call is only meaningful after validation.

Returns:
actual type mapping (or null if none)

hasDirectName

public boolean hasDirectName()
Check if this structure defines a name directly.

Returns:
true if name defined, false if not

hasName

public boolean hasName()
Description copied from interface: IComponent
Check if component has a name.

Specified by:
hasName in interface IComponent
Overrides:
hasName in class StructureElementBase
Returns:
true if component has a name, false if not

getName

public java.lang.String getName()
Description copied from class: StructureElementBase
Get name.

Specified by:
getName in interface IComponent
Overrides:
getName in class StructureElementBase
Returns:
name text

getUri

public java.lang.String getUri()
Description copied from class: StructureElementBase
Get specified namespace URI.

Specified by:
getUri in interface IComponent
Overrides:
getUri in class StructureElementBase
Returns:
namespace URI (null if not set)

hasAttribute

public boolean hasAttribute()
Description copied from interface: IComponent
Check if component defines one or more attribute values of the containing element. This method is only valid after validation.

Specified by:
hasAttribute in interface IComponent
Overrides:
hasAttribute in class StructureElementBase
Returns:
true if one or more attribute values defined for containing element, false if not

hasContent

public boolean hasContent()
Description copied from interface: IComponent
Check if component defines one or more elements or text values as children of the containing element. This method is only valid after validation.

Specified by:
hasContent in interface IComponent
Overrides:
hasContent in class StructureElementBase
Returns:
true if one or more content values defined for containing element, false if not

getType

public IClass getType()
Description copied from interface: IComponent
Get value type information. This call is only meaningful after prevalidation.

Specified by:
getType in interface IComponent
Overrides:
getType in class StructureElementBase
Returns:
type information

setQualifiedMapAs

private void setQualifiedMapAs(java.lang.String text,
                               IUnmarshallingContext ictx)
                        throws JiBXException
JiBX access method to set mapping type name as qualified name.

Parameters:
text - mapping name text (null if none)
ictx - unmarshalling context
Throws:
JiBXException - on deserialization error

getQualifiedMapAs

private java.lang.String getQualifiedMapAs(IMarshallingContext ictx)
                                    throws JiBXException
JiBX access method to get mapping type name as qualified name.

Parameters:
ictx - marshalling context
Returns:
mapping type name text (null if none)
Throws:
JiBXException - on deserialization error

preSet

private void preSet(IUnmarshallingContext uctx)
             throws JiBXException
Make sure all attributes are defined.

Parameters:
uctx - unmarshalling context
Throws:
JiBXException - on unmarshalling error

mergeNamespaces

private void mergeNamespaces(DefinitionContext defc,
                             DefinitionContext addc,
                             ValidationContext vctx)
Merge namespaces from an implicit context to those defined for a reference.

Parameters:
defc - context supplying namespaces to be merged
addc - context to be merged into
vctx -

checkNamespaceUsage

private void checkNamespaceUsage(TemplateElementBase base,
                                 ValidationContext vctx)
Check for conflicts on namespace prefix usage. Abstract mappings may define namespaces, but the prefixes used by the abstract mappings must not conflict with those used at the point of reference. This allows the namespace definitions from the abstract mapping to be promoted to the containing element.

Parameters:
base -
vctx -

classifyComponents

protected void classifyComponents(ValidationContext vctx)
Classify child components as contributing attributes, content, or both. This method is needed to handle on-demand classification during validation. When a child component is another instance of this class, the method calls itself on the child component prior to checking the child component's contribution.

Overrides:
classifyComponents in class ContainerElementBase
Parameters:
vctx -

validate

public void validate(ValidationContext vctx)
Description copied from class: ElementBase
Validate element information. The validation step is used for checking the interactions between elements, such as name references to other elements. The ElementBase.prevalidate(org.jibx.binding.model.ValidationContext) method will always be called for every element in the binding definition before this method is called for any element. This empty base class implementation should be overridden by each subclass that requires validation handling.

Overrides:
validate in class StructureElementBase
Parameters:
vctx - validation context

setMappingReference

private void setMappingReference(ValidationContext vctx,
                                 DefinitionContext dctx,
                                 IClass type)
Validate mapping reference.

Parameters:
vctx - validation context
dctx - definition context
type - referenced type


Project Web Site