Class 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 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