com.ibm.ims.xms
Class XMSShredder

java.lang.Object
  |
  +--com.ibm.ims.xms.XMSShredder
All Implemented Interfaces:
DLISegmentStream, XMSDocumentHandler

public class XMSShredder
extends java.lang.Object
implements XMSDocumentHandler, DLISegmentStream

Shreds an XML document, while implementing an XMSDocumentHandler


Fields inherited from interface com.ibm.ims.xms.XMSDocumentHandler
TYPE_FIELD, TYPE_SEGMENT, TYPE_UNKNOWN
 
Constructor Summary
XMSShredder(XMSGrammarPool xmsGrammarPool, DLIDatabaseView dbView, java.lang.String pcbAlias, boolean validate)
          Creates a XMSShredder object capable of shredding a valid XMS XML Document.
 
Method Summary
 void endDocument()
          The end of the document.
 void endField(java.lang.String fieldName)
          The end of a field.
 void endSegment(java.lang.String segmentName)
          The end of a segment.
 void fieldValue(java.lang.String text)
          Part or all of a field value.
 boolean fillTopSegment(DLISegment topSegment)
          Begins XML parse filling the topSegment.
 int getElementType(java.lang.String elementName)
          Queries for the type this element maps to.
 DLISegment getSegment()
          Returns the next DLISegment produced by the XML Parse.
static void main(java.lang.String[] args)
          This method is used for internal testing only
 boolean moreSegments()
          Returns true if there are more segments to be parsed and returned.
 void reset()
          Resets any accumulated State.
 void setInputSource(java.io.Reader reader)
          Sets the input source to parse.
 void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)
          Sets the input source to parse.
 void sideSegment(java.lang.String segmentName, java.lang.String fieldName, java.lang.String fieldValue)
          Indicates a side Segment has been found inside the current field.
 void startDocument(java.lang.String psbName, java.lang.String pcbName)
          The start of the document.
 boolean startField(java.lang.String fieldName)
          The start of a field.
 void startSegment(java.lang.String segmentName)
          The start of a segment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMSShredder

public XMSShredder(XMSGrammarPool xmsGrammarPool,
                   DLIDatabaseView dbView,
                   java.lang.String pcbAlias,
                   boolean validate)
            throws java.io.IOException
Creates a XMSShredder object capable of shredding a valid XMS XML Document. It uses the prebuilt symbolTable and grammarPool preloaded by the passed in XMSGrammarPool.
Method Detail

fillTopSegment

public boolean fillTopSegment(DLISegment topSegment)
                       throws java.io.IOException,
                              DLIException
Begins XML parse filling the topSegment. This must be the first parsing call. Returns true if there are more Segments to be parsed.
Specified by:
fillTopSegment in interface DLISegmentStream

moreSegments

public boolean moreSegments()
                     throws java.io.IOException
Returns true if there are more segments to be parsed and returned.
Specified by:
moreSegments in interface DLISegmentStream

getSegment

public DLISegment getSegment()
                      throws java.io.IOException,
                             DLIException
Returns the next DLISegment produced by the XML Parse.
Specified by:
getSegment in interface DLISegmentStream
Throws:
NoSuchElementException - no more segments to get.

setInputSource

public void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource)
                    throws org.apache.xerces.xni.parser.XMLConfigurationException,
                           java.io.IOException
Sets the input source to parse.
Parameters:
inputSource - The document's input source.
Throws:
org.apache.xerces.xni.parser.XMLConfigurationException - Thrown if there is a configuration error when initializing the parser.
java.io.IOException - Thrown on I/O error.
See Also:
#parse(boolean)

setInputSource

public void setInputSource(java.io.Reader reader)
                    throws org.apache.xerces.xni.parser.XMLConfigurationException,
                           java.io.IOException
Sets the input source to parse.
Parameters:
inputSource - The document's input source.
Throws:
org.apache.xerces.xni.parser.XMLConfigurationException - Thrown if there is a configuration error when initializing the parser.
java.io.IOException - Thrown on I/O error.
See Also:
#parse(boolean)

startDocument

public void startDocument(java.lang.String psbName,
                          java.lang.String pcbName)
                   throws org.apache.xerces.xni.XNIException
The start of the document.
Specified by:
startDocument in interface XMSDocumentHandler
Parameters:
psbName - The name of the PSB this instance data relates to.
pcbName - The name of the PCB this instance data relates to.
Throws:
XNIException - Thrown by handler to signal an error.

getElementType

public int getElementType(java.lang.String elementName)
                   throws org.apache.xerces.xni.XNIException
Queries for the type this element maps to.
Specified by:
getElementType in interface XMSDocumentHandler
Parameters:
elementName - The name of the element encountered in the parse.
Throws:
XNIException - Thrown by handler to signal an error.

startSegment

public void startSegment(java.lang.String segmentName)
                  throws org.apache.xerces.xni.XNIException
The start of a segment.
Specified by:
startSegment in interface XMSDocumentHandler
Parameters:
segmentName - The name of the segment.
Throws:
XNIException - Thrown by handler to signal an error.

startField

public boolean startField(java.lang.String fieldName)
                   throws org.apache.xerces.xni.XNIException
The start of a field.
Specified by:
startField in interface XMSDocumentHandler
Parameters:
fieldName - The name of the field.
Returns:
boolean If the field value is a clob
Throws:
XNIException - Thrown by handler to signal an error.

fieldValue

public void fieldValue(java.lang.String text)
                throws org.apache.xerces.xni.XNIException
Part or all of a field value.
Specified by:
fieldValue in interface XMSDocumentHandler
Parameters:
text - The content.
Throws:
XNIException - Thrown by handler to signal an error.

sideSegment

public void sideSegment(java.lang.String segmentName,
                        java.lang.String fieldName,
                        java.lang.String fieldValue)
                 throws org.apache.xerces.xni.XNIException
Indicates a side Segment has been found inside the current field.
Specified by:
sideSegment in interface XMSDocumentHandler
Parameters:
segmentName - The SideSegment name.
fieldName - The Name of the single field in the Side Segment.
fieldValue - The Value of the field.
Throws:
XNIException - Thrown by handler to signal an error.

endField

public void endField(java.lang.String fieldName)
              throws org.apache.xerces.xni.XNIException
The end of a field.
Specified by:
endField in interface XMSDocumentHandler
Parameters:
endField - The name of the field.
Throws:
XNIException - Thrown by handler to signal an error.

endSegment

public void endSegment(java.lang.String segmentName)
                throws org.apache.xerces.xni.XNIException
The end of a segment.
Specified by:
endSegment in interface XMSDocumentHandler
Parameters:
segmentName - The name of the segment.
Throws:
XNIException - Thrown by handler to signal an error.

endDocument

public void endDocument()
                 throws org.apache.xerces.xni.XNIException
The end of the document.
Specified by:
endDocument in interface XMSDocumentHandler
Throws:
XNIException - Thrown by handler to signal an error.

reset

public void reset()
Resets any accumulated State.
Specified by:
reset in interface XMSDocumentHandler

main

public static void main(java.lang.String[] args)
This method is used for internal testing only


(C) International Business Machines Corporation 2004. All rights reserved.