com.softwareag.tamino.db.api.objectModel.sax
Class TSAXElementDefaultHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.softwareag.tamino.db.api.objectModel.sax.TSAXElementDefaultHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
Direct Known Subclasses:
TSAXElementDefaultHandlerImpl, TStreamElementDefaultHandler

public abstract class TSAXElementDefaultHandler
extends org.xml.sax.helpers.DefaultHandler

TSAXElementDefaultHandler is a SAX DefaultHandler class. You must provide a class extending this class when using a SAX object model and intend to use the SAX object model to process XML documents resulting from a query.

The TSAXElementDefaultHandler instance specified for a SAX object model receives events for an XML object obtained from Tamino as the reuslt of a query. The element handler receives element events starting with the first member of the query result set. It should create an instance of the class implementing the TSAXElement interface associated with the same SAX object model for each of these members. The following code example shows the usage of a SAX object model and an element handler.

            // instantiate a SAX object model with an element handler
            TSAXObjectModel mySAXObjectModel = new TSAXObjectModel( "MySAXModel" ,
         null ,
         MySAXElement.class ,
                null ,
                mySAXElementDefaultHandler );
     TXMLObjectAccessor accessor = connection.newXMLObjectAccessor(
                TAccessLocation.newInstance( "some collection" ),
                mySAXObjectModel );
     TReponse response = accessor.query( new TQuery( "some query expression" ) );
     // get the first member of the query result set
            TXMLObject xmlObject = response.getFirstXMLObject();
     // get the first SAX element instance.
     // the SAX element default handler received the SAX events and build this.
     MySaxElement mySaxElement = (MySaxElement)xmlObject.getElement();
            mySaxElement.????;
        

Version:
$Revision: 1.7 $
Author:
Marcus Schreyer

Field Summary
static java.lang.String SPECIFIER
          An internal identification for this interface.
 
Constructor Summary
TSAXElementDefaultHandler()
           
 
Method Summary
abstract  java.util.Iterator<TStreamElement> getElementIterator()
          Returns an iterator to iterate over the members of the query result set.
abstract  TSAXElement getFirstElement()
          Returns the first TSAXElement instance representing the first member of the query result set.
 void reset()
          Clears the content that might currently be available thru getFirstElement and getElementIterator.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPECIFIER

public static final java.lang.String SPECIFIER
An internal identification for this interface.

Constructor Detail

TSAXElementDefaultHandler

public TSAXElementDefaultHandler()
Method Detail

getFirstElement

public abstract TSAXElement getFirstElement()
Returns the first TSAXElement instance representing the first member of the query result set. Each class extending TSAXElementDefaultHandler may choose to implement this method or not. An implementation is required if the getFirstXMLObject method of the TResponse instance build for the query in question is to return meaningful information. The instance returned by this method is the instance returned by the getFirstXMLObject method of TResponse. Normally, an implementation of this method is closely related to an implementation of the getElementIterator method.

Returns:
TSAXElement instance if one is given, null otherwise.

getElementIterator

public abstract java.util.Iterator<TStreamElement> getElementIterator()
Returns an iterator to iterate over the members of the query result set. Each class extending TSAXElementDefaultHandler may choose to implement this method or not. An implementation is required if the getXMLObjectIterator method of the TResponse instance build for the query in question is to return meaningful information. The instance returned by this method corresponds to the instance returned by the getXMLObjectIterator method of TResponse. Normally, an implementation of this method is closely related to an implementation of the getFirstElement method.

Returns:
java.util.Iterator if one is given, null otherwise.

reset

public void reset()
Clears the content that might currently be available thru getFirstElement and getElementIterator. NOTE: this has to be called at appropriate code position before input stream interpreting starts.



Copyright (c) 2013 Software AG. All Rights Reserved.