org.jibx.binding.model
Class ContainerElementBase

java.lang.Object
  extended by org.jibx.binding.model.ElementBase
      extended by org.jibx.binding.model.NestingElementBase
          extended by org.jibx.binding.model.ContainerElementBase
Direct Known Subclasses:
StructureElementBase, TemplateElementBase

public abstract class ContainerElementBase
extends NestingElementBase

Model component for elements that can contain detailed binding information in the form of nested child components. Elements of this type include mapping, template, structure, and collection elements.

Author:
Dennis M. Sosnoski

Field Summary
private  java.util.ArrayList m_attributeComponents
          Child components defining attributes (created during validation, contains subset of child components defining attributes).
private  java.util.ArrayList m_contentComponents
          Child components defining content (created during validation, contains subset of child components defining element or character data content).
private  IComponent m_idChild
          Child component that contributes an ID (null if none).
private  boolean m_inClassify
          Flag for child classification in progress.
private  java.lang.String m_label
          Label for this structure definition.
private  ObjectAttributes m_objectAttrs
          Object attributes information for nesting.
private  StructureAttributes m_structureAttrs
          Structure attributes information for nesting.
private  java.lang.String m_using
          Label for structure to be used as definition.
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
protected ContainerElementBase(int type)
          Constructor.
 
Method Summary
protected  void checkCompatibleChildren(ValidationContext vctx, IClass type, java.util.ArrayList children)
          Check that child components are of types compatible with the container object type.
protected  void classifyComponents(ValidationContext vctx)
          Classify child components as contributing attributes, content, or both.
 java.util.ArrayList getAttributeComponents()
          Get list of child components contributing attribute items to this container element.
 IClass getChildObjectType()
          Get class passed to child components.
 java.util.ArrayList getContentComponents()
          Get list of child components contributing content items to this container element.
 IClass getCreateClass()
          Get new instance creation class information.
 java.lang.String getCreateType()
          Get type to be used for creating new instance.
 IClassItem getFactory()
          Get factory method information.
 java.lang.String getFactoryName()
          Get factory method name.
 IComponent getId()
          Get ID property child.
 java.lang.String getLabel()
          Get label for this definition.
 IClass getMarshaller()
          Get marshaller class information.
 java.lang.String getMarshallerName()
          Get marshaller class name.
abstract  IClass getObjectType()
          Get class linked to binding element.
 IClassItem getPostset()
          Get post-set method information.
 java.lang.String getPostsetName()
          Get post-set method name.
 IClassItem getPreget()
          Get pre-get method information.
 java.lang.String getPregetName()
          Get pre-get method name.
 IClassItem getPreset()
          Get pre-set method information.
 java.lang.String getPresetName()
          Get pre-set method name.
 IClass getUnmarshaller()
          Get unmarshaller class information.
 java.lang.String getUnmarshallerName()
          Get unmarshaller class name.
 java.lang.String getUsing()
          Get label for definition to be used.
abstract  boolean hasObject()
          Check if this container defines a context object.
 boolean isAllowRepeats()
          Check if repeated child elements are allowed.
 boolean isChoice()
          Check if child components are a choice.
protected  boolean isClassified()
          Check for child components classified.
 boolean isFlexible()
          Get flexible flag.
 boolean isNillable()
          Check if nillable object.
 boolean isOrdered()
          Check if child components are ordered.
 void prevalidate(ValidationContext vctx)
          Prevalidate element information.
 void setAllowRepeats(boolean ignore)
          Set repeated child elements allowed flag.
 void setChoice(boolean choice)
          Set child components choice flag.
protected  void setComponents(java.util.ArrayList attribs, java.util.ArrayList contents)
          Set child attribute and content components directly.
 void setCreateType(java.lang.String name)
          Set new instance type class name.
 void setFactoryName(java.lang.String name)
          Set factory method name.
 void setFlexible(boolean flexible)
          Set flexible flag.
 void setIdChild(IComponent child, ValidationContext vctx)
          Set ID property child.
 void setLabel(java.lang.String label)
          Set label for this definition.
 void setMarshallerName(java.lang.String name)
          Set marshaller class name.
 void setNillable(boolean nillable)
          Set nillable flag.
 void setOrdered(boolean ordered)
          Set child components ordered flag.
 void setPostsetName(java.lang.String name)
          Set post-set method name.
 void setPreget(java.lang.String name)
          Set pre-get method name.
 void setPresetName(java.lang.String name)
          Set pre-set method name.
 void setUnmarshallerName(java.lang.String name)
          Set unmarshaller class name.
 void setUsing(java.lang.String label)
          Set label for definition to be used.
 void validate(ValidationContext vctx)
          Validate element information.
protected  void verifyConstruction(ValidationContext vctx, IClass type)
          Check that there's a way to construct an instance of an object class for input bindings.
 
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_objectAttrs

private ObjectAttributes m_objectAttrs
Object attributes information for nesting.


m_structureAttrs

private StructureAttributes m_structureAttrs
Structure attributes information for nesting.


m_label

private java.lang.String m_label
Label for this structure definition.


m_using

private java.lang.String m_using
Label for structure to be used as definition.


m_idChild

private IComponent m_idChild
Child component that contributes an ID (null if none).


m_inClassify

private boolean m_inClassify
Flag for child classification in progress.


m_contentComponents

private java.util.ArrayList m_contentComponents
Child components defining content (created during validation, contains subset of child components defining element or character data content).


m_attributeComponents

private java.util.ArrayList m_attributeComponents
Child components defining attributes (created during validation, contains subset of child components defining attributes).

Constructor Detail

ContainerElementBase

protected ContainerElementBase(int type)
Constructor.

Parameters:
type - element type code
Method Detail

getLabel

public java.lang.String getLabel()
Get label for this definition.

Returns:
label for this definition

setLabel

public void setLabel(java.lang.String label)
Set label for this definition.

Parameters:
label - label for this definition

getUsing

public java.lang.String getUsing()
Get label for definition to be used.

Returns:
label for definition to be used

setUsing

public void setUsing(java.lang.String label)
Set label for definition to be used.

Parameters:
label - label for definition to be used

getContentComponents

public java.util.ArrayList getContentComponents()
Get list of child components contributing content items to this container element. This call is only meaningful after validation.

Returns:
list of child binding components defining content items

getAttributeComponents

public java.util.ArrayList getAttributeComponents()
Get list of child components contributing attribute items to this container element. This call is only meaningful after validation.

Returns:
list of child binding components defining attribute items

hasObject

public abstract boolean hasObject()
Check if this container defines a context object.

Returns:
true if defines context object, false if not

getObjectType

public abstract IClass getObjectType()
Get class linked to binding element. This call is only meaningful after validation.

Returns:
information for class linked by binding

getChildObjectType

public IClass getChildObjectType()
Get class passed to child components. This call is only meaningful after validation.

Returns:
information for class linked by binding

setIdChild

public final void setIdChild(IComponent child,
                             ValidationContext vctx)
Set ID property child. Used to set the ID property associated with a particular class instance. There can only be at most one child ID property for each actual object instance.

Parameters:
child - child defining the ID property
vctx - validation context

getId

public IComponent getId()
Get ID property child.

Returns:
ID child

getFactoryName

public java.lang.String getFactoryName()
Get factory method name.

Returns:
fully-qualified factory class and method name (or null if none)

getFactory

public IClassItem getFactory()
Get factory method information. This call is only meaningful after a call to prevalidate(ValidationContext).

Returns:
factory method information (or null if none)

setFactoryName

public void setFactoryName(java.lang.String name)
Set factory method name.

Parameters:
name - fully qualified class and method name for object factory

getPresetName

public java.lang.String getPresetName()
Get pre-set method name.

Returns:
pre-set method name (or null if none)

getPreset

public IClassItem getPreset()
Get pre-set method information. This call is only meaningful after a call to prevalidate(ValidationContext).

Returns:
pre-set method information (or null if none)

setPresetName

public void setPresetName(java.lang.String name)
Set pre-set method name.

Parameters:
name - member method name to be called before unmarshalling

getPostsetName

public java.lang.String getPostsetName()
Get post-set method name.

Returns:
post-set method name (or null if none)

getPostset

public IClassItem getPostset()
Get post-set method information. This call is only meaningful after a call to prevalidate(ValidationContext).

Returns:
post-set method information (or null if none)

setPostsetName

public void setPostsetName(java.lang.String name)
Set post-set method name.

Parameters:
name - member method name to be called after unmarshalling

getPregetName

public java.lang.String getPregetName()
Get pre-get method name.

Returns:
pre-get method name (or null if none)

getPreget

public IClassItem getPreget()
Get pre-get method information. This call is only meaningful after a call to prevalidate(ValidationContext).

Returns:
pre-get method information (or null if none)

setPreget

public void setPreget(java.lang.String name)
Set pre-get method name.

Parameters:
name - member method name to be called before marshalling

getMarshallerName

public java.lang.String getMarshallerName()
Get marshaller class name.

Returns:
marshaller class name (or null if none)

getMarshaller

public IClass getMarshaller()
Get marshaller class information. This call is only meaningful after a call to prevalidate(ValidationContext).

Returns:
class information for marshaller (or null if none)

setMarshallerName

public void setMarshallerName(java.lang.String name)
Set marshaller class name.

Parameters:
name - class name to be used for marshalling

getUnmarshallerName

public java.lang.String getUnmarshallerName()
Get unmarshaller class name.

Returns:
unmarshaller class name (or null if none)

getUnmarshaller

public IClass getUnmarshaller()
Get unmarshaller class information. This call is only meaningful after a call to prevalidate(ValidationContext).

Returns:
class information for unmarshaller (or null if none)

setUnmarshallerName

public void setUnmarshallerName(java.lang.String name)
Set unmarshaller class name.

Parameters:
name - class name to be used for unmarshalling

isNillable

public boolean isNillable()
Check if nillable object.

Returns:
nillable flag

setNillable

public void setNillable(boolean nillable)
Set nillable flag.

Parameters:
nillable - flag

getCreateType

public java.lang.String getCreateType()
Get type to be used for creating new instance.

Returns:
class name for type to be created (or null if none)

getCreateClass

public IClass getCreateClass()
Get new instance creation class information. This method is only usable a call to prevalidate(ValidationContext).

Returns:
class information for type to be created (or null if none)

setCreateType

public void setCreateType(java.lang.String name)
Set new instance type class name.

Parameters:
name - class name to be used for creating new instance

isFlexible

public boolean isFlexible()
Get flexible flag.

Returns:
flexible flag

setFlexible

public void setFlexible(boolean flexible)
Set flexible flag.

Parameters:
flexible -

isOrdered

public boolean isOrdered()
Check if child components are ordered.

Returns:
true if ordered, false if not

setOrdered

public void setOrdered(boolean ordered)
Set child components ordered flag.

Parameters:
ordered - true if ordered, false if not

isChoice

public boolean isChoice()
Check if child components are a choice.

Returns:
true if choice, false if not

setChoice

public void setChoice(boolean choice)
Set child components choice flag.

Parameters:
choice - true if choice, false if not

isAllowRepeats

public boolean isAllowRepeats()
Check if repeated child elements are allowed.

Returns:
true if repeats allowed, false if not

setAllowRepeats

public void setAllowRepeats(boolean ignore)
Set repeated child elements allowed flag.

Parameters:
ignore - true if repeated child elements to be allowed, false if not

verifyConstruction

protected void verifyConstruction(ValidationContext vctx,
                                  IClass type)
Check that there's a way to construct an instance of an object class for input bindings. This can be a factory method, an unmarshaller, a no-argument constructor already defined in the class, or a modifiable class with constructor generation enabled. If a create-type is specified, this is used in place of the declared type. The call always succeeds if the binding is output-only. Note that this method should not be changed to pass the "this" object when reporting errors, because it may be called indirectly during the validation of other elements. Because of this, it needs to only use values defined after prevalidate(ValidationContext).

Parameters:
vctx - validation context
type - constructed object type

checkCompatibleChildren

protected void checkCompatibleChildren(ValidationContext vctx,
                                       IClass type,
                                       java.util.ArrayList children)
Check that child components are of types compatible with the container object type. This method may call itself recursively to process the children of child components which do not themselves set a type. It's not used directly, but is here for use by subclasses.

Parameters:
vctx - validation context
type - structure object type
children - list of child components to be checked

isClassified

protected boolean isClassified()
Check for child components classified. This is a convenience method for subclasses to check if classification has already been done.

Returns:
true if classified, false if not

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.

Parameters:
vctx -

setComponents

protected void setComponents(java.util.ArrayList attribs,
                             java.util.ArrayList contents)
Set child attribute and content components directly. This is provided for use by subclasses requiring special handling, in particular the <structure> element used as a mapping reference.

Parameters:
attribs -
contents -

prevalidate

public void prevalidate(ValidationContext vctx)
Description copied from class: ElementBase
Prevalidate element information. The prevalidation step is used to check isolated aspects of an element, such as the settings for enumerated values on the element and attributes. This empty base class implementation should be overridden by each subclass that requires prevalidation handling.

Overrides:
prevalidate in class NestingElementBase
Parameters:
vctx - validation context

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 NestingElementBase
Parameters:
vctx - validation context


Project Web Site