java.lang.Object
io.xlate.edi.stream.PropertySupport
io.xlate.edi.stream.EDIInputFactory
Defines an abstract implementation of a factory for getting EDIStreamReaders,
JSON parsers (wrapping an existing EDIStreamReader), and XMLStreamReaders
(wrapping an existing EDIStreamReader). An EDIInputErrorReporter may also be
configured via the factory for use with each new EDIStreamReader created.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.static final StringWhen set to true, non-graphical, control characters will be ignored in the EDI input stream.static final StringWhen set to true, hierarchical loops will be nested in the EDI input stream.static final StringWhen set to false, enumerated code values of control structure elements will be ignore.static final StringWhen set to false, control structures, segments, elements, and codes will not be validated unless a user-provided control schema has been set usingEDIStreamReader.setControlSchema(Schema).static final StringWhen set to true, simple data elements not containing data will be represented via the JSON parsers as anullvalue.static final StringWhen set to true, simple data elements will be represented via the JSON parsers as JSON objects.static final StringWhen set to true, XMLStreamReader instances created from an EDIInputFactory will generate XMLNS attributes on the TRANSACTION element in addition to the INTERCHANGE element.static final StringWhen set to true, the XML elements representing segments in an EDI implementation schema will be named according to the schema-definedcodeattribute for the segment.static final StringWhen set to true, XMLStreamReader instances created from an EDIInputFactory will generate an element wrapper around the transaction's content element.Fields inherited from class io.xlate.edi.stream.PropertySupport
properties, supportedProperties -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract EDIStreamReadercreateEDIStreamReader(InputStream stream) Creates a newEDIStreamReaderusing the givenInputStream(with default encoding).abstract EDIStreamReadercreateEDIStreamReader(InputStream stream, Schema schema) Creates a newEDIStreamReaderusing the givenInputStream(with default encoding) which uses theSchemafor validation of the input's control structures (interchange, group, transaction).abstract EDIStreamReadercreateEDIStreamReader(InputStream stream, String encoding) Creates a newEDIStreamReaderusing the givenInputStreamand encoding.abstract EDIStreamReadercreateEDIStreamReader(InputStream stream, String encoding, Schema schema) Creates a newEDIStreamReaderusing the givenInputStreamand encoding which uses theSchemafor validation of the input's control structures (interchange, group, transaction).abstract EDIStreamReadercreateFilteredReader(EDIStreamReader reader, EDIStreamFilter filter) Creates a newEDIStreamReaderby wrapping the given reader with theEDIStreamFilterfilter.abstract <J> JcreateJsonParser(EDIStreamReader reader, Class<J> type) Creates a new JSON parser of typeJthat uses the given reader as its data source.abstract XMLStreamReadercreateXMLStreamReader(EDIStreamReader reader) Creates a newXMLStreamReaderthat uses the given reader as its data source.abstract EDIReporterDeprecated.usegetErrorReporter()insteadabstract EDIInputErrorReporterRetrieves the reporter that will be set on any EDIStreamReader created by this factory instance.static EDIInputFactoryCreate a new instance of the factory.abstract voidsetEDIReporter(EDIReporter reporter) Deprecated.usesetErrorReporter(EDIInputErrorReporter)insteadabstract voidsetErrorReporter(EDIInputErrorReporter reporter) The reporter that will be set on any EDIStreamReader created by this factory instance.Methods inherited from class io.xlate.edi.stream.PropertySupport
getProperty, isPropertySupported, setProperty
-
Field Details
-
EDI_VALIDATE_CONTROL_STRUCTURE
When set to false, control structures, segments, elements, and codes will not be validated unless a user-provided control schema has been set usingEDIStreamReader.setControlSchema(Schema). When set to true AND no user-provided control schema has been set, the reader will attempt to find a known control schema for the detected EDI dialect and version to be used for control structure validation. Default value: true- See Also:
-
EDI_VALIDATE_CONTROL_CODE_VALUES
When set to false, enumerated code values of control structure elements will be ignore. Element size and type validation will still occur.- See Also:
-
XML_DECLARE_TRANSACTION_XMLNS
When set to true, XMLStreamReader instances created from an EDIInputFactory will generate XMLNS attributes on the TRANSACTION element in addition to the INTERCHANGE element.- See Also:
-
XML_WRAP_TRANSACTION_CONTENTS
When set to true, XMLStreamReader instances created from an EDIInputFactory will generate an element wrapper around the transaction's content element. The wrapper will not contain the elements representing the transaction's header and trailer segments. The wrapper element will be in theLOOPSXML name space and the local name will be constructed as follows:
<Standard Name> + '-' + <Transaction Code> + '-' + <Transaction Version String>- Since:
- 1.16
- See Also:
-
XML_USE_SEGMENT_IMPLEMENTATION_CODES
When set to true, the XML elements representing segments in an EDI implementation schema will be named according to the schema-definedcodeattribute for the segment. Default value: false- Since:
- 1.21
- See Also:
-
EDI_IGNORE_EXTRANEOUS_CHARACTERS
When set to true, non-graphical, control characters will be ignored in the EDI input stream. This includes characters ranging from 0x00 through 0x1F and 0x7F.- Since:
- 1.13
- See Also:
-
EDI_NEST_HIERARCHICAL_LOOPS
When set to true, hierarchical loops will be nested in the EDI input stream. The nesting structure is determined by the linkage specified by the EDI data itself using pointers given in the EDI schema for a loop. For example, the hierarchical information given by the X12 HL segment. Default value: true- Since:
- 1.18
- See Also:
-
EDI_ENABLE_LOOP_TEXT
Deprecated.useEDIStreamReader.getReferenceCode()andEDIStreamReader.getSchemaTypeReference()to retrieve additional information for non-textual event types.When set to true, functional group, transaction, and loop start/end events will allow forEDIStreamReader.getText()to be called, which is the legacy behavior. The default value is `true` and this property is deprecated. In the next major release, the property's default value will be `false`. Default value: true- Since:
- 1.20
- See Also:
-
JSON_NULL_EMPTY_ELEMENTS
When set to true, simple data elements not containing data will be represented via the JSON parsers as anullvalue. Default value: false- Since:
- 1.14
- See Also:
-
JSON_OBJECT_ELEMENTS
When set to true, simple data elements will be represented via the JSON parsers as JSON objects. When false, simple elements will be JSON primitive values (string, number) in the data array of their containing structures. Default value: false- Since:
- 1.14
- See Also:
-
-
Constructor Details
-
EDIInputFactory
protected EDIInputFactory()Default constructor
-
-
Method Details
-
newFactory
Create a new instance of the factory. This static method creates a new factory instance. Once an application has obtained a reference to an EDIInputFactory it can use the factory to configure and obtain stream instances.- Returns:
- the factory implementation
-
createEDIStreamReader
Creates a newEDIStreamReaderusing the givenInputStream(with default encoding).- Parameters:
stream-InputStreamfrom which the EDI data will be read- Returns:
- a new
EDIStreamReaderwhich reads from the stream
-
createEDIStreamReader
public abstract EDIStreamReader createEDIStreamReader(InputStream stream, String encoding) throws EDIStreamException Creates a newEDIStreamReaderusing the givenInputStreamand encoding. The encoding must be a validCharset.- Parameters:
stream-InputStreamfrom which the EDI data will be readencoding- character encoding of the stream, must be a validCharset.- Returns:
- a new
EDIStreamReaderwhich reads from the stream - Throws:
EDIStreamException- when encoding is not supported
-
createEDIStreamReader
Creates a newEDIStreamReaderusing the givenInputStream(with default encoding) which uses theSchemafor validation of the input's control structures (interchange, group, transaction). Note that a separate schema for validation of messages/transactions may be passed directly to theEDIStreamReaderonce the type and version of the messages is known.- Parameters:
stream-InputStreamfrom which the EDI data will be readschema-Schemafor control structure validation- Returns:
- a new
EDIStreamReaderwhich reads from the stream
-
createEDIStreamReader
public abstract EDIStreamReader createEDIStreamReader(InputStream stream, String encoding, Schema schema) throws EDIStreamException Creates a newEDIStreamReaderusing the givenInputStreamand encoding which uses theSchemafor validation of the input's control structures (interchange, group, transaction). The encoding must be a validCharset. Note that a separate schema for validation of messages/transactions may be passed directly to theEDIStreamReaderonce the type and version of the messages is known.- Parameters:
stream-InputStreamfrom which the EDI data will be readencoding- character encoding of the stream, must be a validCharset.schema-Schemafor control structure validation- Returns:
- a new
EDIStreamReaderwhich reads from the stream - Throws:
EDIStreamException- when encoding is not supported
-
createFilteredReader
public abstract EDIStreamReader createFilteredReader(EDIStreamReader reader, EDIStreamFilter filter) Creates a newEDIStreamReaderby wrapping the given reader with theEDIStreamFilterfilter.- Parameters:
reader- the reader to wrapfilter- a filter to wrap the given reader- Returns:
- a new
EDIStreamReaderwhich uses filter
-
createXMLStreamReader
public abstract XMLStreamReader createXMLStreamReader(EDIStreamReader reader) throws XMLStreamException Creates a newXMLStreamReaderthat uses the given reader as its data source. The reader should be positioned before the start of an interchange or at the start of an interchange. XML generated by the XMLStreamReader consist exclusively of elements in the namespaces declared by the constants inEDINamespaces. The names of the elements will be as follows:
Errors encountered in the EDI data will result in an XMLStreamException with a message describing the error.EDI Event Namespace Cross Reference Event Element Local Name Element Namespace Start/End of interchange INTERCHANGE EDINamespaces.LOOPSStart/End of functional group GROUP EDINamespaces.LOOPSStart/End of message/transaction TRANSACTION EDINamespaces.LOOPSStart/End of loop Loop code from EDI schema EDINamespaces.LOOPSStart/End of segment Segment tag from EDI data EDINamespaces.SEGMENTSStart/End of composite Segment tag plus two digit element position from EDI data EDINamespaces.COMPOSITESStart/End of simple element Segment tag plus two digit element position from EDI data EDINamespaces.ELEMENTSStart/End of component element in a composite Segment tag plus two digit element position from EDI data plus hyphen plus two digit component position EDINamespaces.ELEMENTS- Parameters:
reader- the reader to wrap- Returns:
- a new
XMLStreamReader - Throws:
XMLStreamException- when the reader encounters an error in creation- See Also:
-
createJsonParser
Creates a new JSON parser of typeJthat uses the given reader as its data source. The reader should be positioned before the start of an interchange or at the start of an interchange.- Type Parameters:
J- the type of the parser being created- Parameters:
reader- the reader to wraptype- the type of the parser being created- Returns:
- a new JSON parser of type
J - Throws:
IllegalArgumentException- when type is an unsupported parser type- Since:
- 1.14
-
getEDIReporter
Deprecated.usegetErrorReporter()insteadRetrieves the reporter that will be set on any EDIStreamReader created by this factory instance.- Returns:
- the reporter that will be set on any EDIStreamReader created by this factory instance
- Throws:
ClassCastException- when reporter is not an instance of EDIReporter- Since:
- 1.4
-
setEDIReporter
Deprecated.usesetErrorReporter(EDIInputErrorReporter)insteadThe reporter that will be set on any EDIStreamReader created by this factory instance. NOTE: When using an EDIReporter, errors found in the data stream that are reported to the reporter will not appear in the stream of events returned by the EDIStreamReader.- Parameters:
reporter- the resolver to use to report non fatal errors- Since:
- 1.4
-
getErrorReporter
Retrieves the reporter that will be set on any EDIStreamReader created by this factory instance.- Returns:
- the reporter that will be set on any EDIStreamReader created by this factory instance
- Since:
- 1.9
-
setErrorReporter
The reporter that will be set on any EDIStreamReader created by this factory instance. NOTE: When using an EDIReporter, errors found in the data stream that are reported to the reporter will not appear in the stream of events returned by the EDIStreamReader.- Parameters:
reporter- the resolver to use to report non fatal errors- Since:
- 1.9
-
EDIStreamReader.getReferenceCode()andEDIStreamReader.getSchemaTypeReference()to retrieve additional information for non-textual event types.