Open Business Objects for EDI
v3.6.0

com.americancoders.edi
Class ValidXMLEDIParser

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--com.americancoders.edi.ValidXMLEDIParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler

public class ValidXMLEDIParser
extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.EntityResolver, org.xml.sax.ext.LexicalHandler

class builds OBOE objects by parsing input string in valid xml edi format

OBOE - Open Business Objects for EDI

Part of the OBOE Basic Extended Package
An EDI and XML Translator Written In Java
Copyright 1998-2009 - American Coders, LTD - Raleigh NC USA
All rights reserved
American Coders, Ltd
P. O. Box 97462
Raleigh, NC 27624 USA
1-919-846-2014
http://www.americancoders.com

Version:
3.6.0
Author:
Joe McVerry - American Coders, Ltd.

Field Summary
protected  int _iElement
          current element position
protected  int _iLine
          current line number
protected  com.americancoders.edi.CompositeDE composite
          cucurrent comp
protected  com.americancoders.edi.ICompositeDEContainer compositeContainer
          current composite container
protected  java.io.CharArrayWriter contents
          simple string processor
protected  com.americancoders.edi.Table detailTable
          current detail tlb
protected  com.americancoders.edi.DataElement element
          current element
protected  com.americancoders.edi.IDataElementContainer elementContainer
          current de container
protected  int elementCount
          # of elements found
protected  com.americancoders.edi.Table headerTable
          current header tbl
protected  com.americancoders.edi.Loop loop
          current loop
protected  com.americancoders.edi.LoopAndSegmentContainer loopAndSegmentContainer
          current loop container, either table or loop
protected  java.util.Stack loopAndSegmentStack
          stack to handle recursive nature of file
protected  com.americancoders.edi.Envelope parsedEnvelope
          envelope
protected  com.americancoders.edi.FunctionalGroup parsedFunctionalGroup
          functionalGroup
protected  com.americancoders.edi.TemplateTransactionSet parsedTemplateTransactionSet
          templatetransactionset
protected  com.americancoders.edi.TransactionSet parsedTransactionSet
          transactionset
protected  javax.xml.parsers.SAXParser parser
          parser object
protected  com.americancoders.edi.Segment segment
          current seg
protected  com.americancoders.edi.SegmentContainer segmentContainer
          current seg container, either table or loop
protected  com.americancoders.edi.Table summaryTable
          current sum table
protected  com.americancoders.edi.Table table
          current table
protected  com.americancoders.edi.TemplateComposite templateComposite
           
protected  com.americancoders.edi.TemplateSegment templateSegment
           
protected  com.americancoders.edi.TemplateTable templateTable
          current template table
protected  java.lang.String xmlDirectoryPath
           
 
Constructor Summary
ValidXMLEDIParser()
          create a XML EDI parser for valid xml files
 
Method Summary
 void characters(char[] ch, int start, int length)
          Method handles #PCDATA
 void comment(char[] chars, int start, int length)
           
 void endCDATA()
           
 void endDTD()
           
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName)
          Method called by the SAX parser at the
 void endEntity(java.lang.String arg0)
           
 void error(org.xml.sax.SAXParseException e)
          catches error SAXParseExceptions this code causes exception to continue
 void fatalError(org.xml.sax.SAXParseException e)
          catches fatal SAXParseExceptions this code causes exception to continue
 com.americancoders.edi.Envelope getEnvelope()
          returns the envelope that was parsed
 com.americancoders.edi.TransactionSet getTransactionSet()
          returns the last transaction set that was parsed
 void ignorableWhitespace(char[] ch, int start, int length)
          I use this to keep track of line #s
static void main(java.lang.String[] args)
          static main method to test xmlparser class
 void parse(java.lang.String text)
          parse an xml document coming in as a String
 void parseFile(java.lang.String filename)
          parse an xml
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          resolves the DTD file name for the xml parser
 void startCDATA()
           
 void startDTD(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName, org.xml.sax.Attributes attributes)
          method called for each xml element found.
 void startEntity(java.lang.String arg0)
           
 void warning(org.xml.sax.SAXParseException e)
          catches warning SAXParseExceptions this code sends exception to stdio and allows public classto continue
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parsedEnvelope

protected com.americancoders.edi.Envelope parsedEnvelope
envelope


parsedFunctionalGroup

protected com.americancoders.edi.FunctionalGroup parsedFunctionalGroup
functionalGroup


parsedTransactionSet

protected com.americancoders.edi.TransactionSet parsedTransactionSet
transactionset


parsedTemplateTransactionSet

protected com.americancoders.edi.TemplateTransactionSet parsedTemplateTransactionSet
templatetransactionset


_iElement

protected int _iElement
current element position


_iLine

protected int _iLine
current line number


table

protected com.americancoders.edi.Table table
current table


templateTable

protected com.americancoders.edi.TemplateTable templateTable
current template table


headerTable

protected com.americancoders.edi.Table headerTable
current header tbl


detailTable

protected com.americancoders.edi.Table detailTable
current detail tlb


summaryTable

protected com.americancoders.edi.Table summaryTable
current sum table


loop

protected com.americancoders.edi.Loop loop
current loop


segment

protected com.americancoders.edi.Segment segment
current seg


composite

protected com.americancoders.edi.CompositeDE composite
cucurrent comp


element

protected com.americancoders.edi.DataElement element
current element


loopAndSegmentContainer

protected com.americancoders.edi.LoopAndSegmentContainer loopAndSegmentContainer
current loop container, either table or loop


segmentContainer

protected com.americancoders.edi.SegmentContainer segmentContainer
current seg container, either table or loop


compositeContainer

protected com.americancoders.edi.ICompositeDEContainer compositeContainer
current composite container


elementContainer

protected com.americancoders.edi.IDataElementContainer elementContainer
current de container


loopAndSegmentStack

protected java.util.Stack loopAndSegmentStack
stack to handle recursive nature of file


elementCount

protected int elementCount
# of elements found


contents

protected java.io.CharArrayWriter contents
simple string processor


parser

protected javax.xml.parsers.SAXParser parser
parser object


templateSegment

protected com.americancoders.edi.TemplateSegment templateSegment

templateComposite

protected com.americancoders.edi.TemplateComposite templateComposite

xmlDirectoryPath

protected java.lang.String xmlDirectoryPath
Constructor Detail

ValidXMLEDIParser

public ValidXMLEDIParser()
create a XML EDI parser for valid xml files

Method Detail

parse

public void parse(java.lang.String text)
           throws org.xml.sax.SAXException,
                  java.io.FileNotFoundException,
                  java.io.IOException
parse an xml document coming in as a String

Parameters:
text - String xml data
Throws:
org.xml.sax.SAXException
java.io.FileNotFoundException
java.io.IOException

parseFile

public void parseFile(java.lang.String filename)
               throws org.xml.sax.SAXException,
                      java.io.FileNotFoundException,
                      java.io.IOException
parse an xml

Parameters:
filename - String xml file name
Throws:
org.xml.sax.SAXException
java.io.FileNotFoundException
java.io.IOException

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws org.xml.sax.SAXException
resolves the DTD file name for the xml parser

Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Overrides:
resolveEntity in class org.xml.sax.helpers.DefaultHandler
Parameters:
publicId - - String name of xml public id
systemId - - String name of xml system id
Returns:
InputSource the dtd
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String rawName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
method called for each xml element found.
process logic

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - URI of incoming file
localName - String of element's local name
rawName - String of element's raw name
attributes - Vector of the elements attributes
Throws:
org.xml.sax.SAXException - many possible exceptions

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String rawName)
                throws org.xml.sax.SAXException
Method called by the SAX parser at the
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - URI of incoming file
localName - String of element's local name
rawName - String of element's raw name
Throws:
org.xml.sax.SAXException - many possible *

characters

public void characters(char[] ch,
                       int start,
                       int length)
Method handles #PCDATA

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
ch - array
start - position in array where next has been placed
length - int

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
I use this to keep track of line #s

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Overrides:
ignorableWhitespace in class org.xml.sax.helpers.DefaultHandler
Parameters:
ch - char array of found whitespaces
start - int start position in array
length - int length of what's been found

warning

public void warning(org.xml.sax.SAXParseException e)
             throws org.xml.sax.SAXException
catches warning SAXParseExceptions this code sends exception to stdio and allows public classto continue

Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - SaxException object
Throws:
org.xml.sax.SAXException - exception

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXException
catches error SAXParseExceptions this code causes exception to continue

Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - SaxException object
Throws:
org.xml.sax.SAXException - thrown

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXException
catches fatal SAXParseExceptions this code causes exception to continue

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - SAXException object
Throws:
org.xml.sax.SAXException - thrown

startDTD

public void startDTD(java.lang.String arg0,
                     java.lang.String arg1,
                     java.lang.String arg2)
              throws org.xml.sax.SAXException
Specified by:
startDTD in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

endDTD

public void endDTD()
            throws org.xml.sax.SAXException
Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

startEntity

public void startEntity(java.lang.String arg0)
                 throws org.xml.sax.SAXException
Specified by:
startEntity in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

endEntity

public void endEntity(java.lang.String arg0)
               throws org.xml.sax.SAXException
Specified by:
endEntity in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

startCDATA

public void startCDATA()
                throws org.xml.sax.SAXException
Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

endCDATA

public void endCDATA()
              throws org.xml.sax.SAXException
Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

comment

public void comment(char[] chars,
                    int start,
                    int length)
             throws org.xml.sax.SAXException
Specified by:
comment in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

main

public static void main(java.lang.String[] args)
static main method to test xmlparser class

Parameters:
args - String array

getEnvelope

public com.americancoders.edi.Envelope getEnvelope()
returns the envelope that was parsed

Returns:
Envelope - the envelope parsed when parse method was called

getTransactionSet

public com.americancoders.edi.TransactionSet getTransactionSet()
returns the last transaction set that was parsed

Returns:
TransactionSet - the transaction set parsed when parse method was called

Open Business Objects for EDI
v3.6.0


OBOE is a trademark or registered trademark of American Coders, Ltd. in the US and other countries.
Copyright 1999-2004 American Coders, Ltd.
POB 97462
Raleigh NC 27624 USA
All Rights Reserved.