Class EDIInputFactory

java.lang.Object
io.xlate.edi.stream.PropertySupport
io.xlate.edi.stream.EDIInputFactory

public abstract class EDIInputFactory
extends PropertySupport
  • Field Details

  • Constructor Details

  • Method Details

    • newFactory

      public static EDIInputFactory 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

      public abstract EDIStreamReader createEDIStreamReader​(java.io.InputStream stream)
      Creates a new EDIStreamReader using the given InputStream (with default encoding).
      Parameters:
      stream - InputStream from which the EDI data will be read
      Returns:
      a new EDIStreamReader which reads from the stream
    • createEDIStreamReader

      public abstract EDIStreamReader createEDIStreamReader​(java.io.InputStream stream, java.lang.String encoding) throws EDIStreamException
      Creates a new EDIStreamReader using the given InputStream and encoding. The encoding must be a valid Charset.
      Parameters:
      stream - InputStream from which the EDI data will be read
      encoding - character encoding of the stream, must be a valid Charset.
      Returns:
      a new EDIStreamReader which reads from the stream
      Throws:
      EDIStreamException - when encoding is not supported
    • createEDIStreamReader

      public abstract EDIStreamReader createEDIStreamReader​(java.io.InputStream stream, Schema schema)
      Creates a new EDIStreamReader using the given InputStream (with default encoding) which uses the Schema for 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 the EDIStreamReader once the type and version of the messages is known.
      Parameters:
      stream - InputStream from which the EDI data will be read
      schema - Schema for control structure validation
      Returns:
      a new EDIStreamReader which reads from the stream
    • createEDIStreamReader

      public abstract EDIStreamReader createEDIStreamReader​(java.io.InputStream stream, java.lang.String encoding, Schema schema) throws EDIStreamException
      Creates a new EDIStreamReader using the given InputStream and encoding which uses the Schema for validation of the input's control structures (interchange, group, transaction). The encoding must be a valid Charset. Note that a separate schema for validation of messages/transactions may be passed directly to the EDIStreamReader once the type and version of the messages is known.
      Parameters:
      stream - InputStream from which the EDI data will be read
      encoding - character encoding of the stream, must be a valid Charset.
      schema - Schema for control structure validation
      Returns:
      a new EDIStreamReader which reads from the stream
      Throws:
      EDIStreamException - when encoding is not supported
    • createFilteredReader

      public abstract EDIStreamReader createFilteredReader​(EDIStreamReader reader, EDIStreamFilter filter)
      Creates a new EDIStreamReader by wrapping the given reader with the EDIStreamFilter filter.
      Parameters:
      reader - the reader to wrap
      filter - a filter to wrap the given reader
      Returns:
      a new EDIStreamReader which uses filter
    • createXMLStreamReader

      public abstract javax.xml.stream.XMLStreamReader createXMLStreamReader​(EDIStreamReader reader) throws javax.xml.stream.XMLStreamException
      Creates a new XMLStreamReader that 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 in EDINamespaces. The names of the elements will be as follows:
      EDI Event Namespace Cross Reference
      Event Element Local Name Element Namespace
      Start/End of interchange INTERCHANGE EDINamespaces.LOOPS
      Start/End of functional group GROUP EDINamespaces.LOOPS
      Start/End of message/transaction TRANSACTION EDINamespaces.LOOPS
      Start/End of loop Loop code from EDI schema EDINamespaces.LOOPS
      Start/End of segment Segment tag from EDI data EDINamespaces.SEGMENTS
      Start/End of composite Segment tag plus two digit element position from EDI data EDINamespaces.COMPOSITES
      Start/End of simple element Segment tag plus two digit element position from EDI data EDINamespaces.ELEMENTS
      Start/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
      Errors encountered in the EDI data will result in an XMLStreamException with a message describing the error.
      Parameters:
      reader - the reader to wrap
      Returns:
      a new XMLStreamReader
      Throws:
      javax.xml.stream.XMLStreamException - when the reader encounters an error in creation
      See Also:
      EDINamespaces
    • getEDIReporter

      @Deprecated public abstract EDIReporter getEDIReporter()
      Deprecated.
      use getErrorReporter() instead
      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
      Throws:
      java.lang.ClassCastException - when reporter is not an instance of EDIReporter
      Since:
      1.4
    • setEDIReporter

      @Deprecated public abstract void setEDIReporter​(EDIReporter reporter)
      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.4
    • getErrorReporter

      public abstract EDIInputErrorReporter 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

      public abstract void setErrorReporter​(EDIInputErrorReporter reporter)
      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