com.berryworks.edireader
Class EDIReader

java.lang.Object
  extended by com.berryworks.edireader.EDIAbstractReader
      extended by com.berryworks.edireader.EDIReader
All Implemented Interfaces:
com.berryworks.edireader.error.ErrorMessages, org.xml.sax.XMLReader
Direct Known Subclasses:
EDIReaderWrapper, StandardReader

public class EDIReader
extends EDIAbstractReader
implements com.berryworks.edireader.error.ErrorMessages

Reads and parses an EDI interchange in any of the supported EDI standards. Once a specific EDI standard is identified, EDIReader delegates the actual parsing to a subclass of EDIReader that it creates. This delegation technique allows an application to use EDIReader just as it would an XMLReader and without having to configure or otherwise signal for a particular standard to be used. Another advantage of this approach is that it provides a framework for additional EDIReader subclasses to be developed and integrated with little impact.


Field Summary
static boolean debug
          If debug is set to true, then a parser may emit diagnostic information to System.err
 
Fields inherited from interface com.berryworks.edireader.error.ErrorMessages
CONTROL_NUMBER_GE, CONTROL_NUMBER_IEA, CONTROL_NUMBER_SE, CONTROL_NUMBER_UNT, CONTROL_NUMBER_UNZ, COUNT_GE, COUNT_IEA, COUNT_SE, COUNT_UNT, COUNT_UNZ, DIGITS_ONLY, ELEMENT_TOO_LONG, EXPECTED_SIMPLE_TOKEN, FIRST_SEGMENT_MUST_BE_UNA_OR_UNB, INCOMPLETE_ACH_MESSAGE, INCOMPLETE_HL7_MESSAGE, INCOMPLETE_X12, INTERNAL_ERROR_MULTIPLE_EOFS, INTERNAL_ERROR_MULTIPLE_PREVIEWS, INVALID_BEGINNING_OF_SEGMENT, INVALID_COMPOSITE, INVALID_SEGMENT_TERMINATOR, INVALID_UNA, ISA_FIELD_WIDTH, ISA_SEGMENT_HAS_TOO_FEW_FIELDS, MALFORMED_EDI_SEGMENT, MANDATORY_ELEMENT_MISSING, MISMATCHED_PACKAGE_REF, MISMATCHED_UNP_LENGTH, MISSING_UNO_LENGTH, MISSING_UNP, NO_HL7_PARSER, NO_STANDARD_BEGINS_WITH, TOO_MANY_ISA_FIELDS, UNEXPECTED_EOF, UNEXPECTED_SEGMENT_IN_CONTEXT, X12_MISSING_ISA
 
Constructor Summary
EDIReader()
           
 
Method Summary
 XMLTags getXMLTags()
           
 void parse(org.xml.sax.InputSource source)
          Parse an EDI interchange from the input source.
 void preview()
          Read enough of the EDI interchange to establish which characters are used for segment terminators, element delimiters, etc.
static void setDebug(boolean d)
          Sets debug on or off.
 void setXMLTags(XMLTags tags)
           
 
Methods inherited from class com.berryworks.edireader.EDIAbstractReader
emptyStringIfNull, getAcknowledgmentSyntaxDescriptor, getAckStream, getCharCount, getContentHandler, getDecimalMark, getDelimiter, getDocumentAttributes, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getFirstSegment, getGroupAttributes, getInterchangeAttributes, getProperty, getRelease, getReleaseCharacter, getRepetitionSeparator, getSegmentCharCount, getSubDelimiter, getSubSubDelimiter, getSyntaxExceptionHandler, getTerminator, getTerminatorSuffix, getTokenizer, getTransactionCallback, isExternalXmlDocumentStart, isInterchangeAcknowledgment, isNamespaceEnabled, isPresent, isPreviewed, isReleaseCharacterDefined, parse, setAcknowledgment, setAcknowledgment, setAcknowledgmentSyntaxDescriptor, setAckStream, setContentHandler, setCopyWriter, setDecimalMark, setDelimiter, setDTDHandler, setEntityResolver, setErrorHandler, setExternalXmlDocumentStart, setFeature, setFirstSegment, setInterchangeAcknowledgment, setLocale, setNamespaceEnabled, setPreviewed, setProperty, setRelease, setRepetitionSeparator, setSubDelimiter, setSubSubDelimiter, setSyntaxExceptionHandler, setTerminator, setTerminatorSuffix, setTokenizer, setTransactionCallback, toString, trace
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static boolean debug
If debug is set to true, then a parser may emit diagnostic information to System.err

Constructor Detail

EDIReader

public EDIReader()
Method Detail

preview

public void preview()
             throws EDISyntaxException,
                    java.io.IOException
Read enough of the EDI interchange to establish which characters are used for segment terminators, element delimiters, etc. Each subclass of EDIReader overrides this method with logic specific to a particular EDI standard. Upon return, the input stream has been re-positioned so that the interchange will be parsed from the beginning by parse().

Specified by:
preview in class EDIAbstractReader
Throws:
EDISyntaxException - if invalid EDI is detected
java.io.IOException - for problem reading EDI data

parse

public void parse(org.xml.sax.InputSource source)
           throws org.xml.sax.SAXException,
                  java.io.IOException
Parse an EDI interchange from the input source.

Specified by:
parse in interface org.xml.sax.XMLReader
Throws:
org.xml.sax.SAXException
java.io.IOException

setXMLTags

public void setXMLTags(XMLTags tags)

getXMLTags

public XMLTags getXMLTags()

setDebug

public static void setDebug(boolean d)
Sets debug on or off.

Parameters:
d - true to turn debug on, false to turn it off