Module jonix

Class Jonix

java.lang.Object
com.tectonica.jonix.Jonix

public class Jonix extends Object
  • Constructor Details

    • Jonix

      public Jonix()
  • Method Details

    • source

      public static JonixRecords source(InputStream inputStream)
      Initializes a JonixRecords from an InputStream of an ONIX source. This source is expected to contain valid XML content, conforming to either of the ONIX standards (the deprecated Onix2 or the current Onix3). The resulting JonixRecords can be used to iterate over the ONIX records contained in the source.

      NOTE: only one InputStream is allowed in a JonixRecords. It is possible, however, to add files as additional ONIX sources before starting iteration.

      Parameters:
      inputStream - non-null InputStream with ONIX content
      Returns:
      a JonixRecords for iterating over the ONIX content
    • source

      public static JonixRecords source(File file)
      Initializes a JonixRecords from an ONIX File. This file is expected to contain valid XML content, conforming to either of the ONIX standards (the deprecated Onix2 or the current Onix3). The resulting JonixRecords can be used to iterate over the ONIX records contained in the file.

      If needed, before starting iteration, more files can be added as sources, using the various source() methods of JonixRecords.

      Parameters:
      file - non-null File containing ONIX content
      Returns:
      a JonixRecords for iterating over the ONIX content
    • source

      public static JonixRecords source(List<File> files)
      Initializes a JonixRecords from a group of ONIX Files. Each of these files is expected to contain valid XML content, conforming to either of the ONIX standards (the deprecated Onix2 or the current Onix3). The resulting JonixRecords can be used to iterate over the ONIX records contained in these files.

      If needed, before starting iteration, more files can be added as sources, using the various source() methods of JonixRecords.

      Parameters:
      files - non-null list of Files containing ONIX content
      Returns:
      a JonixRecords for iterating over the ONIX content
    • source

      public static JonixRecords source(File folder, String glob, boolean recursive)
      Initializes a JonixRecords from a group of ONIX Files, created by scanning folder. Each of these files is expected to contain valid XML content, conforming to either of the ONIX standards (the deprecated Onix2 or the current Onix3). The resulting JonixRecords can be used to iterate over the ONIX records contained in these files.

      If needed, before starting iteration, more files can be added as sources, using the various source() methods of JonixRecords.

      Parameters:
      folder - the parent folder in which to look for ONIX files
      glob - a glob expression for determining which files within the folder is relevant
      recursive - whether or not to scan the sub-folders in the parent folder recursively
      Returns:
      a JonixRecords for iterating over the ONIX content
    • toProduct2

      public static Product toProduct2(OnixProduct onixProduct)
      Convenience method to assist in casting a <Product> object (as returned in a JonixRecords stream) into an ONIX-2 class (i.e Product)
      Parameters:
      onixProduct - concrete OnixProduct object, which requires casting for further processing
      Returns:
      ONIX-2 type-casted object
    • toProduct2

      public static Product toProduct2(JonixRecord jonixRecord)
      Convenience method to assist in casting a <Product> object (as returned in a JonixRecords stream) into an ONIX-2 class (i.e Product)
      Parameters:
      jonixRecord - a JonixRecord holding a concrete OnixProduct object, which requires casting for further processing
      Returns:
      ONIX-2 type-casted object
    • toProduct3

      public static Product toProduct3(OnixProduct onixProduct)
      Convenience method to assist in casting a <Product> object (as returned in a JonixRecords stream) into an ONIX-3 class (i.e Product)
      Parameters:
      onixProduct - concrete OnixProduct object, which requires casting for further processing
      Returns:
      ONIX-3 type-casted object
    • toProduct3

      public static Product toProduct3(JonixRecord jonixRecord)
      Convenience method to assist in casting a <Product> object (as returned in a JonixRecords stream) into an ONIX-3 class (i.e Product)
      Parameters:
      jonixRecord - a JonixRecord holding a concrete OnixProduct object, which requires casting for further processing
      Returns:
      ONIX-3 type-casted object
    • toHeader2

      public static Header toHeader2(OnixHeader onixHeader)
      Convenience method to assist in casting a <Header> object (e.g. as passed in JonixRecords.onSourceStart(JonixRecords.OnSourceEvent)) into an ONIX-2 class (i.e Header)
      Parameters:
      onixHeader - concrete OnixHeader object, which requires casting for further processing
      Returns:
      ONIX-2 type-casted object
    • toHeader3

      public static Header toHeader3(OnixHeader onixHeader)
      Convenience method to assist in casting a <Header> object (e.g. as passed in JonixRecords.onSourceStart(JonixRecords.OnSourceEvent)) into an ONIX-3 class (i.e Header)
      Parameters:
      onixHeader - concrete OnixHeader object, which requires casting for further processing
      Returns:
      ONIX-3 type-casted object
    • toBaseRecord

      public static BaseRecord toBaseRecord(JonixRecord jonixRecord)
    • toBaseProduct

      public static BaseProduct toBaseProduct(OnixProduct onixProduct)
    • toBaseProduct

      public static BaseProduct toBaseProduct(JonixRecord jonixRecord)
    • toBaseHeader

      public static BaseHeader toBaseHeader(OnixHeader onixHeader)
    • main

      public static void main(String[] args)
      Creates a comma-delimited file named OUTPUT, listing all the ONIX records found in either:
      • any file in or below DIRECTORY (default is current) whose name matches PATTERN (default is *.xml)
      • the single file INPUT
      Parameters:
      args - OUTPUT INPUT or OUTPUT [DIRECTORY] [PATTERN]