com.berryworks.edireader
Class EDIAbstractReader

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

public abstract class EDIAbstractReader
extends java.lang.Object
implements org.xml.sax.XMLReader

An adaptor for XMLReader providing default implementations of several methods to simplify each of the EDIReader classes that have XMLReader as an ancestor.


Constructor Summary
EDIAbstractReader()
           
 
Method Summary
static java.lang.String emptyStringIfNull(java.lang.String value)
          Return the String argument unless that argument is null, in which case an empty String is returned instead.
 SyntaxDescriptor getAcknowledgmentSyntaxDescriptor()
           
 com.berryworks.edireader.util.BranchingWriter getAckStream()
           
 int getCharCount()
           
 org.xml.sax.ContentHandler getContentHandler()
           
 char getDecimalMark()
          Gets the character used as the decimal point in currency.
 char getDelimiter()
          Gets the character marking the boundary between fields
 EDIAttributes getDocumentAttributes()
           
 org.xml.sax.DTDHandler getDTDHandler()
           
 org.xml.sax.EntityResolver getEntityResolver()
           
 org.xml.sax.ErrorHandler getErrorHandler()
           
 boolean getFeature(java.lang.String name)
           
 java.lang.String getFirstSegment()
           
 EDIAttributes getGroupAttributes()
           
 EDIAttributes getInterchangeAttributes()
           
 java.lang.Object getProperty(java.lang.String name)
           
 int getRelease()
          Gets the character used in release/escape sequences.
 char getReleaseCharacter()
           
 char getRepetitionSeparator()
          Gets the character marking the boundary between repeating fields.
 int getSegmentCharCount()
           
 char getSubDelimiter()
          Gets the character marking the boundary between sub-fields.
 char getSubSubDelimiter()
          Gets the character marking the boundary between sub-sub-fields.
 com.berryworks.edireader.error.EDISyntaxExceptionHandler getSyntaxExceptionHandler()
           
 char getTerminator()
          Gets the character marking the boundary between segments
 java.lang.String getTerminatorSuffix()
          Gets the short String of 'whitespace' characters that follows the terminator.
 com.berryworks.edireader.tokenizer.Tokenizer getTokenizer()
           
 TransactionCallback getTransactionCallback()
           
 boolean isExternalXmlDocumentStart()
           
 boolean isInterchangeAcknowledgment()
           
 boolean isNamespaceEnabled()
           
static boolean isPresent(java.lang.String value)
          Determine if a String argument is null and not empty.
 boolean isPreviewed()
           
 boolean isReleaseCharacterDefined()
           
 void parse(java.lang.String systemId)
          Parse the EDI interchange.
abstract  void preview()
          Preview the EDI interchange to discover syntactic details that will be useful to know before the actual parse method is called.
 void setAcknowledgment(java.io.Writer writer)
          Indicate that functional acknowledgments are to be generated by designating a Writer.
 void setAcknowledgment(java.io.Writer writer, SyntaxDescriptor syntaxDescriptor)
           
 void setAcknowledgmentSyntaxDescriptor(SyntaxDescriptor syntaxDescriptor)
           
 void setAckStream(com.berryworks.edireader.util.BranchingWriter ackStream)
           
 void setContentHandler(org.xml.sax.ContentHandler handler)
           
 void setCopyWriter(java.io.Writer writer)
           
 void setDecimalMark(char decimalMark)
           
 void setDelimiter(char delimiter)
           
 void setDTDHandler(org.xml.sax.DTDHandler handler)
           
 void setEntityResolver(org.xml.sax.EntityResolver resolver)
           
 void setErrorHandler(org.xml.sax.ErrorHandler handler)
           
 void setExternalXmlDocumentStart(boolean externalXmlDocumentStart)
           
 void setFeature(java.lang.String name, boolean value)
           
 void setFirstSegment(java.lang.String firstSegment)
           
 void setInterchangeAcknowledgment(boolean interchangeAcknowledgment)
           
 void setLocale(java.util.Locale locale)
           
 void setNamespaceEnabled(boolean namespaceEnabled)
           
 void setPreviewed(boolean previewed)
           
 void setProperty(java.lang.String name, java.lang.Object value)
           
 void setRelease(int release)
           
 void setRepetitionSeparator(char repetitionSeparator)
           
 void setSubDelimiter(char subDelimiter)
           
 void setSubSubDelimiter(char subSubDelimiter)
           
 void setSyntaxExceptionHandler(com.berryworks.edireader.error.EDISyntaxExceptionHandler syntaxExceptionHandler)
           
 void setTerminator(char terminator)
           
 void setTerminatorSuffix(java.lang.String terminatorSuffix)
           
 void setTokenizer(com.berryworks.edireader.tokenizer.Tokenizer t)
           
 void setTransactionCallback(TransactionCallback transactionCallback)
           
 java.lang.String toString()
           
static void trace(java.lang.String msg)
          Write a message to a diagnostic trace stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xml.sax.XMLReader
parse
 

Constructor Detail

EDIAbstractReader

public EDIAbstractReader()
Method Detail

getTerminator

public char getTerminator()
Gets the character marking the boundary between segments

Returns:
The terminator value

getTerminatorSuffix

public java.lang.String getTerminatorSuffix()
Gets the short String of 'whitespace' characters that follows the terminator.

Returns:
The terminator value

setDelimiter

public void setDelimiter(char delimiter)

setSubDelimiter

public void setSubDelimiter(char subDelimiter)

setSubSubDelimiter

public void setSubSubDelimiter(char subSubDelimiter)

setDecimalMark

public void setDecimalMark(char decimalMark)

setRepetitionSeparator

public void setRepetitionSeparator(char repetitionSeparator)

setTerminator

public void setTerminator(char terminator)

setRelease

public void setRelease(int release)

setTerminatorSuffix

public void setTerminatorSuffix(java.lang.String terminatorSuffix)

getDelimiter

public char getDelimiter()
Gets the character marking the boundary between fields

Returns:
The delimiter value

getSubDelimiter

public char getSubDelimiter()
Gets the character marking the boundary between sub-fields. Subfields may be called by different names in different EDI standards.

Returns:
The subDelimiter value

getRelease

public int getRelease()
Gets the character used in release/escape sequences. Exactly how this character is used may differ between standards. In ANSI, there is no release mechanism. When no release character is available, the int value -1 is returned, otherwise a char value is returned via the int.

Returns:
The release char value or -1 if none

getReleaseCharacter

public char getReleaseCharacter()

isReleaseCharacterDefined

public boolean isReleaseCharacterDefined()

getDecimalMark

public char getDecimalMark()
Gets the character used as the decimal point in currency. This is the period (".") in the USA and many other countries, but can also be the comma (",").

Returns:
mark

getSubSubDelimiter

public char getSubSubDelimiter()
Gets the character marking the boundary between sub-sub-fields. Sub-sub-fields are not used in ANSI or EDIFACT, but appear in HL7.

Returns:
The subSubDelimiter value

getRepetitionSeparator

public char getRepetitionSeparator()
Gets the character marking the boundary between repeating fields.

Returns:
The repetitionSeparator value

getTokenizer

public com.berryworks.edireader.tokenizer.Tokenizer getTokenizer()

setTokenizer

public void setTokenizer(com.berryworks.edireader.tokenizer.Tokenizer t)

setCopyWriter

public void setCopyWriter(java.io.Writer writer)

preview

public abstract void preview()
                      throws EDISyntaxException,
                             java.io.IOException
Preview the EDI interchange to discover syntactic details that will be useful to know before the actual parse method is called.

Throws:
java.io.IOException - for problem reading EDI data
EDISyntaxException - if invalid EDI is detected

setAcknowledgment

public void setAcknowledgment(java.io.Writer writer)
Indicate that functional acknowledgments are to be generated by designating a Writer. This method should be called before calling parse() if acknowledgments are desired.

Parameters:
writer - The new acknowledgment value

setAcknowledgment

public void setAcknowledgment(java.io.Writer writer,
                              SyntaxDescriptor syntaxDescriptor)

isInterchangeAcknowledgment

public boolean isInterchangeAcknowledgment()

setInterchangeAcknowledgment

public void setInterchangeAcknowledgment(boolean interchangeAcknowledgment)

getAcknowledgmentSyntaxDescriptor

public SyntaxDescriptor getAcknowledgmentSyntaxDescriptor()

setAcknowledgmentSyntaxDescriptor

public void setAcknowledgmentSyntaxDescriptor(SyntaxDescriptor syntaxDescriptor)

getTransactionCallback

public TransactionCallback getTransactionCallback()

setTransactionCallback

public void setTransactionCallback(TransactionCallback transactionCallback)

getSyntaxExceptionHandler

public com.berryworks.edireader.error.EDISyntaxExceptionHandler getSyntaxExceptionHandler()

setSyntaxExceptionHandler

public void setSyntaxExceptionHandler(com.berryworks.edireader.error.EDISyntaxExceptionHandler syntaxExceptionHandler)

isNamespaceEnabled

public boolean isNamespaceEnabled()

setNamespaceEnabled

public void setNamespaceEnabled(boolean namespaceEnabled)

isExternalXmlDocumentStart

public boolean isExternalXmlDocumentStart()

setExternalXmlDocumentStart

public void setExternalXmlDocumentStart(boolean externalXmlDocumentStart)

setLocale

public void setLocale(java.util.Locale locale)
               throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver resolver)
Specified by:
setEntityResolver in interface org.xml.sax.XMLReader

setDTDHandler

public void setDTDHandler(org.xml.sax.DTDHandler handler)
Specified by:
setDTDHandler in interface org.xml.sax.XMLReader

setErrorHandler

public void setErrorHandler(org.xml.sax.ErrorHandler handler)
Specified by:
setErrorHandler in interface org.xml.sax.XMLReader

parse

public void parse(java.lang.String systemId)
           throws org.xml.sax.SAXException,
                  java.io.IOException
Parse the EDI interchange. Each subclass must override this method.

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

setContentHandler

public void setContentHandler(org.xml.sax.ContentHandler handler)
Specified by:
setContentHandler in interface org.xml.sax.XMLReader

getContentHandler

public org.xml.sax.ContentHandler getContentHandler()
Specified by:
getContentHandler in interface org.xml.sax.XMLReader

setFeature

public void setFeature(java.lang.String name,
                       boolean value)
                throws org.xml.sax.SAXNotRecognizedException,
                       org.xml.sax.SAXNotSupportedException
Specified by:
setFeature in interface org.xml.sax.XMLReader
Throws:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException

getFeature

public boolean getFeature(java.lang.String name)
                   throws org.xml.sax.SAXNotRecognizedException,
                          org.xml.sax.SAXNotSupportedException
Specified by:
getFeature in interface org.xml.sax.XMLReader
Throws:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
                 throws org.xml.sax.SAXNotRecognizedException,
                        org.xml.sax.SAXNotSupportedException
Specified by:
setProperty in interface org.xml.sax.XMLReader
Throws:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException

getProperty

public java.lang.Object getProperty(java.lang.String name)
                             throws org.xml.sax.SAXNotRecognizedException,
                                    org.xml.sax.SAXNotSupportedException
Specified by:
getProperty in interface org.xml.sax.XMLReader
Throws:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException

getDocumentAttributes

public EDIAttributes getDocumentAttributes()

getInterchangeAttributes

public EDIAttributes getInterchangeAttributes()

getGroupAttributes

public EDIAttributes getGroupAttributes()

getAckStream

public com.berryworks.edireader.util.BranchingWriter getAckStream()

setAckStream

public void setAckStream(com.berryworks.edireader.util.BranchingWriter ackStream)

isPreviewed

public boolean isPreviewed()

setPreviewed

public void setPreviewed(boolean previewed)

getErrorHandler

public org.xml.sax.ErrorHandler getErrorHandler()
Specified by:
getErrorHandler in interface org.xml.sax.XMLReader

getDTDHandler

public org.xml.sax.DTDHandler getDTDHandler()
Specified by:
getDTDHandler in interface org.xml.sax.XMLReader

getEntityResolver

public org.xml.sax.EntityResolver getEntityResolver()
Specified by:
getEntityResolver in interface org.xml.sax.XMLReader

getCharCount

public int getCharCount()

getSegmentCharCount

public int getSegmentCharCount()

getFirstSegment

public java.lang.String getFirstSegment()

setFirstSegment

public void setFirstSegment(java.lang.String firstSegment)

trace

public static void trace(java.lang.String msg)
Write a message to a diagnostic trace stream.

Parameters:
msg - to appear in trace

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isPresent

public static boolean isPresent(java.lang.String value)
Determine if a String argument is null and not empty.

Parameters:
value -
Returns:
false if the argument is null or empty, and true otherwise

emptyStringIfNull

public static java.lang.String emptyStringIfNull(java.lang.String value)
Return the String argument unless that argument is null, in which case an empty String is returned instead.

Parameters:
value -
Returns:
value, but "" if the value is null