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.Stringm_classNameName of handled class.private java.util.ArrayListm_extensionTypesTemplates or mappings that can be used in place of this one (as substitution group using mapping, or xsi:type with template).private IClassm_handledClassHandled class information.protected java.util.ArrayListm_topChildrenList of child elements.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 Constructor Description TemplateElementBase(int type)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddExtensionType(TemplateElementBase ext)Add template or mapping which derives from this one.voidaddTopChild(java.lang.Object child)Add top-level child element.java.lang.StringgetClassName()Get mapped class name.java.util.ArrayListgetExtensionTypes()Get templates or mappings which derive from this one.IClassgetHandledClass()Get handled class information.IClassgetObjectType()Get class linked to binding element.IClassgetType()booleanhasObject()Check if this container defines a context object.abstract booleanisDefaultTemplate()Check if default template for type.booleanisImplicit()booleanisOptional()voidprevalidate(ValidationContext vctx)Prevalidate element information.voidsetClassName(java.lang.String name)Set mapped class name.java.util.IteratortopChildIterator()Get iterator for top-level child elements.java.util.ArrayListtopChildren()Get list of top-level child elements.voidvalidate(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:
trueif default for type,falseif 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
nullif 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:ContainerElementBaseCheck if this container defines a context object.- Specified by:
hasObjectin classContainerElementBase- Returns:
trueif defines context object,falseif not
-
getObjectType
public IClass getObjectType()
Description copied from class:ContainerElementBaseGet class linked to binding element. This call is only meaningful after validation.- Specified by:
getObjectTypein classContainerElementBase- Returns:
- information for class linked by binding
-
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 classContainerElementBase- 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 classContainerElementBase- Parameters:
vctx- validation context
-
-