jhplot.io
Class HBook
- java.lang.Object
-
- jhplot.io.HBook
-
public class HBook extends java.lang.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 substantially 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 Summary
Constructors Constructor and Description HBook(java.lang.String file)
Initialize HBook class for reading a file.HBook(java.lang.String file, java.lang.String option)
Initialize HBook and tell what to do.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
close()
Clear all objects and exit.void
doc()
Show online documentation.java.lang.Object
get(java.lang.String id)
Get an object using the keyjava.util.Map<java.lang.String,java.lang.Object>
getAll()
Get all objects as a mapjava.lang.String[]
getKeys()
Return array of all know keysjava.lang.String
getTimeCreation()
Return time of file creation.int
getVersion()
Get version of the file.void
setDescription(java.lang.String description)
Set a desciption which will be attached to the header of the output file.void
setFormat(java.text.DecimalFormat dfb)
Set format for writting double values.void
write(int id, java.lang.Object ob)
Write jhplot data container.void
write(java.lang.Object ob)
Add any object.void
write(java.lang.String id, double[] a)
add 1D arrayvoid
write(java.lang.String id, double[][] a)
add 2D arrayvoid
write(java.lang.String id, F1D f1)
write F1D functionvoid
write(java.lang.String id, F2D f2)
write F2D functionvoid
write(java.lang.String id, FND a)
add 2D arrayvoid
write(java.lang.String id, FPR f1)
write FPR parametric functionvoid
write(java.lang.String id, H1D h1d)
write H1D histogram to HBookvoid
write(java.lang.String id, H2D h2d)
write H2D histogram to HBookvoid
write(java.lang.String id, int[] a)
add 1D arrayvoid
write(java.lang.String id, int[][] a)
add 2D arrayvoid
write(java.lang.String id, P0D pnd)
add P0D data object.void
write(java.lang.String id, P0I pnd)
add P0I data object.void
write(java.lang.String id, P1D p1d)
add P1D histogram to HBookvoid
write(java.lang.String id, P2D pnd)
add P2D data object.void
write(java.lang.String id, PND pnd)
add PND data object.void
write(java.lang.String id, PNI pnd)
add PID data object.
-
-
-
Constructor Detail
-
HBook
public HBook(java.lang.String file, java.lang.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 writingoption
- can be "r" (read) or "w" (write).
-
HBook
public HBook(java.lang.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(java.text.DecimalFormat dfb)
Set format for writting double values. The default format is "##.#####E00.- Parameters:
dfb
- writing format.
-
setDescription
public void setDescription(java.lang.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 java.lang.Object get(java.lang.String id)
Get an object using the key- Parameters:
id
- key for object access- Returns:
- H1D histogram
-
getKeys
public java.lang.String[] getKeys()
Return array of all know keys- Returns:
- keys
-
write
public void write(java.lang.String id, H1D h1d)
write H1D histogram to HBook- Parameters:
id
- key to be assignedh1d
- H1D histogram to be added
-
write
public void write(java.lang.String id, H2D h2d)
write H2D histogram to HBook- Parameters:
id
- key to be assignedh2d
- H2D histogram to be added
-
write
public void write(java.lang.String id, P1D p1d)
add P1D histogram to HBook- Parameters:
id
- key to be assignedp1d
- P1D histogram to be added
-
write
public void write(java.lang.String id, PND pnd)
add PND data object.- Parameters:
id
- key to be assignedpnd
- PND histogram to be added
-
write
public void write(java.lang.String id, PNI pnd)
add PID data object.- Parameters:
id
- key to be assignedpnd
- PID histogram to be added
-
write
public void write(java.lang.String id, P0D pnd)
add P0D data object.- Parameters:
id
- key to be assignedpnd
- P0D histogram to be added
-
write
public void write(java.lang.String id, P0I pnd)
add P0I data object.- Parameters:
id
- key to be assignedpnd
- P0D histogram to be added
-
write
public void write(java.lang.String id, P2D pnd)
add P2D data object.- Parameters:
id
- key to be assignedpnd
- P2D histogram to be added
-
write
public void write(java.lang.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, java.lang.Object ob)
Write jhplot data container. Integer key will be transformed to string. Only predefined objects are supported.- Parameters:
id
- integer keyobj
- object
-
write
public void write(java.lang.String id, F1D f1)
write F1D function- Parameters:
id
- key to be assignedf1
- function
-
write
public void write(java.lang.String id, FPR f1)
write FPR parametric function- Parameters:
id
- key to be assignedf1
- function
-
write
public void write(java.lang.String id, F2D f2)
write F2D function- Parameters:
id
- key to be assignedf2
- function
-
write
public void write(java.lang.String id, double[] a)
add 1D array- Parameters:
id
- key to be assigneda
- array
-
write
public void write(java.lang.String id, int[] a)
add 1D array- Parameters:
id
- key to be assigneda
- array
-
write
public void write(java.lang.String id, double[][] a)
add 2D array- Parameters:
id
- key to be assigneda
- array
-
write
public void write(java.lang.String id, int[][] a)
add 2D array- Parameters:
id
- key to be assigneda
- array
-
write
public void write(java.lang.String id, FND a)
add 2D array- Parameters:
id
- key to be assigneda
- 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.
-
getAll
public java.util.Map<java.lang.String,java.lang.Object> getAll()
Get all objects as a map- Returns:
-
getTimeCreation
public java.lang.String getTimeCreation()
Return time of file creation.
-
-
DMelt 3.0 © DataMelt by jWork.ORG