HBook
jhplot.io

Class HBook



  • public class HBookextends Object
    This class is used to book histograms for writing and reading. It can read any input with histograms defined by an external XML file, 1D and 2D arrays. In particular, it can read histogram files generated by FORTRAN or C++ external programs. Unlike the Java serialisation, we keep only data using very clear human-readable syntax. Use integer keys to insert or retrieve objects from XML files. The output size is substentially smaller than for the standard serialisation. You can read data from URL as well.

    The file extension of HBook is "jdat".

    See Also:
    CFBook web page. Look at examples in examples/hbook.py and hbook2d.py.

    Generally, however, use HFile or Serialized class to keep objects to read and write objects in a serialized form.

    • Constructor Detail

      • HBook

        public HBook(String file,     String option)
        Initialize HBook and tell what to do. If the option is "w", the file will be written. If the option is "r", we read the file. If the file name starts with "http" or "ftp", the file will be read from URL. You should call "close" to write the objects in case "w" option.
        Parameters:
        file - file for reading or writing
        option - can be "r" (read) or "w" (write).
      • HBook

        public HBook(String file)
        Initialize HBook class for reading a file. The file can have URL (should start from http or ftp.)
        Parameters:
        file - input file for reading (can be URL).
    • Method Detail

      • setFormat

        public void setFormat(DecimalFormat dfb)
        Set format for writting double values. The default format is "##.#####E00.
        Parameters:
        dfb - writing format.
      • setDescription

        public void setDescription(String description)
        Set a desciption which will be attached to the header of the output file.
        Parameters:
        description - description.
      • getVersion

        public int getVersion()
        Get version of the file.
        Returns:
      • get

        public Object get(String id)
        Get an object using the key
        Parameters:
        id - key for object access
        Returns:
        H1D histogram
      • getKeys

        public String[] getKeys()
        Return array of all know keys
        Returns:
        keys
      • write

        public void write(String id,         H1D h1d)
        write H1D histogram to HBook
        Parameters:
        id - key to be assigned
        h1d - H1D histogram to be added
      • write

        public void write(String id,         H2D h2d)
        write H2D histogram to HBook
        Parameters:
        id - key to be assigned
        h2d - H2D histogram to be added
      • write

        public void write(String id,         P1D p1d)
        add P1D histogram to HBook
        Parameters:
        id - key to be assigned
        p1d - P1D histogram to be added
      • write

        public void write(String id,         PND pnd)
        add PND data object.
        Parameters:
        id - key to be assigned
        pnd - PND histogram to be added
      • write

        public void write(String id,         PNI pnd)
        add PID data object.
        Parameters:
        id - key to be assigned
        pnd - PID histogram to be added
      • write

        public void write(String id,         P0D pnd)
        add P0D data object.
        Parameters:
        id - key to be assigned
        pnd - P0D histogram to be added
      • write

        public void write(String id,         P0I pnd)
        add P0I data object.
        Parameters:
        id - key to be assigned
        pnd - P0D histogram to be added
      • write

        public void write(String id,         P2D pnd)
        add P2D data object.
        Parameters:
        id - key to be assigned
        pnd - P2D histogram to be added
      • write

        public void write(Object ob)
        Add any object. The key will be assigned automatically (integer number incremented by 1). object. All objects should belong to jhplot package.
        Parameters:
        obj - object for writing.
      • write

        public void write(int id,         Object ob)
        Write jhplot data container. Integer key will be transformed to string. Only predefined objects are supported.
        Parameters:
        id - integer key
        obj - object
      • write

        public void write(String id,         F1D f1)
        write F1D function
        Parameters:
        id - key to be assigned
        f1 - function
      • write

        public void write(String id,         FPR f1)
        write FPR parametric function
        Parameters:
        id - key to be assigned
        f1 - function
      • write

        public void write(String id,         F2D f2)
        write F2D function
        Parameters:
        id - key to be assigned
        f2 - function
      • write

        public void write(String id,         double[] a)
        add 1D array
        Parameters:
        id - key to be assigned
        a - array
      • write

        public void write(String id,         int[] a)
        add 1D array
        Parameters:
        id - key to be assigned
        a - array
      • write

        public void write(String id,         double[][] a)
        add 2D array
        Parameters:
        id - key to be assigned
        a - array
      • write

        public void write(String id,         int[][] a)
        add 2D array
        Parameters:
        id - key to be assigned
        a - array
      • write

        public void write(String id,         FND a)
        add 2D array
        Parameters:
        id - key to be assigned
        a - array
      • close

        public void close()
        Clear all objects and exit. If yu write a file, all objects will be writted to the disk.
      • doc

        public void doc()
        Show online documentation.
      • getTimeCreation

        public String getTimeCreation()
        Return time of file creation.

SCaVis 2.1 © jWork.ORG