Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

joelib.jcamp
Class JCAMPParser  view JCAMPParser download JCAMPParser.java

java.lang.Object
  extended byjoelib.jcamp.JCAMPParser

public class JCAMPParser
extends java.lang.Object

A class to interpret JCAMP-DX data (JCAMP-CS is not implemented yet). The supported data types are XYPAIRS, XYDATA=(X++(Y..Y)), PEAK TABLE and LINK.
If you want load a file with multiple blocks or inner blocks you must use JCampMultipleFile.
This class can only load separated single blocks with one TITLE and END label !


Field Summary
private  boolean calculatedDeltaXneeded
          state if the decodeData() - routine must estimate the DELTAX label
static int CHEMICAL_STRUCTURE
          data representation: definition for the parameter of a chemical structure
static java.lang.String[] commonLDRs
          An array of the commonly used LDR's (Label Data Records).
static int DATA_TYPE_PEAKS
          Description of the Field
static int DATA_TYPE_SPECTRUM
          Description of the Field
private  boolean dataDecoded
          the state if this data was decoded.
private  int dataType
          the JCAMP data type of this data set.
private  double deltaX
          DELTAX label from this data set
private  double DELTAX_DIFFERENCE_WARNING_VALUE
          this defines the valid difference of the original DELTAX label and the calculated DELTAX label
private  boolean estimatedNPointsNeeded
          state if the decodeData() - routine must estimate the NPOINTS label
private  double firstX
          FIRSTX label from this data set
private  double lastX
          LASTX label from this data set
static int LINK
          data representation: LINK definition
private static org.apache.log4j.Category logger
          Obtain a suitable logger.
private  double nPoints
          NPOINTS label from this data set
private  java.util.Hashtable parameterTable
          here are the LDR's (label data records) stored
static int PEAK_ASSIGNMENTS
          data representation: PEAK ASSIGNMENTS definition
static int PEAK_TABLE
          data representation: PEAK TABLE definition
static int RADATA
          data representation: RADATA definition
private  boolean separatorStandardChecked
          state if the separator standard is already checked
private  boolean standardSeparator
          standard separator is "," and ";", values are represanteted with ".", e.g.
private  java.util.LinkedList xData
          temporarily used when data is decoded
private  double[] xDoubleData
           
private  double xFactor
          XFACTOR label from this data set
static int XYDATA_X_YY
          data representation: XYDATA=(X++(Y..Y)) definition
static int XYPAIRS
          data representation: XYPAIRS definition
static int XYPOINTS
          data representation: XYPOINTS definition
private  java.util.LinkedList yData
          temporarily used when data is decoded
private  double[] yDoubleData
           
private  double yFactor
          YFACTOR label from this data set
 
Constructor Summary
JCAMPParser(java.lang.String s)
          Initializes this JCampInterpreter and gets the JCAMP data in the String s.
 
Method Summary
private  void addXYDATADataLine(java.lang.String s)
          Adds a Data Line to the yData- and the xData - puffer
private  void addXYPAIRSandPEAKTABLEdataLine(java.lang.String s)
          Adds a Data Line to the yData- and the xData - puffer
private  void decodeChemicalStructure()
          Decodes the chemical data.
private  void decodeData()
          Decide which data type this JCAMP data set contains and decodes this data.
private  void decodeXYDATA()
          Decodes XYDATA.
private  void decodeXYPAIRSandPEAKTABLE()
          Decodes XYPAIRS.
 java.lang.String getAdditionalInformation(java.lang.String infoType)
          Gets the label infoType.
 int getDataType()
          Gets the data type of this data set.
protected  double getDouble(LabelData ld)
          Gets the double from ld.data.
 int getJCampDataType()
          Gets the JCAMP data type of this data set.
 int getLength()
          Gets the length of the X and Y array.
 LabelData[] getParameter()
          Get all LDR's (data label records) that are stored.
 LabelData getParameter(java.lang.String wanted)
           
 LabelData[] getParameter(java.lang.String[] wanted)
           
 double[] getXData()
          Gets the X array.
 java.lang.String getXLabel()
          Gets the label for the X axis.
 double[] getYData()
          Gets the Y array.
 java.lang.String getYLabel()
          Gets the label for the Y axis.
private  void interpretLDRs(java.lang.String s)
          Interprets the data in s.
private  void sendDataToDoubleArray()
          Sends the data from the vectors to the X and Y array.
 void setParameter(LabelData newLDR)
          Set one LDR (data label record).
 void setParameter(LabelData[] newLDR)
          Set some LDR's (data label records).
 java.lang.String toString()
          Returns a string of all LDR's (label data records.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static org.apache.log4j.Category logger
Obtain a suitable logger.


DATA_TYPE_SPECTRUM

public static final int DATA_TYPE_SPECTRUM
Description of the Field

See Also:
Constant Field Values

DATA_TYPE_PEAKS

public static final int DATA_TYPE_PEAKS
Description of the Field

See Also:
Constant Field Values

XYPAIRS

public static final int XYPAIRS
data representation: XYPAIRS definition

See Also:
Constant Field Values

XYDATA_X_YY

public static final int XYDATA_X_YY
data representation: XYDATA=(X++(Y..Y)) definition

See Also:
Constant Field Values

CHEMICAL_STRUCTURE

public static final int CHEMICAL_STRUCTURE
data representation: definition for the parameter of a chemical structure

See Also:
Constant Field Values

XYPOINTS

public static final int XYPOINTS
data representation: XYPOINTS definition

See Also:
Constant Field Values

PEAK_TABLE

public static final int PEAK_TABLE
data representation: PEAK TABLE definition

See Also:
Constant Field Values

PEAK_ASSIGNMENTS

public static final int PEAK_ASSIGNMENTS
data representation: PEAK ASSIGNMENTS definition

See Also:
Constant Field Values

RADATA

public static final int RADATA
data representation: RADATA definition

See Also:
Constant Field Values

LINK

public static final int LINK
data representation: LINK definition

See Also:
Constant Field Values

commonLDRs

public static final java.lang.String[] commonLDRs
An array of the commonly used LDR's (Label Data Records).

For more information see:


parameterTable

private java.util.Hashtable parameterTable
here are the LDR's (label data records) stored


xData

private java.util.LinkedList xData
temporarily used when data is decoded


yData

private java.util.LinkedList yData
temporarily used when data is decoded


calculatedDeltaXneeded

private boolean calculatedDeltaXneeded
state if the decodeData() - routine must estimate the DELTAX label

See Also:
decodeData() 55

dataDecoded

private boolean dataDecoded
the state if this data was decoded. Only available after decoding the data with decodeData()

See Also:
decodeData() 55

estimatedNPointsNeeded

private boolean estimatedNPointsNeeded
state if the decodeData() - routine must estimate the NPOINTS label

See Also:
decodeData() 55

separatorStandardChecked

private boolean separatorStandardChecked
state if the separator standard is already checked


standardSeparator

private boolean standardSeparator
standard separator is "," and ";", values are represanteted with ".", e.g. "123.456". Spaces can be used for a nicer look.

Another possibility for a separator is " ", values are represanteted with ",", e.g. "123,456". That's not a standard definition !!!


DELTAX_DIFFERENCE_WARNING_VALUE

private final double DELTAX_DIFFERENCE_WARNING_VALUE
this defines the valid difference of the original DELTAX label and the calculated DELTAX label

See Also:
decodeData() 55 , Constant Field Values

xDoubleData

private double[] xDoubleData

yDoubleData

private double[] yDoubleData

deltaX

private double deltaX
DELTAX label from this data set


firstX

private double firstX
FIRSTX label from this data set


lastX

private double lastX
LASTX label from this data set


nPoints

private double nPoints
NPOINTS label from this data set


xFactor

private double xFactor
XFACTOR label from this data set


yFactor

private double yFactor
YFACTOR label from this data set


dataType

private int dataType
the JCAMP data type of this data set. If the data type was not evaluated by decodeData() it is -1

Constructor Detail

JCAMPParser

public JCAMPParser(java.lang.String s)
            throws java.io.IOException,
                   JCAMPException
Initializes this JCampInterpreter and gets the JCAMP data in the String s. file is stored, but not used. Data is decoded if state is true. Messages are printed to the JTextComponent messages

Method Detail

getDataType

public final int getDataType()
Gets the data type of this data set. That's important for the visualisation routines.


getJCampDataType

public final int getJCampDataType()
Gets the JCAMP data type of this data set.


getLength

public final int getLength()
Gets the length of the X and Y array.


setParameter

public final void setParameter(LabelData[] newLDR)
Set some LDR's (data label records).


setParameter

public final void setParameter(LabelData newLDR)
Set one LDR (data label record).


getParameter

public final LabelData[] getParameter()
Get all LDR's (data label records) that are stored.


getParameter

public final LabelData[] getParameter(java.lang.String[] wanted)

getParameter

public final LabelData getParameter(java.lang.String wanted)

getXData

public final double[] getXData()
Gets the X array.


getXLabel

public final java.lang.String getXLabel()
Gets the label for the X axis. It's equivalent to getParameter ("XUNITS"). If the LDR is not available an empty String is returned.


getYData

public final double[] getYData()
Gets the Y array.


getYLabel

public final java.lang.String getYLabel()
Gets the label for the Y axis. It's equivalent to getParameter ("YUNITS"). If the LDR is not available an empty String is returned.


getAdditionalInformation

public java.lang.String getAdditionalInformation(java.lang.String infoType)
Gets the label infoType. It's equivalent to getParameter (infoType). If the LDR is not available an empty String is returned.


toString

public java.lang.String toString()
Returns a string of all LDR's (label data records.


getDouble

protected final double getDouble(LabelData ld)
                          throws java.lang.NumberFormatException
Gets the double from ld.data.


addXYDATADataLine

private final void addXYDATADataLine(java.lang.String s)
                              throws java.lang.NumberFormatException
Adds a Data Line to the yData- and the xData - puffer


addXYPAIRSandPEAKTABLEdataLine

private final void addXYPAIRSandPEAKTABLEdataLine(java.lang.String s)
                                           throws java.lang.NumberFormatException
Adds a Data Line to the yData- and the xData - puffer


decodeChemicalStructure

private final void decodeChemicalStructure()
                                    throws JCAMPException,
                                           java.lang.NumberFormatException
Decodes the chemical data.


decodeData

private void decodeData()
                 throws JCAMPException,
                        java.lang.NumberFormatException
Decide which data type this JCAMP data set contains and decodes this data. After decoding the data is available with getXData() and getYData(), if the data contains a spectra.
Chemical structures are not supported, until now !


decodeXYDATA

private void decodeXYDATA()
                   throws JCAMPException,
                          java.lang.NumberFormatException
Decodes XYDATA. Only the uncompressed ASDF format is supported. The compressed AFFN format is not supported.


decodeXYPAIRSandPEAKTABLE

private void decodeXYPAIRSandPEAKTABLE()
                                throws JCAMPException,
                                       java.lang.NumberFormatException
Decodes XYPAIRS.


interpretLDRs

private void interpretLDRs(java.lang.String s)
                    throws JCAMPException,
                           java.io.IOException
Interprets the data in s. The interpreted LDR's (label data record's) are stored in the parameterTable.


sendDataToDoubleArray

private void sendDataToDoubleArray()
Sends the data from the vectors to the X and Y array.