com.ddtek.xmlconverter.adapter.edi
Class EDIConverterException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjava.io.IOException
              extended bycom.ddtek.xmlconverter.exception.ConverterException
                  extended bycom.ddtek.xmlconverter.adapter.edi.EDIConverterException
All Implemented Interfaces:
Serializable

public class EDIConverterException
extends ConverterException

This is a specialized version of ConverterException which contains extra information about the context of errors in EDI files.

When a ConverterException is thrown during the processing of an EDI file, or when a ConverterListener is registered and a warning(), error(), or fatalError() is called, in most cases the exception thrown will be a subclass of ConverterException called EDIConverterException.

This exception contains many methods to delve into the context of the specific error. Both warnings and errors may be recovered from, although fatal errors always will end the processing.

Since:
3.1
See Also:
ConverterException, EDIConverterException, Serialized Form

Constructor Summary
EDIConverterException(String msg)
           
EDIConverterException(String msg, Throwable cause)
           
EDIConverterException(Throwable cause)
           
 
Method Summary
 String getContentData(int element)
          Fetch a specific value from the segment currently being processed.
 String getContentData(int composite, int element)
          Fetch a specific value from the segment currently being processed.
 String getContentData(int composite, int subcomposite, int element)
          Fetch a specific value from the segment currently being processed.
 String getContentData(int composite, int subcomposite, int element, int repeat)
          Fetch a specific value from the segment currently being processed.
 String getControlData(String segment, int element)
          Fetch a specific value from an element of the last-seen control segment of the given name.
 String getControlData(String segment, int composite, int element)
          Fetch a specific value from an element of the last-seen control segment of the given name.
 String getData()
          The value of the element being processed at the time of an error
 String getDialect()
          The major EDI dialect
 String getElement()
          Element name if appropriate, or null.
 int getElementPosition()
          Returns the number of the element relative to the segment.
 int getLine()
          Line number of error, treating each new segment as a new line.
 String getNativeCode()
          Error code relative to EDI dialect
 String getNativeTable()
          Table from which error code for local EDI dialect is drawn.
 int getOffset()
          When available, character offset from the start of the segment.
 int getRepetition()
          Returns the repetition number for the element within the segment.
 String getSegment()
          Name of segment containing error, or null.
 char getSeverity()
          Level of severity of exception
 int getSubElementPosition()
          Returns the number of the element relative to the composite element.
 int getSubSubElementPosition()
          Returns the number of the element relative to the composite element nested within another composite.
 String getTransactionSet()
          Message name/Transaction set number in which the error occurred, or null.
 String getVersion()
          A string of any versions or releases specified in the EDI file.
 
Methods inherited from class com.ddtek.xmlconverter.exception.ConverterException
WrapAsConverterException, WrapAsIOException, WrapAsRuntimeException, WrapAsSAXException, WrapAsSAXParseException, WrapAsTransformerException, WrapAsXMLStreamException
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EDIConverterException

public EDIConverterException(String msg)

EDIConverterException

public EDIConverterException(Throwable cause)

EDIConverterException

public EDIConverterException(String msg,
                             Throwable cause)
Method Detail

getLine

public int getLine()
Line number of error, treating each new segment as a new line.

Returns:
'nth' segment number from start of input stream.

getElementPosition

public int getElementPosition()
Returns the number of the element relative to the segment.

Returns:
Element relative position.

getSubElementPosition

public int getSubElementPosition()
Returns the number of the element relative to the composite element.

Returns:
Element relative position within the composite.

getSubSubElementPosition

public int getSubSubElementPosition()
Returns the number of the element relative to the composite element nested within another composite.

Returns:
Element relative to composite's composite.

getRepetition

public int getRepetition()
Returns the repetition number for the element within the segment.

Returns:
Repetition number.

getOffset

public int getOffset()
When available, character offset from the start of the segment.

Returns:
Character offset from start of segment. This is only available when parsing EDI files, not when going from XML back to EDI.

getElement

public String getElement()
Element name if appropriate, or null.

Returns:
If the error happened within an element, its name, along with its parent(s) if it is inside of a composite, will be in this string.

getSegment

public String getSegment()
Name of segment containing error, or null.

Returns:
If the error happened while processing a specific segment, its name will be returned by this method.

getTransactionSet

public String getTransactionSet()
Message name/Transaction set number in which the error occurred, or null.

Returns:
If an error happened during the processing of a message body, the transaction set number or message name will be returned by this function.

getDialect

public String getDialect()
The major EDI dialect

Returns:
This will be a string such as (but not limited to) EDIFACT, EANCOM, IATA, HL7, or X12.

getSeverity

public char getSeverity()
Level of severity of exception

Returns:
'W' for warning, 'E' for error, 'F' for fatal error that stops the conversion

getData

public String getData()
The value of the element being processed at the time of an error

Returns:
If the error occurred during the processing of a specific element because of the value of the element, the value can be examined via this method.

getVersion

public String getVersion()
A string of any versions or releases specified in the EDI file.

Returns:
This string will contain all of the versions specified in the header and body of the current EDI message or transaction set.

getNativeCode

public String getNativeCode()
Error code relative to EDI dialect

Returns:
If the error has a specific code value in the dialect of EDI, that value is returned by this method.

getNativeTable

public String getNativeTable()
Table from which error code for local EDI dialect is drawn.

Returns:
If there is a table in the native EDI dialect containing the error that just occurred, that table name can be retrieved via this method.

getControlData

public String getControlData(String segment,
                             int element)
Fetch a specific value from an element of the last-seen control segment of the given name.

Parameters:
segment - The name of a control segment, such as ISA or UNB.
element - The element sequence number, one-based.
Returns:
The element content at the specified location, or null if nothing exists there.

getControlData

public String getControlData(String segment,
                             int composite,
                             int element)
Fetch a specific value from an element of the last-seen control segment of the given name.

Parameters:
segment - The name of a control segment, such as ISA or UNB.
composite - The composite element sequence number, one-based.
element - The element number within the above composite.
Returns:
The element content at the specified location, or null if nothing exists there.

getContentData

public String getContentData(int element)
Fetch a specific value from the segment currently being processed.

Parameters:
element - The element sequence number, one-based.
Returns:
The element content at the specified location, or null if nothing exists there.

getContentData

public String getContentData(int composite,
                             int element)
Fetch a specific value from the segment currently being processed.

Parameters:
composite - The composite element sequence number, one-based.
element - The element number within the above composite.
Returns:
The element content at the specified location, or null if nothing exists there.

getContentData

public String getContentData(int composite,
                             int subcomposite,
                             int element)
Fetch a specific value from the segment currently being processed.

Parameters:
composite - The composite element sequence number, one-based.
subcomposite - The sub-composite element sequence number within the above composite.
element - The element number within the above sub-composite.
Returns:
The element content at the specified location, or null if nothing exists there.

getContentData

public String getContentData(int composite,
                             int subcomposite,
                             int element,
                             int repeat)
Fetch a specific value from the segment currently being processed. This method has special properties, in that it can be used to retrieve repeating elements such as often used in HL7. To retrieve a repeating simple element, pass a 0 for the component and subcomponent arguments. To retrieve a repeating complex element, pass a 0 just for the subcomponent argument. Remember that 0 is never a valid value for the repeat argument.

Parameters:
composite - The composite element sequence number, one-based.
subcomposite - The sub-composite element sequence number within the above composite.
element - The element number within the above sub-composite.
repeat - If the outermost element is repeating, the repetition number. This is one-based, since there is always one instance by definition if an element is present.
Returns:
The element content at the specified location, or null if nothing exists there.