org.jibx.schema.elements
Class OpenAttrBase

java.lang.Object
  extended by org.jibx.schema.elements.SchemaBase
      extended by org.jibx.schema.elements.OpenAttrBase
All Implemented Interfaces:
IComponent
Direct Known Subclasses:
AnnotatedBase, AnnotationElement, SchemaElement

public abstract class OpenAttrBase
extends SchemaBase

Base class for all element structures in schema definition which allow arbitrary attributes from outside the schema namespace.

Author:
Dennis M. Sosnoski

Field Summary
private  java.util.ArrayList m_attributes
          Extra attributes associated with element (lazy create, null if unused).
private  LazyList m_children
          Child element list (lazy create, null if not used)
 
Fields inherited from class org.jibx.schema.elements.SchemaBase
ALL_TYPE, ANNOTATION_TYPE, ANY_TYPE, ANYATTRIBUTE_TYPE, APPINFO_TYPE, ATTRIBUTE_TYPE, ATTRIBUTEGROUP_TYPE, CHOICE_TYPE, COMPLEXCONTENT_TYPE, COMPLEXTYPE_TYPE, DOCUMENTATION_TYPE, ELEMENT_MASKS, ELEMENT_NAMES, ELEMENT_TYPE, ENUMERATION_TYPE, EXTENSION_TYPE, FIELD_TYPE, FRACTIONDIGITS_TYPE, GROUP_TYPE, IMPORT_TYPE, INCLUDE_TYPE, KEY_TYPE, KEYREF_TYPE, LENGTH_TYPE, LIST_TYPE, MAXEXCLUSIVE_TYPE, MAXINCLUSIVE_TYPE, MAXLENGTH_TYPE, MINEXCLUSIVE_TYPE, MININCLUSIVE_TYPE, MINLENGTH_TYPE, NOTATION_TYPE, PATTERN_TYPE, REDEFINE_TYPE, RESTRICTION_TYPE, SCHEMA_TYPE, SELECTOR_TYPE, SEQUENCE_TYPE, SIMPLECONTENT_TYPE, SIMPLETYPE_TYPE, TOTALDIGITS_TYPE, UNION_TYPE, UNIQUE_TYPE, WHITESPACE_TYPE
 
Fields inherited from interface org.jibx.schema.IComponent
SCHEMA_NAMESPACE
 
Constructor Summary
protected OpenAttrBase(int type)
          Constructor.
 
Method Summary
 void addExtraAttribute(java.lang.String name, java.lang.String uri, java.lang.String value)
          Add extra attribute.
 void clearExtraAttributes()
          Clear extra attribute list.
 void compactChildren()
          Compact the list of child elements.
 SchemaBase detachChild(int index)
          Detach child by index.
 SchemaBase getChild(int index)
          Get child by index.
 int getChildCount()
          Get count of child elements.
 java.util.Iterator getChildIterator()
          Get read-only iterator for child elements.
protected  LazyList getChildrenWritable()
          Get modifiable list of child elements.
 java.util.List getExtraAttributes()
          Get read-only list of extra attributes.
protected  void preget(IMarshallingContext ictx)
          Pre-get method called during marshalling.
 SchemaBase replaceChild(int index, SchemaBase repl)
          Replace child by index.
protected  void validateAttributes(IUnmarshallingContext ictx, StringArray attrs)
          Validate attributes of element from schema namespace.
 
Methods inherited from class org.jibx.schema.elements.SchemaBase
addNamespaceDeclaration, bit, clearNamespaceDeclarations, getExtension, getNamespaceDeclarations, getParent, getSchema, isGlobal, name, preset, prevalidate, readNamespaces, setExtension, setParent, type, validate, validateAttributes, writeNamespaces
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_children

private LazyList m_children
Child element list (lazy create, null if not used)


m_attributes

private java.util.ArrayList m_attributes
Extra attributes associated with element (lazy create, null if unused).

Constructor Detail

OpenAttrBase

protected OpenAttrBase(int type)
Constructor.

Parameters:
type - element type
Method Detail

getChildCount

public final int getChildCount()
Get count of child elements.

Specified by:
getChildCount in class SchemaBase
Returns:
child count

getChildIterator

public java.util.Iterator getChildIterator()
Get read-only iterator for child elements.

Specified by:
getChildIterator in class SchemaBase
Returns:
iterator

getChild

public SchemaBase getChild(int index)
Get child by index.

Parameters:
index -
Returns:
child element

replaceChild

public SchemaBase replaceChild(int index,
                               SchemaBase repl)
Replace child by index.

Parameters:
index -
repl - replacement element
Returns:
detached child

detachChild

public SchemaBase detachChild(int index)
Detach child by index. This method only replaces the child with a null in the child list, leaving the list in an illegal state for most purposes. After using this method, compactChildren() must be called to remove the null(s) from the list and restore it to a legal state. These methods are provided to avoid the overhead otherwise associated with multiple removals from a list.

Parameters:
index -
Returns:
detached child

compactChildren

public void compactChildren()
Compact the list of child elements. This removes any null values (which should only be present if detachChild(int) was called) from the list.


preget

protected void preget(IMarshallingContext ictx)
               throws JiBXException
Pre-get method called during marshalling. This first calls the base class implementation to handle namespaces, then writes any extra attributes to the element start tag.

Overrides:
preget in class SchemaBase
Parameters:
ictx - marshalling context
Throws:
JiBXException - on marshalling error

getChildrenWritable

protected final LazyList getChildrenWritable()
Get modifiable list of child elements. This method should only be used by subclasses to work with their own list of child elements.

Returns:
child list

getExtraAttributes

public final java.util.List getExtraAttributes()
Get read-only list of extra attributes. Entries in this list are triplets, consisting of attribute name, namespace, and value.

Returns:
extra attribute list

clearExtraAttributes

public final void clearExtraAttributes()
Clear extra attribute list.


addExtraAttribute

public final void addExtraAttribute(java.lang.String name,
                                    java.lang.String uri,
                                    java.lang.String value)
Add extra attribute.

Parameters:
name - attribute name
uri - attribute namespace URI
value - attribute value

validateAttributes

protected void validateAttributes(IUnmarshallingContext ictx,
                                  StringArray attrs)
                           throws JiBXException
Validate attributes of element from schema namespace. This allows any number of attributes from other namespaces on the element.

Parameters:
ictx - unmarshalling context
attrs - attributes array
Throws:
JiBXException - on unmarshalling error


Project Web Site