Package org.jibx.binding.model
Class ContainerElementBase
- java.lang.Object
-
- org.jibx.binding.model.ElementBase
-
- org.jibx.binding.model.NestingElementBase
-
- 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
Fields Modifier and Type Field Description private java.util.ArrayListm_attributeComponentsChild components defining attributes (created during validation, contains subset of child components defining attributes).private java.util.ArrayListm_contentComponentsChild components defining content (created during validation, contains subset of child components defining element or character data content).private IComponentm_idChildChild component that contributes an ID (nullif none).private booleanm_inClassifyFlag for child classification in progress.private java.lang.Stringm_labelLabel for this structure definition.private ObjectAttributesm_objectAttrsObject attributes information for nesting.private StructureAttributesm_structureAttrsStructure attributes information for nesting.private java.lang.Stringm_usingLabel for structure to be used as definition.static StringArrays_allowedAttributesEnumeration 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
Constructors Modifier Constructor Description protectedContainerElementBase(int type)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckCompatibleChildren(ValidationContext vctx, IClass type, java.util.ArrayList children)Check that child components are of types compatible with the container object type.protected voidclassifyComponents(ValidationContext vctx)Classify child components as contributing attributes, content, or both.java.util.ArrayListgetAttributeComponents()Get list of child components contributing attribute items to this container element.IClassgetChildObjectType()Get class passed to child components.java.util.ArrayListgetContentComponents()Get list of child components contributing content items to this container element.IClassgetCreateClass()Get new instance creation class information.java.lang.StringgetCreateType()Get type to be used for creating new instance.IClassItemgetFactory()Get factory method information.java.lang.StringgetFactoryName()Get factory method name.IComponentgetId()Get ID property child.java.lang.StringgetLabel()Get label for this definition.IClassgetMarshaller()Get marshaller class information.java.lang.StringgetMarshallerName()Get marshaller class name.abstract IClassgetObjectType()Get class linked to binding element.IClassItemgetPostset()Get post-set method information.java.lang.StringgetPostsetName()Get post-set method name.IClassItemgetPreget()Get pre-get method information.java.lang.StringgetPregetName()Get pre-get method name.IClassItemgetPreset()Get pre-set method information.java.lang.StringgetPresetName()Get pre-set method name.IClassgetUnmarshaller()Get unmarshaller class information.java.lang.StringgetUnmarshallerName()Get unmarshaller class name.java.lang.StringgetUsing()Get label for definition to be used.abstract booleanhasObject()Check if this container defines a context object.booleanisAllowRepeats()Check if repeated child elements are allowed.booleanisChoice()Check if child components are a choice.protected booleanisClassified()Check for child components classified.booleanisFlexible()Get flexible flag.booleanisNillable()Check if nillable object.booleanisOrdered()Check if child components are ordered.voidprevalidate(ValidationContext vctx)Prevalidate element information.voidsetAllowRepeats(boolean ignore)Set repeated child elements allowed flag.voidsetChoice(boolean choice)Set child components choice flag.protected voidsetComponents(java.util.ArrayList attribs, java.util.ArrayList contents)Set child attribute and content components directly.voidsetCreateType(java.lang.String name)Set new instance type class name.voidsetFactoryName(java.lang.String name)Set factory method name.voidsetFlexible(boolean flexible)Set flexible flag.voidsetIdChild(IComponent child, ValidationContext vctx)Set ID property child.voidsetLabel(java.lang.String label)Set label for this definition.voidsetMarshallerName(java.lang.String name)Set marshaller class name.voidsetNillable(boolean nillable)Set nillable flag.voidsetOrdered(boolean ordered)Set child components ordered flag.voidsetPostsetName(java.lang.String name)Set post-set method name.voidsetPregetName(java.lang.String name)Set pre-get method name.voidsetPresetName(java.lang.String name)Set pre-set method name.voidsetUnmarshallerName(java.lang.String name)Set unmarshaller class name.voidsetUsing(java.lang.String label)Set label for definition to be used.voidvalidate(ValidationContext vctx)Validate element information.protected voidverifyConstruction(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
-
-
-
-
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 (nullif 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).
-
-
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:
trueif defines context object,falseif 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 propertyvctx- 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
nullif none)
-
getFactory
public IClassItem getFactory()
Get factory method information. This call is only meaningful after a call toprevalidate(ValidationContext).- Returns:
- factory method information (or
nullif 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
nullif none)
-
getPreset
public IClassItem getPreset()
Get pre-set method information. This call is only meaningful after a call toprevalidate(ValidationContext).- Returns:
- pre-set method information (or
nullif 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
nullif none)
-
getPostset
public IClassItem getPostset()
Get post-set method information. This call is only meaningful after a call toprevalidate(ValidationContext).- Returns:
- post-set method information (or
nullif 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
nullif none)
-
getPreget
public IClassItem getPreget()
Get pre-get method information. This call is only meaningful after a call toprevalidate(ValidationContext).- Returns:
- pre-get method information (or
nullif none)
-
setPregetName
public void setPregetName(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
nullif none)
-
getMarshaller
public IClass getMarshaller()
Get marshaller class information. This call is only meaningful after a call toprevalidate(ValidationContext).- Returns:
- class information for marshaller (or
nullif 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
nullif none)
-
getUnmarshaller
public IClass getUnmarshaller()
Get unmarshaller class information. This call is only meaningful after a call toprevalidate(ValidationContext).- Returns:
- class information for unmarshaller (or
nullif 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
nullif none)
-
getCreateClass
public IClass getCreateClass()
Get new instance creation class information. This method is only usable a call toprevalidate(ValidationContext).- Returns:
- class information for type to be created (or
nullif 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:
trueif ordered,falseif not
-
setOrdered
public void setOrdered(boolean ordered)
Set child components ordered flag.- Parameters:
ordered-trueif ordered,falseif not
-
isChoice
public boolean isChoice()
Check if child components are a choice.- Returns:
trueif choice,falseif not
-
setChoice
public void setChoice(boolean choice)
Set child components choice flag.- Parameters:
choice-trueif choice,falseif not
-
isAllowRepeats
public boolean isAllowRepeats()
Check if repeated child elements are allowed.- Returns:
trueif repeats allowed,falseif not
-
setAllowRepeats
public void setAllowRepeats(boolean ignore)
Set repeated child elements allowed flag.- Parameters:
ignore-trueif repeated child elements to be allowed,falseif 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 afterprevalidate(ValidationContext).- Parameters:
vctx- validation contexttype- 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 contexttype- structure object typechildren- 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:
trueif classified,falseif 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:ElementBasePrevalidate 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:
prevalidatein classNestingElementBase- Parameters:
vctx- validation context
-
validate
public void validate(ValidationContext vctx)
Description copied from class:ElementBaseValidate element information. The validation step is used for checking the interactions between elements, such as name references to other elements. TheElementBase.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:
validatein classNestingElementBase- Parameters:
vctx- validation context
-
-