Module jonix

Class JonixSource

java.lang.Object
com.tectonica.jonix.JonixSource

public class JonixSource extends Object
Represents a source (either a File or an InputStream) containing ONIX records.

While iterating over records with JonixRecords, this object is accessible via the JonixRecord.source passed to the caller with each ONIX record. It can be used to query the details of the current source, such as its (auto-detected) ONIX version, its ONIX Header (if provided), and of course the file/stream behind it.

Also, it provides a key-value map, that the caller can use during iteration for applicative purposes.

  • Field Details

    • stream

      public final InputStream stream
      Mandatory, non-null member, represented by this source (even it the user passed a File object)
    • file

      public final File file
      The File represented by this source (possibly null if InputStream was used directly)
  • Method Details

    • isStreamBased

      public boolean isStreamBased()
    • sourceName

      public String sourceName()
      Returns:
      the absolute path of the file (if this source pertains to a file), or some text label representing the stream if isStreamBased().
    • header

      public Optional<OnixHeader> header()
    • onixVersion

      public OnixVersion onixVersion()
    • onixRelease

      public String onixRelease()
    • productCount

      public int productCount()
      Returns:
      the ordinal number of the current product, counting from the beginning of this source
    • productGlobalCount

      public int productGlobalCount()
      Returns:
      the ordinal number of the current product, counting from the beginning of this stream
    • skipSource

      public void skipSource()
      Call this in an event triggered by .onSourceStart() if you wish to skip the current source and move on to the next one
    • store

      public <T> JonixSource store(String key, T value)
      Stores an object for later use during the streaming OF THIS SOURCE (as opposed to the more general JonixRecords.store(String, Object) which stores an object for use throughout the entire streaming). The stored object can be retrieved with retrieve(String).
    • retrieve

      public <T> T retrieve(String key)
      Returns:
      an object stored with store(String, Object) during the streaming of the current source, or null if the key doesn't exist
    • retrieve

      public <T> T retrieve(String key, T defaultValue)
      Returns:
      an object stored with store(String, Object) during the streaming of the current source, or defaultValue if the key doesn't exist
    • toString

      public String toString()
      Overrides:
      toString in class Object