Class SchemaBase

java.lang.Object
org.jibx.schema.elements.SchemaBase
All Implemented Interfaces:
IComponent
Direct Known Subclasses:
AnnotationItem, OpenAttrBase

public abstract class SchemaBase extends 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 Details

  • Constructor Details

    • SchemaBase

      protected SchemaBase(int type)
      Constructor.
      Parameters:
      type - element type code
  • Method Details

    • type

      public final int type()
      Get element type.
      Returns:
      type code for this element
    • name

      public final 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 (particularly FilteredSegmentList).
      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 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(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 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(String prefix, String uri)
      Add namespace declaration.
      Parameters:
      prefix - namespace prefix
      uri - namespace URI
    • getChildCount

      public abstract int getChildCount()
      Get count of child elements.
      Returns:
      child count
    • getChildIterator

      public abstract 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 context
      extra - allow extra attributes from other namespaces flag
      attrs - attributes array
      See Also:
    • 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 interface IComponent
      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. The prevalidate(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 interface IComponent
      Parameters:
      vctx - validation context