Package org.jibx.binding.model
Class TemplateElementBase
- java.lang.Object
-
- org.jibx.binding.model.ElementBase
-
- org.jibx.binding.model.NestingElementBase
-
- org.jibx.binding.model.ContainerElementBase
-
- org.jibx.binding.model.TemplateElementBase
-
- Direct Known Subclasses:
MappingElementBase
,TemplateElement
public abstract class TemplateElementBase extends ContainerElementBase
Model component for elements that define how instances of a particular class are converted to or from XML. This includes both mapping and template elements.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
m_className
Name of handled class.private java.util.ArrayList
m_extensionTypes
Templates or mappings that can be used in place of this one (as substitution group using mapping, or xsi:type with template).private IClass
m_handledClass
Handled class information.protected java.util.ArrayList
m_topChildren
List of child elements.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
Constructors Constructor Description TemplateElementBase(int type)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addExtensionType(TemplateElementBase ext)
Add template or mapping which derives from this one.void
addTopChild(java.lang.Object child)
Add top-level child element.java.lang.String
getClassName()
Get mapped class name.java.util.ArrayList
getExtensionTypes()
Get templates or mappings which derive from this one.IClass
getHandledClass()
Get handled class information.IClass
getObjectType()
Get class linked to binding element.IClass
getType()
boolean
hasObject()
Check if this container defines a context object.abstract boolean
isDefaultTemplate()
Check if default template for type.boolean
isImplicit()
boolean
isOptional()
void
prevalidate(ValidationContext vctx)
Prevalidate element information.void
setClassName(java.lang.String name)
Set mapped class name.java.util.Iterator
topChildIterator()
Get iterator for top-level child elements.java.util.ArrayList
topChildren()
Get list of top-level child elements.void
validate(ValidationContext vctx)
Validate element information.-
Methods inherited from class org.jibx.binding.model.ContainerElementBase
checkCompatibleChildren, classifyComponents, 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, setPregetName, 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
-
-
-
-
Field Detail
-
s_allowedAttributes
public static final StringArray s_allowedAttributes
Enumeration of allowed attribute names
-
m_className
private java.lang.String m_className
Name of handled class.
-
m_handledClass
private IClass m_handledClass
Handled class information.
-
m_topChildren
protected java.util.ArrayList m_topChildren
List of child elements.
-
m_extensionTypes
private java.util.ArrayList m_extensionTypes
Templates or mappings that can be used in place of this one (as substitution group using mapping, or xsi:type with template).
-
-
Method Detail
-
setClassName
public void setClassName(java.lang.String name)
Set mapped class name.- Parameters:
name
- mapped class name
-
getClassName
public java.lang.String getClassName()
Get mapped class name.- Returns:
- class name
-
getHandledClass
public IClass getHandledClass()
Get handled class information. This call is only meaningful after prevalidation.- Returns:
- mapped class information
-
addExtensionType
protected void addExtensionType(TemplateElementBase ext)
Add template or mapping which derives from this one.- Parameters:
ext
- derived template or mapping information
-
getExtensionTypes
public java.util.ArrayList getExtensionTypes()
Get templates or mappings which derive from this one.- Returns:
- list of derived templates or mappings
-
isDefaultTemplate
public abstract boolean isDefaultTemplate()
Check if default template for type. Needs to be implemented by subclasses for common handling.- Returns:
true
if default for type,false
if not
-
addTopChild
public void addTopChild(java.lang.Object child)
Add top-level child element.- Parameters:
child
- element to be added as child of this element
-
topChildren
public java.util.ArrayList topChildren()
Get list of top-level child elements.- Returns:
- list of child elements, or
null
if none
-
topChildIterator
public java.util.Iterator topChildIterator()
Get iterator for top-level child elements.- Returns:
- iterator for child elements
-
isOptional
public boolean isOptional()
-
getType
public IClass getType()
-
isImplicit
public boolean isImplicit()
-
hasObject
public boolean hasObject()
Description copied from class:ContainerElementBase
Check if this container defines a context object.- Specified by:
hasObject
in classContainerElementBase
- Returns:
true
if defines context object,false
if not
-
getObjectType
public IClass getObjectType()
Description copied from class:ContainerElementBase
Get class linked to binding element. This call is only meaningful after validation.- Specified by:
getObjectType
in classContainerElementBase
- Returns:
- information for class linked by binding
-
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 classContainerElementBase
- 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. 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:
validate
in classContainerElementBase
- Parameters:
vctx
- validation context
-
-