Module jonix

Class JonixRecord

java.lang.Object
com.tectonica.jonix.JonixRecord

public class JonixRecord extends Object
This class is generated by JonixRecords when iterating over ONIX source, and basically wraps an ONIX Product with some contextual information. It contains the JonixSource from which the ONIX Product was read, which, among others, contains the ONIX Header of that source.

Note that the ONIX Product object contained in this class is a low-level OnixProduct which requires casting to an actual descendant in order to access the actual product content. For example:

 void foo(JonixRecord record) {
     if (record.product instanceof com.tectonica.jonix.onix3.Product) {
         com.tectonica.jonix.onix3.Product product3 = (com.tectonica.jonix.onix3.Product) record.product;
         // TODO: this is an Onix3 <Product>, do something with 'product3' hereafter
     } else if (record.product instanceof com.tectonica.jonix.onix2.Product) {
         com.tectonica.jonix.onix2.Product product2 = (com.tectonica.jonix.onix2.Product) record.product;
         // TODO: this is an Onix2 <Product>, do something with 'product2' hereafter
     } else {
         throw new IllegalArgumentException();
     }
 }
 
Alternatively, it is possible to use JonixUnifier in order transform the raw OnixProduct into a BaseProduct which is easier to manipulate:
 void foo(JonixRecord record) {
     BaseProduct baseProduct = JonixUnifier.unifyProduct(record.product);
     // TODO: access the content of 'baseProduct'
 }
 
  • Field Details

  • Constructor Details

  • Method Details

    • breakCurrentSource

      public void breakCurrentSource()
      call this method to stop streaming products from the current source, and move on to the next one (if listed)
    • breakStream

      public void breakStream()
      call this method to stop streaming products from current as well as the next sources (if listed)
    • store

      public <T> JonixRecord store(String key, T value)
      Stores an object for later use during the streaming process. 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, 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, or defaultValue if the key doesn't exist