Package org.jibx.schema.elements
Class SchemaBase
- java.lang.Object
-
- org.jibx.schema.elements.SchemaBase
-
- All Implemented Interfaces:
IComponent
- Direct Known Subclasses:
AnnotationItem
,OpenAttrBase
public abstract class SchemaBase extends java.lang.Object implements IComponent
Base class for all element structures in schema definition model. This just provides the linkages for the schema definition tree structure and related validation hooks, along with support for extra namespaces.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALL_TYPE
static int
ANNOTATION_TYPE
static int
ANY_TYPE
static int
ANYATTRIBUTE_TYPE
static int
APPINFO_TYPE
static int
ATTRIBUTE_TYPE
static int
ATTRIBUTEGROUP_TYPE
static int
CHOICE_TYPE
static int
COMPLEXCONTENT_TYPE
static int
COMPLEXTYPE_TYPE
static int
DOCUMENTATION_TYPE
static long[]
ELEMENT_MASKS
Bit masks for individual elements.static java.lang.String[]
ELEMENT_NAMES
Actual element names.static int
ELEMENT_TYPE
static int
ENUMERATION_TYPE
static int
EXTENSION_TYPE
static int
FIELD_TYPE
static int
FRACTIONDIGITS_TYPE
static int
GROUP_TYPE
static int
IMPORT_TYPE
static int
INCLUDE_TYPE
static int
KEY_TYPE
static int
KEYREF_TYPE
static int
LENGTH_TYPE
static int
LIST_TYPE
private java.lang.Object
m_extension
Extension data for application use.private java.util.ArrayList
m_namespaces
Namespace definitions associated with this element (lazy create,null
if unused).private OpenAttrBase
m_parent
Parent element.private int
m_type
Element type code.static int
MAXEXCLUSIVE_TYPE
static int
MAXINCLUSIVE_TYPE
static int
MAXLENGTH_TYPE
static int
MINEXCLUSIVE_TYPE
static int
MININCLUSIVE_TYPE
static int
MINLENGTH_TYPE
static int
NOTATION_TYPE
static int
PATTERN_TYPE
static int
REDEFINE_TYPE
static int
RESTRICTION_TYPE
static int
SCHEMA_TYPE
static int
SELECTOR_TYPE
static int
SEQUENCE_TYPE
static int
SIMPLECONTENT_TYPE
static int
SIMPLETYPE_TYPE
static int
TOTALDIGITS_TYPE
static int
UNION_TYPE
static int
UNIQUE_TYPE
static int
WHITESPACE_TYPE
-
Fields inherited from interface org.jibx.schema.IComponent
SCHEMA_NAMESPACE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SchemaBase(int type)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addNamespaceDeclaration(java.lang.String prefix, java.lang.String uri)
Add namespace declaration.long
bit()
Get element bit mask.void
clearNamespaceDeclarations()
Clear namespace declarations list.abstract int
getChildCount()
Get count of child elements.abstract java.util.Iterator
getChildIterator()
Get read-only iterator for child elements.java.lang.Object
getExtension()
Get extension data.java.util.ArrayList
getNamespaceDeclarations()
Get namespace declarations list.OpenAttrBase
getParent()
Get parent element.SchemaElement
getSchema()
Get the ancestor schema element.boolean
isGlobal()
Check if this element represents a global definition.java.lang.String
name()
Get element name.protected void
preget(IMarshallingContext ictx)
Pre-get method to be called by data binding while writing element start tag.protected void
preset(IUnmarshallingContext ictx)
Pre-set method to be called by data binding while parsing element start tag.void
prevalidate(ValidationContext vctx)
Prevalidate component information.protected void
readNamespaces(IUnmarshallingContext ictx)
Collect namespace declarations from element.void
setExtension(java.lang.Object extension)
Set extension data.protected void
setParent(OpenAttrBase parent)
Set parent element.int
type()
Get element type.void
validate(ValidationContext vctx)
Validate component information.protected static void
validateAttributes(IUnmarshallingContext ictx, boolean extra, StringArray attrs)
Validate attributes of element.protected void
writeNamespaces(IMarshallingContext ictx)
Write namespace declarations to element.
-
-
-
Field Detail
-
ALL_TYPE
public static final int ALL_TYPE
- See Also:
- Constant Field Values
-
ANNOTATION_TYPE
public static final int ANNOTATION_TYPE
- See Also:
- Constant Field Values
-
ANY_TYPE
public static final int ANY_TYPE
- See Also:
- Constant Field Values
-
ANYATTRIBUTE_TYPE
public static final int ANYATTRIBUTE_TYPE
- See Also:
- Constant Field Values
-
APPINFO_TYPE
public static final int APPINFO_TYPE
- See Also:
- Constant Field Values
-
ATTRIBUTE_TYPE
public static final int ATTRIBUTE_TYPE
- See Also:
- Constant Field Values
-
ATTRIBUTEGROUP_TYPE
public static final int ATTRIBUTEGROUP_TYPE
- See Also:
- Constant Field Values
-
CHOICE_TYPE
public static final int CHOICE_TYPE
- See Also:
- Constant Field Values
-
COMPLEXCONTENT_TYPE
public static final int COMPLEXCONTENT_TYPE
- See Also:
- Constant Field Values
-
COMPLEXTYPE_TYPE
public static final int COMPLEXTYPE_TYPE
- See Also:
- Constant Field Values
-
DOCUMENTATION_TYPE
public static final int DOCUMENTATION_TYPE
- See Also:
- Constant Field Values
-
ELEMENT_TYPE
public static final int ELEMENT_TYPE
- See Also:
- Constant Field Values
-
ENUMERATION_TYPE
public static final int ENUMERATION_TYPE
- See Also:
- Constant Field Values
-
EXTENSION_TYPE
public static final int EXTENSION_TYPE
- See Also:
- Constant Field Values
-
FIELD_TYPE
public static final int FIELD_TYPE
- See Also:
- Constant Field Values
-
FRACTIONDIGITS_TYPE
public static final int FRACTIONDIGITS_TYPE
- See Also:
- Constant Field Values
-
GROUP_TYPE
public static final int GROUP_TYPE
- See Also:
- Constant Field Values
-
IMPORT_TYPE
public static final int IMPORT_TYPE
- See Also:
- Constant Field Values
-
INCLUDE_TYPE
public static final int INCLUDE_TYPE
- See Also:
- Constant Field Values
-
KEY_TYPE
public static final int KEY_TYPE
- See Also:
- Constant Field Values
-
KEYREF_TYPE
public static final int KEYREF_TYPE
- See Also:
- Constant Field Values
-
LENGTH_TYPE
public static final int LENGTH_TYPE
- See Also:
- Constant Field Values
-
LIST_TYPE
public static final int LIST_TYPE
- See Also:
- Constant Field Values
-
MAXEXCLUSIVE_TYPE
public static final int MAXEXCLUSIVE_TYPE
- See Also:
- Constant Field Values
-
MAXINCLUSIVE_TYPE
public static final int MAXINCLUSIVE_TYPE
- See Also:
- Constant Field Values
-
MAXLENGTH_TYPE
public static final int MAXLENGTH_TYPE
- See Also:
- Constant Field Values
-
MINEXCLUSIVE_TYPE
public static final int MINEXCLUSIVE_TYPE
- See Also:
- Constant Field Values
-
MININCLUSIVE_TYPE
public static final int MININCLUSIVE_TYPE
- See Also:
- Constant Field Values
-
MINLENGTH_TYPE
public static final int MINLENGTH_TYPE
- See Also:
- Constant Field Values
-
NOTATION_TYPE
public static final int NOTATION_TYPE
- See Also:
- Constant Field Values
-
PATTERN_TYPE
public static final int PATTERN_TYPE
- See Also:
- Constant Field Values
-
REDEFINE_TYPE
public static final int REDEFINE_TYPE
- See Also:
- Constant Field Values
-
RESTRICTION_TYPE
public static final int RESTRICTION_TYPE
- See Also:
- Constant Field Values
-
SCHEMA_TYPE
public static final int SCHEMA_TYPE
- See Also:
- Constant Field Values
-
SELECTOR_TYPE
public static final int SELECTOR_TYPE
- See Also:
- Constant Field Values
-
SEQUENCE_TYPE
public static final int SEQUENCE_TYPE
- See Also:
- Constant Field Values
-
SIMPLECONTENT_TYPE
public static final int SIMPLECONTENT_TYPE
- See Also:
- Constant Field Values
-
SIMPLETYPE_TYPE
public static final int SIMPLETYPE_TYPE
- See Also:
- Constant Field Values
-
TOTALDIGITS_TYPE
public static final int TOTALDIGITS_TYPE
- See Also:
- Constant Field Values
-
UNION_TYPE
public static final int UNION_TYPE
- See Also:
- Constant Field Values
-
UNIQUE_TYPE
public static final int UNIQUE_TYPE
- See Also:
- Constant Field Values
-
WHITESPACE_TYPE
public static final int WHITESPACE_TYPE
- See Also:
- Constant Field Values
-
ELEMENT_NAMES
public static final java.lang.String[] ELEMENT_NAMES
Actual element names.
-
ELEMENT_MASKS
public static final long[] ELEMENT_MASKS
Bit masks for individual elements.
-
m_type
private final int m_type
Element type code.
-
m_parent
private OpenAttrBase m_parent
Parent element.
-
m_extension
private java.lang.Object m_extension
Extension data for application use.
-
m_namespaces
private java.util.ArrayList m_namespaces
Namespace definitions associated with this element (lazy create,null
if unused).
-
-
Method Detail
-
type
public final int type()
Get element type.- Returns:
- type code for this element
-
name
public final java.lang.String name()
Get element name.- Returns:
- type code for this element
-
bit
public final long bit()
Get element bit mask.- Returns:
- bit mask for this element
-
getParent
public final OpenAttrBase getParent()
Get parent element.- Returns:
- parent element,
null
if none (schema element only)
-
setParent
protected final void setParent(OpenAttrBase parent)
Set parent element. This method is provided for use by subclasses and other classes in this package (particularlyFilteredSegmentList
).- Parameters:
parent
-
-
getSchema
public final SchemaElement getSchema()
Get the ancestor schema element. It is an error to call this method with an element which is not part of a schema, resulting in a runtime exception.- Returns:
- schema
-
isGlobal
public final boolean isGlobal()
Check if this element represents a global definition.- Returns:
true
if global,false
if not
-
getExtension
public java.lang.Object getExtension()
Get extension data. The actual type of object used for extension data (if any) is defined by the application.- Returns:
- extension
-
setExtension
public void setExtension(java.lang.Object extension)
Set extension data. The actual type of object used for extension data (if any) is defined by the application.- Parameters:
extension
-
-
getNamespaceDeclarations
public final java.util.ArrayList getNamespaceDeclarations()
Get namespace declarations list. Entries in this list consist of pairs, consisting of namespace prefix followed by namespace URI. The empty string is used as the prefix for the default namespace.- Returns:
- extra attribute list
-
clearNamespaceDeclarations
public final void clearNamespaceDeclarations()
Clear namespace declarations list.
-
addNamespaceDeclaration
public final void addNamespaceDeclaration(java.lang.String prefix, java.lang.String uri)
Add namespace declaration.- Parameters:
prefix
- namespace prefixuri
- namespace URI
-
getChildCount
public abstract int getChildCount()
Get count of child elements.- Returns:
- child count
-
getChildIterator
public abstract java.util.Iterator getChildIterator()
Get read-only iterator for child elements.- Returns:
- iterator
-
preget
protected void preget(IMarshallingContext ictx) throws JiBXException
Pre-get method to be called by data binding while writing element start tag. The base class implementation just writes out any extra namespaces defined on the element. Subclasses which override this implementation must call the base implementation during their processing.- Parameters:
ictx
- marshalling context- Throws:
JiBXException
- on marshalling error
-
preset
protected void preset(IUnmarshallingContext ictx) throws JiBXException
Pre-set method to be called by data binding while parsing element start tag. The base class implementation just sets the parent element link and reads in any extra namespaces defined on the element. Subclasses which override this implementation must call the base implementation during their processing.- Parameters:
ictx
- unmarshalling context- Throws:
JiBXException
- on error
-
validateAttributes
protected static void validateAttributes(IUnmarshallingContext ictx, boolean extra, StringArray attrs)
Validate attributes of element. This is designed to be called during unmarshalling as part of the pre-set method processing when a subclass instance is being created.- Parameters:
ictx
- unmarshalling contextextra
- allow extra attributes from other namespaces flagattrs
- attributes array- See Also:
preset(IUnmarshallingContext)
-
readNamespaces
protected void readNamespaces(IUnmarshallingContext ictx)
Collect namespace declarations from element. This is designed to be called during unmarshalling as part of the pre-set method processing when a subclass instance is being created.- Parameters:
ictx
- unmarshalling context
-
writeNamespaces
protected void writeNamespaces(IMarshallingContext ictx) throws JiBXException
Write namespace declarations to element. This is designed to be called during marshalling as part of the pre-get method processing when a subclass instance is being marshalled.- Parameters:
ictx
- marshalling context- Throws:
JiBXException
- on error writing
-
prevalidate
public void prevalidate(ValidationContext vctx)
Prevalidate component information. The prevalidation step is used to check isolated aspects of a component, such as the settings for enumerated values. This empty base class implementation should be overridden by each subclass that requires prevalidation handling.- Specified by:
prevalidate
in interfaceIComponent
- Parameters:
vctx
- validation context
-
validate
public void validate(ValidationContext vctx)
Validate component information. The validation step is used for checking the interactions between components, such as name references to other components. Theprevalidate(org.jibx.schema.validation.ValidationContext)
method will always be called for every component in the schema definition before this method is called for any component. This empty base class implementation should be overridden by each subclass that requires validation handling.- Specified by:
validate
in interfaceIComponent
- Parameters:
vctx
- validation context
-
-