Class ALcdXMLTypedElementReader

java.lang.Object
com.luciad.format.xml.schema.ALcdXMLTypedElementReader
All Implemented Interfaces:
ILcdXMLElementReader

public abstract class ALcdXMLTypedElementReader extends Object implements ILcdXMLElementReader
Deprecated.
Use of the com.format.xml.schema API has been deprecated. Instead, use the com.format.xml.bind.schema API.
An abstract class implementing ILcdXMLElementReader, facilitating the implementation of custom XML readers and offering support for XML type inheritance, based on schema information. Its main functions are:
  • to take care of context management: a new reader context and domain model object are created each time an element is started (via an element factory provider).
  • to delegate the part of the handling that cannot be performed by this reader, to the super reader (i.e., the reader registered for the XML type of which the type of this reader is an extension or restriction).
Extensions of this class should typically override the following methods:
  • void content(ILcdXMLNameStack aElementStack, String aContent): handling of simple content
  • void initObject(ILcdXMLNameStack aElementStack, ILcdAssocSet aAttributes): initialization of a new object
  • void handleChild(ILcdXMLNameStack aElementStack, Object aObject): handling of a child element
  • void finalizeObject(ILcdXMLNameStack aElementStack): finalization of the current object
  • Object createContext(): creation of a context, in which temporary information can be saved
  • Constructor Details

    • ALcdXMLTypedElementReader

      public ALcdXMLTypedElementReader(ILcdXMLTypedElementReaderProvider aTypedElementReaderProvider, ILcdXMLObjectFactoryProvider aTypeFactoryProvider, ILcdXMLSchemaProvider aSchemaProvider, TLcdXMLName aTypeName)
      Deprecated.
      Creates a new reader for a global type.
      Parameters:
      aTypedElementReaderProvider - The provider to be used for lookup of child readers.
      aTypeFactoryProvider - The provider to be used for creation of new object instances.
      aSchemaProvider - The provider to be used for lookup of XML type hierarchies.
      aTypeName - Each time an element stack is started, whose top element matches this type, a new context and domain model object will be created.
    • ALcdXMLTypedElementReader

      public ALcdXMLTypedElementReader(ILcdXMLTypedElementReaderProvider aTypedElementReaderProvider, ILcdXMLObjectFactoryProvider aTypeFactoryProvider, ILcdXMLSchemaProvider aSchemaProvider, TLcdXMLName aTypeName, TLcdXMLName[] aElementNameStack)
      Deprecated.
      Creates a new reader for an anonymous type.
      Parameters:
      aTypedElementReaderProvider - The provider to be used for lookup of child readers.
      aTypeFactoryProvider - The provider to be used for creation of new object instances.
      aSchemaProvider - The provider to be used for lookup of XML type hierarchies.
      aTypeName - The closest global ancestor type in which the anonymous type is contained, or null if there is no ancestor element defined by a global type (i.e., all ancestor elements of the type have an anonymous type).
      aElementNameStack - The list of element names that identify the anonymous type, starting from the top-most global element or one of the child element of the given global type.
  • Method Details

    • startElement

      public void startElement(ILcdXMLNameStack aElementStack, ILcdAssocSet aAttributes, Object aObject, ILcdXMLDocumentContext aContext)
      Deprecated.
      Starts a new element, and performs the following steps:

      • create a new context for this element, by calling createContext()
      • if aObject is null, create a new object, by calling createObject(TLcdXMLGlobalName aELementName, ILcdAssocSet aAttributes), and registered as the current object. If aObject isn't null, that object will be registered with the current context as the current object to work on.
      • call the startElement method of the base type's reader, if there is one, with the current object as last parameter. Attributes supported by this handled will be filtered out when delegating to the base type's reader.
      • initialize the object, by calling initObject(TLcdXMLGlobalName aElement, ILcdAssocSet aAttributes)

      Specified by:
      startElement in interface ILcdXMLElementReader
      Parameters:
      aElementStack -
      aAttributes -
      aObject -
      aContext -
    • endElement

      public Object endElement(ILcdXMLNameStack aElementStack, ILcdXMLDocumentContext aContext)
      Deprecated.
      Ends an element. This performs the following steps:

      • call the endElement method of the base type's reader, if there is one
      • Finalize the object, by calling finalizeObject
      • reestablish the 'current' context and 'current' object that were active just before this element was started

      The 'current' object of this element, is returned.

      Specified by:
      endElement in interface ILcdXMLElementReader
      Parameters:
      aElementStack -
      aContext -
      Returns:
      the object constructed by this reader (or one of its subtype readers) for the element.
    • content

      public void content(ILcdXMLNameStack aElementStack, char[] chars, int start, int length, ILcdXMLDocumentContext aContext)
      Deprecated.
      Description copied from interface: ILcdXMLElementReader
      Reports some simple character content to be processed. Content and children are reported in the order they are present in the original XML document.

      A continuous block of XML characters can be split up by the decoder and passed to this reader in multiple method calls, especially if the character block is large. After the last character(s) of a block have been passed to this reader, the method will be called with aLength == -1, to indicate that the content block has ended.

      Specified by:
      content in interface ILcdXMLElementReader
      Parameters:
      aElementStack - The current element name stack, including the container element for this content on top.
      chars - The characters.
      start - The start position in the character array.
      length - The number of characters to use from the character array.
      aContext - The document context for the XML document currently being decoded.
    • content

      public void content(ILcdXMLNameStack aElementStack, String aContent, ILcdXMLDocumentContext aContext)
      Deprecated.
      This method is called whenever simple content is parsed and the canHandleContent() method returns true. The default implementation does nothing.
      Parameters:
      aElementStack -
      aContent -
      aContext -
    • canHandleContent

      public boolean canHandleContent(ILcdXMLDocumentContext aContext)
      Deprecated.
      Returns true if this method can handle simple (text) content, false if content handling should be delegated to an XML base type handler. By default, returns false.
      Returns:
      true if this method can handle simple content, false otherwise.
    • isTrimContent

      protected boolean isTrimContent(ILcdXMLNameStack aElementStack, String aContent, ILcdXMLDocumentContext aContext)
      Deprecated.
      Returns whether content should be trimmed or not. By default, returns false if the type has mixed content, true otherwise.
      Parameters:
      aElementStack - the current element name stack.
      aContent - the content to be processed.
      aContext - the document context.
      Returns:
      true if the content should be trimmed, false otherwise.
    • getChildReader

      public ILcdXMLElementReader getChildReader(ILcdXMLNameStack aElementStack, ILcdAssocSet aAttributes, ILcdXMLDocumentContext aContext)
      Deprecated.
      Tries to find a matching reader for the given child.

      • If the child is supported by this reader (isSupportedChild(child) returns true), returns the reader provided by the element reader provider.
      • If the child isn't supported, tries to get a child reader from the base type reader, if there is one.
      • Else, return null.
      Specified by:
      getChildReader in interface ILcdXMLElementReader
      Parameters:
      aElementStack -
      aAttributes -
      aContext -
      Returns:
      a child reader for the given child.
    • endChildElement

      public void endChildElement(ILcdXMLNameStack aElementStack, ILcdXMLElementReader aReader, Object aObject, ILcdXMLDocumentContext aContext)
      Deprecated.
      This method is called whenever a child element has been finished. The following steps are performed:

      • If the child is a supported child, handleChild is called with the corresponding child element name (if the child element was substituted, the originally registered child name is passed, not the substituted name) and the object that was created by the child reader.
      • Else, if there is a supertype reader, the call is forwarded to the endChildreader method of the supertype's readers.
      Specified by:
      endChildElement in interface ILcdXMLElementReader
      Parameters:
      aElementStack -
      aReader -
      aObject -
      aContext -
    • isSupportedChild

      protected boolean isSupportedChild(ILcdXMLNameStack aElementStack, ILcdXMLDocumentContext aContext)
      Deprecated.
      Returns true if the given element is a supported child (i.e., if this reader can take the necessary steps to store the object that is created by the child's reader.

      A child is supported if either:

      • the child element belongs to the substitution group of one of the substitutable children of this element (only globally defined elements are substitutable)
      • or the child element matches one of the locally defined childs of this element.
      Parameters:
      aElementStack -
      Returns:
      true if the given element is supported by this reader, false otherwise.
    • isSupportedAttribute

      protected boolean isSupportedAttribute(TLcdXMLName aAttributeName)
      Deprecated.
    • getBaseTypeReader

      protected ILcdXMLElementReader getBaseTypeReader()
      Deprecated.
      Returns the base type reader of this reader, or null if none exists. This is done by climbing up the type hierarchy (type.getSuperType()) until a type is found for which a reader is registered with the type reader provider.
      Returns:
      the super reader of this reader.
    • createObject

      protected Object createObject(ILcdXMLNameStack aElementStack, ILcdAssocSet aAttributes, ILcdXMLDocumentContext aDocumentContext)
      Deprecated.
      Creates and returns a new instance for the current element handled by this reader. If there is an ILcdXMLObjectFactory available in the ILcdXMLObjectFactoryProvider for this type, a new instance is created via the factory, otherwise, null is returned. If the created object returned by the object factory is an instance of ILcdXMLEditableElement, it will also set the correct XML name on the element.
      Parameters:
      aAttributes -
      aDocumentContext -
      Returns:
      a new instance for the currently handled element
    • initObject

      protected void initObject(ILcdXMLNameStack aElementStack, ILcdAssocSet aAttributes, ILcdXMLDocumentContext aContext)
      Deprecated.
      Initializes a newly created object. The default implementation is empty.
      Parameters:
      aAttributes -
      aContext -
    • handleChild

      public void handleChild(ILcdXMLNameStack aElementStack, Object aObject, ILcdXMLDocumentContext aContext)
      Deprecated.
      Is called by endChildreader whenever a child element is finished, that is supported by this reader. If the element was substituted, the original element name, registered with this reader, is passed.
      Parameters:
      aObject -
      aContext -
    • finalizeObject

      protected void finalizeObject(ILcdXMLNameStack aElementStack, ILcdXMLDocumentContext aContext)
      Deprecated.
      Finalizes the current object.
    • getCurrentObject

      protected Object getCurrentObject(ILcdXMLDocumentContext aContext)
      Deprecated.
      Returns the current object.
      Returns:
      the current object
    • createContext

      protected Object createContext()
      Deprecated.
      Creates a new context, that can be used by the reader to store intermediate information during the handling of an element. By default, null is returned.
      Returns:
      a new context for the current element
    • getCurrentContext

      protected Object getCurrentContext(ILcdXMLDocumentContext aContext)
      Deprecated.
      Returns the current context.
      Returns:
      the context for the current element
    • getElementReaderProvider

      protected ILcdXMLTypedElementReaderProvider getElementReaderProvider()
      Deprecated.
      Returns the ILcdXMLTypereaderProvider that is used by this reader.
      Returns:
      the ILcdXMLTypereaderProvider that is used by this reader.
    • getObjectFactoryProvider

      protected ILcdXMLObjectFactoryProvider getObjectFactoryProvider()
      Deprecated.
      Returns the ILcdXMLTypeFactoryProvider that is used by this reader.
      Returns:
      the ILcdXMLTypeFactoryProvider that is used by this reader.
    • getXMLSchemaUtil

      protected TLcdXMLSchemaUtil getXMLSchemaUtil()
      Deprecated.
      Returns an XML util instance, initialized with the proper schema provider.
      Returns:
      XML util
    • getSchemaProvider

      protected ILcdXMLSchemaProvider getSchemaProvider()
      Deprecated.
      Returns the ILcdXMLSchemaProvider that is used by this reader.
      Returns:
      the ILcdXMLSchemaProvider that is used by this reader.