com.ddtek.xmlconverter.adapter.edi
Class EDIConverterException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.io.IOException
              extended by com.ddtek.xmlconverter.exception.ConverterException
                  extended by com.ddtek.xmlconverter.adapter.edi.EDIConverterException
All Implemented Interfaces:
com.ddtek.xmlconverter.adapter.edi.EDIErrorDetails, com.ddtek.xmlconverter.adapter.edi.EDISegmentLocator, 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 an instance of 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

Field Summary
 
Fields inherited from class com.ddtek.xmlconverter.exception.ConverterException
m_errorCode
 
Constructor Summary
 
Method Summary
 String getCodeListVersion()
          If there is a version of the codelists that is in context for the current segment, this returns that version.
 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 getControllingAgency()
          This is the controlling agency.
 String getData()
          The value of the element being processed at the time of an error
 int getDataLine()
          Data line number, counting line termination sequences instead of segments.
 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.
 String getHeaderVersion()
          If the header has the potential to be versioned differently than the payload, as for example EDIFACT and X12 allow, then this returns the version of the header.
 int getInvalidCharacter()
          Return the invalid character which caused this exception.
 int getLine()
          Line number of error, treating each new segment as a new line.
 String getLoopName()
          Name of loop containing error, or null.
 String getMessageRelease()
          This is the release of the current message or transaction set.
 String getMessageVersion()
          This is the version of the current message or transaction set.
 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.
 int getSegmentNumber()
           
 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 getSyntaxLevel()
          For EDI dialects such as EDIFACT which have different levels of syntax support, the major version, such as 1, 2, 3 or 4, are returned by this method.
 String getSyntaxRelease()
          For EDI dialects such as EDIFACT which have different levels of syntax support, the minor version if specified.
 String getSystemVersion()
          If there is a version of the codelists that is in context for the most recently seen header segment.
 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
getErrorCode, isNestedFatalException, reportedToListener, setErrorCode, setNestedFatalException, setReportedToListener, simpleElement, UnwrapInstantiationException, WrapAsConverterException, WrapAsEDIConverterException, WrapAsInternalConverterError, 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
 
Methods inherited from interface com.ddtek.xmlconverter.adapter.edi.EDIErrorDetails
getMessage
 

Constructor Detail
Method Detail

getLine

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

Specified by:
getLine in interface com.ddtek.xmlconverter.adapter.edi.EDIErrorDetails
Overrides:
getLine in class ConverterException
Returns:
'nth' segment number from start of input stream.

getSegmentNumber

public int getSegmentNumber()
Specified by:
getSegmentNumber in interface com.ddtek.xmlconverter.adapter.edi.EDISegmentLocator
Overrides:
getSegmentNumber in class ConverterException

getDataLine

public int getDataLine()
Data line number, counting line termination sequences instead of segments.

Specified by:
getDataLine in interface com.ddtek.xmlconverter.adapter.edi.EDISegmentLocator
Overrides:
getDataLine in class ConverterException
Returns:
'nth' data line starting from the start of the 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.

Specified by:
getOffset in interface com.ddtek.xmlconverter.adapter.edi.EDIErrorDetails
Overrides:
getOffset in class ConverterException
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.

Specified by:
getSegment in interface com.ddtek.xmlconverter.adapter.edi.EDISegmentLocator
Overrides:
getSegment in class ConverterException
Returns:
If the error happened while processing a specific segment, its name will be returned by this method.

getLoopName

public String getLoopName()
Name of loop containing error, or null.

Returns:
If the error happened while processing a segment within a loop, the loop name 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. This data is volatile and does not persist after this exception, so it should be recorded elsewhere if needed.

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. This data is volatile and does not persist after this exception, so it should be recorded elsewhere if needed.

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 its index in the composite parameter and pass a 0 for the subcomposite and element arguments. To retrieve a repeating complex element, pass its index and sub-index in the composite and subcomposite parameters, and pass a 0 for the element argument. Remember that 0 is never a valid value for the repeat argument.

Parameters:
composite - The top level sequence number, one-based.
subcomposite - The second level sequence number, or 0 if not needed.
element - The third level sequence number, or 0 if not needed.
repeat - The repetition number of the top level element, one-based.
Returns:
The element content at the specified location, or null if nothing exists there.

getSyntaxLevel

public String getSyntaxLevel()
For EDI dialects such as EDIFACT which have different levels of syntax support, the major version, such as 1, 2, 3 or 4, are returned by this method.

Returns:
Syntax level of active message if supported, or null if not supported or not in context yet of message.
See Also:
EDISegmentDetails.getSyntaxLevel()

getSyntaxRelease

public String getSyntaxRelease()
For EDI dialects such as EDIFACT which have different levels of syntax support, the minor version if specified.

Returns:
Syntax release of active message if supported, or null if not supported, not supplied, or not in context yet of message.
See Also:
EDISegmentDetails.getSyntaxRelease()

getMessageVersion

public String getMessageVersion()
This is the version of the current message or transaction set. In EDIFACT-based dialects, both getMessageVersion() and getMessageRelease() are used. In X12-based ones, getMessageRelease() holds the transaction set version number. In HL7, getMessageVersion() reports the message version.

Returns:
Message version, or null.
See Also:
EDISegmentDetails.getMessageVersion()

getMessageRelease

public String getMessageRelease()
This is the release of the current message or transaction set. In EDIFACT-based dialects, both getMessageVersion() and getMessageRelease() are used. In X12-based ones, getMessageRelease() holds the transaction set version number. In HL7, getMessageVersion() reports the message version.

Returns:
Message release, or null.
See Also:
EDISegmentDetails.getMessageRelease()

getCodeListVersion

public String getCodeListVersion()
If there is a version of the codelists that is in context for the current segment, this returns that version. Any validation or lookup of descriptions has been done against the codelist version specified here.

Returns:
The active codelist version for the current segment, or null.
See Also:
EDISegmentDetails.getCodeListVersion()

getSystemVersion

public String getSystemVersion()
If there is a version of the codelists that is in context for the most recently seen header segment. For example, EDIFACT allows in the de0110 element for the header to have a specific codelist version, and this would apply to UNS segments even in the message body.

Returns:
The active codelist version for the current segment, or null.
See Also:
EDISegmentDetails.getSystemVersion()

getHeaderVersion

public String getHeaderVersion()
If the header has the potential to be versioned differently than the payload, as for example EDIFACT and X12 allow, then this returns the version of the header.

Returns:
The version of the EDI header or null if not appropriate or no header in context.
See Also:
EDISegmentDetails.getHeaderVersion()

getControllingAgency

public String getControllingAgency()
This is the controlling agency.

For X12, this is the full version number as specified in GS08, since the getMessageRelease() is set to the normalized six-digit version number. This way, user applications can query this field to get any 'X' suffix or extended version numbering for local dialects like HIPAA.

For EDIFACT, this comes from the UNH0204 or UIH0105 elements.

Returns:
The controlling agency as specified in the EDI header if supported, supplied and in context, or else null.
See Also:
EDISegmentDetails.getControllingAgency()

getInvalidCharacter

public int getInvalidCharacter()
Return the invalid character which caused this exception. If the exception was not caused by an invalid character, this method returns -1.