Open Business Objects for EDI
v3.6.0

com.americancoders.edi
Class EnvelopeFactory

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--com.americancoders.edi.EnvelopeFactory
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 EnvelopeFactory
extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.EntityResolver, org.xml.sax.ext.LexicalHandler, org.xml.sax.ContentHandler

class for building an Envelope from an edi xml file this is a subclass of the SAX2 handler
Class contains a main method to allow it to be invoked as an application.
format: java com.americancoders.edi.EnvelopeFactory xmlfilename,
where xmlfilename is a xml file based on envelopeRules.dtd.
OBOE - Open Business Objects for EDI
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 number
protected  int _iLine
          current line number
protected  java.io.CharArrayWriter contents
          simple string processor
protected  com.americancoders.edi.TemplateComposite currentCompositeDE
          current composite
protected  com.americancoders.edi.TemplateDE currentDataElement
          current element
protected  com.americancoders.edi.TemplateEnvelope currentEnvelope
          current envelope
protected  com.americancoders.edi.TemplateFunctionalGroup currentFG
          current functionalGroup
protected  java.lang.String currentID
          current id string
protected  com.americancoders.edi.IDList currentIDList
          current list of ids
protected  com.americancoders.edi.IDListProcessor currentIDListProcessor
          idList Processor
protected  java.lang.String currentLoopID
          loop id - may not be used in future
protected  java.util.Stack currentSegContainerStack
          stack, since segments can be held by table and segments and datalements by segments and composites we keep track of container depth through a stack
protected  com.americancoders.edi.TemplateSegment currentTemplateSegment
          current segment
protected  com.americancoders.edi.TemplateSegmentContainer currentTemplateSegmentContainer
          current container for segments
protected  java.lang.String idCode
          idcode value since idcode appears before idvalue save it
protected  com.americancoders.edi.IDList idlist
           
protected  java.lang.String idListFile
          current idListFile name
protected  com.americancoders.edi.IDListParser idListParser
          current IDList parser object
protected  java.util.Hashtable idLists
          list of IDs
protected  java.lang.String knowSystemID
          file name being parsed
protected  java.lang.String nameOrID
          default name
protected  java.lang.String xmlDirectoryPath
          directory path for xml file
 
Constructor Summary
EnvelopeFactory()
          construct the factory with a xml parser
 
Method Summary
static com.americancoders.edi.TemplateEnvelope buildEnvelope(java.lang.String inFileName)
          Deprecated. use buildEnvelope(String, String)
static com.americancoders.edi.TemplateEnvelope buildEnvelope(java.lang.String inFileName, java.lang.String version)
          static class method will build a envelope based on input string and OBOE.properties defintion see OBOE.properties file to define the directory path
 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
 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 class used for testing
Class contains a main method to allow it to invoked as an application.
 void parse(org.xml.sax.InputSource is)
          method to call parser with an InputSource argument
 void parse(java.lang.String is)
          method to call parser with a String argument
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          resolves the DTD file name for the xerces parser
 com.americancoders.edi.TemplateDE setDataElement(int pos, org.xml.sax.Attributes attributes)
          method to build a template data element
made static in release 2.5.0
 void setDocumentLocator(org.xml.sax.Locator locator)
           
 com.americancoders.edi.TemplateComposite setTemplateComposite(int pos, org.xml.sax.Attributes attributes)
          method to build a template composite
made static in release 2.5.0
 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, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
endDocument, endPrefixMapping, processingInstruction, skippedEntity, startDocument, startPrefixMapping
 

Field Detail

_iElement

protected int _iElement
current element number


_iLine

protected int _iLine
current line number


currentEnvelope

protected com.americancoders.edi.TemplateEnvelope currentEnvelope
current envelope


currentFG

protected com.americancoders.edi.TemplateFunctionalGroup currentFG
current functionalGroup


currentTemplateSegmentContainer

protected com.americancoders.edi.TemplateSegmentContainer currentTemplateSegmentContainer
current container for segments


currentTemplateSegment

protected com.americancoders.edi.TemplateSegment currentTemplateSegment
current segment


currentCompositeDE

protected com.americancoders.edi.TemplateComposite currentCompositeDE
current composite


currentDataElement

protected com.americancoders.edi.TemplateDE currentDataElement
current element


currentLoopID

protected java.lang.String currentLoopID
loop id - may not be used in future


currentID

protected java.lang.String currentID
current id string


contents

protected java.io.CharArrayWriter contents
simple string processor


idListFile

protected java.lang.String idListFile
current idListFile name


currentIDListProcessor

protected com.americancoders.edi.IDListProcessor currentIDListProcessor
idList Processor


idlist

protected com.americancoders.edi.IDList idlist

idCode

protected java.lang.String idCode
idcode value since idcode appears before idvalue save it


idListParser

protected com.americancoders.edi.IDListParser idListParser
current IDList parser object


idLists

protected java.util.Hashtable idLists
list of IDs


currentIDList

protected com.americancoders.edi.IDList currentIDList
current list of ids


xmlDirectoryPath

protected java.lang.String xmlDirectoryPath
directory path for xml file


nameOrID

protected java.lang.String nameOrID
default name


currentSegContainerStack

protected java.util.Stack currentSegContainerStack
stack, since segments can be held by table and segments and datalements by segments and composites we keep track of container depth through a stack


knowSystemID

protected java.lang.String knowSystemID
file name being parsed

Constructor Detail

EnvelopeFactory

public EnvelopeFactory()
                throws java.lang.Exception
construct the factory with a xml parser

Throws:
java.lang.Exception - an xml parser exception
Method Detail

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Overrides:
setDocumentLocator in class org.xml.sax.helpers.DefaultHandler

parse

public void parse(org.xml.sax.InputSource is)
           throws java.lang.Exception
method to call parser with an InputSource argument

Parameters:
is - InputSource
Throws:
java.lang.Exception - an xml parser exception

parse

public void parse(java.lang.String is)
           throws java.lang.Exception
method to call parser with a String argument

Parameters:
is - String of xml data
Throws:
java.lang.Exception - an xml parser exception

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 xerces 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

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

setTemplateComposite

public com.americancoders.edi.TemplateComposite setTemplateComposite(int pos,
                                                                     org.xml.sax.Attributes attributes)
                                                              throws org.xml.sax.SAXException
method to build a template composite
made static in release 2.5.0

Parameters:
pos - int position within segment
attributes - SAX2 attributes
Returns:
TemplateComposite template composite
Throws:
org.xml.sax.SAXException - SAX errors

setDataElement

public com.americancoders.edi.TemplateDE setDataElement(int pos,
                                                        org.xml.sax.Attributes attributes)
                                                 throws org.xml.sax.SAXException
method to build a template data element
made static in release 2.5.0

Parameters:
pos - position within segment or composite
attributes - SAX2 attributes
Returns:
TemplateDE template data element
Throws:
org.xml.sax.SAXException - SAX errors

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

buildEnvelope

public static com.americancoders.edi.TemplateEnvelope buildEnvelope(java.lang.String inFileName)
                                                             throws OBOEException
Deprecated. use buildEnvelope(String, String)

static class method will build a envelope based on input string and OBOE.properties defintion see OBOE.properties file to define the directory path

Parameters:
inFileName - String without the path or xml file extension
Returns:
TemplatesEnvelope
Throws:
OBOEException - io error most likely

buildEnvelope

public static com.americancoders.edi.TemplateEnvelope buildEnvelope(java.lang.String inFileName,
                                                                    java.lang.String version)
static class method will build a envelope based on input string and OBOE.properties defintion see OBOE.properties file to define the directory path

Parameters:
inFileName - String without the path or xml file extension
version - String specifies subpath to find version specific envelope rules files
Returns:
TemplateEnvelope
Throws:
OBOEException - io error most likely

main

public static void main(java.lang.String[] args)
static main class used for testing
Class contains a main method to allow it to invoked as an application.
format: java com.americancoders.edi.EnvelopeFactory

Parameters:
args - String array

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.