peakml
Class Annotation

java.lang.Object
  extended by peakml.Annotation

public class Annotation
extends java.lang.Object

Implementation of a label-value pair. This class is used in the PeakML file format to include information in the file that is not defined in the schema, without breaking the format. The label encodes the name of the annotation and the value encodes the actual value.


Nested Class Summary
static class Annotation.ValueType
          This enum defines the different types of annotations that can occur.
 
Field Summary
static java.lang.String identification
          System annotation for identification tags
static java.lang.String raw_retentiontime
          System annotation for storing the raw retention time in the ScanInfo
static java.lang.String relationid
          System annotation for relation id's of derivatives
static java.lang.String relationship
          System annotation for relationships of derivatives
 
Constructor Summary
Annotation(java.lang.String label, double value)
          Constructs a new annotation instance, with the given label, value, and type.
Annotation(java.lang.String label, int value)
          Constructs a new annotation instance, with the given label, value, and type.
Annotation(java.lang.String label, java.lang.String value)
          Constructs a new annotation instance, with the given label and value.
Annotation(java.lang.String label, java.lang.String value, Annotation.ValueType valuetype)
          Constructs a new annotation instance, with the given label, value, and type.
 
Method Summary
 java.lang.String getLabel()
          Retrieves the label of this annotation.
 java.lang.String getOntologyRef()
          Returns the ontology-ref (eg GO:0051458) for the annotation.
 java.lang.String getValue()
          Returns the value of this annotation as a string.
 double getValueAsDouble()
          Returns the value of the annotation as a double.
 int getValueAsInteger()
          Returns the value of the annotation as an integer.
 java.lang.String getValueAsString()
          See getValue().
 Annotation.ValueType getValueType()
          Returns the type of the annotation.
 void setOntologyRef(java.lang.String ontologyref)
          Sets the ontology-ref (eg GO:0051458) for the annotation.
 void setValue(double value)
          Sets the given value.
 void setValue(int value)
          Sets the given value.
 void setValue(java.lang.String value)
          Sets the given value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

relationid

public static final java.lang.String relationid
System annotation for relation id's of derivatives

See Also:
Constant Field Values

relationship

public static final java.lang.String relationship
System annotation for relationships of derivatives

See Also:
Constant Field Values

identification

public static final java.lang.String identification
System annotation for identification tags

See Also:
Constant Field Values

raw_retentiontime

public static final java.lang.String raw_retentiontime
System annotation for storing the raw retention time in the ScanInfo

See Also:
Constant Field Values
Constructor Detail

Annotation

public Annotation(java.lang.String label,
                  java.lang.String value)
Constructs a new annotation instance, with the given label and value. The type of the constructed annotation is automatically set to string.

Parameters:
label - The label of the annotation.
value - The value of the annotation.

Annotation

public Annotation(java.lang.String label,
                  java.lang.String value,
                  Annotation.ValueType valuetype)
Constructs a new annotation instance, with the given label, value, and type.

Parameters:
label - The label of the annotation.
value - The value of the annotation.
valuetype - The type of the annotation.

Annotation

public Annotation(java.lang.String label,
                  int value)
Constructs a new annotation instance, with the given label, value, and type.

Parameters:
label - The label of the annotation.
value - The value of the annotation.

Annotation

public Annotation(java.lang.String label,
                  double value)
Constructs a new annotation instance, with the given label, value, and type.

Parameters:
label - The label of the annotation.
value - The value of the annotation.
Method Detail

getLabel

public java.lang.String getLabel()
Retrieves the label of this annotation.

Returns:
The label of the annotation.

getValueType

public Annotation.ValueType getValueType()
Returns the type of the annotation.

Returns:
The type of the annotation.

getValue

public java.lang.String getValue()
Returns the value of this annotation as a string. This method will always work because the label is stored as a string in the annotation instance.

Returns:
The value of the annotation.

getValueAsString

public java.lang.String getValueAsString()
See getValue().

Returns:
The value of the annotation.

getValueAsInteger

public int getValueAsInteger()
                      throws java.lang.NumberFormatException
Returns the value of the annotation as an integer. Beware that the string is converted to an integer and this method will throw an exception if the string does not represent an integer.

Returns:
The value of the annotation as an integer.
Throws:
java.lang.NumberFormatException - Thrown by Integer.parseInt(String) and passed on to the calling method.

getValueAsDouble

public double getValueAsDouble()
                        throws java.lang.NumberFormatException
Returns the value of the annotation as a double. Beware that the string is converted to a double and this method will throw an exception if the string does not represent a double.

Returns:
The value of the annotation as a double.
Throws:
java.lang.NumberFormatException - Thrown by Double.parseDouble(String) and passed on to the calling method.

setValue

public void setValue(java.lang.String value)
Sets the given value.

Parameters:
value - The new value.

setValue

public void setValue(int value)
Sets the given value.

Parameters:
value - The new value.

setValue

public void setValue(double value)
Sets the given value.

Parameters:
value - The new value.

setOntologyRef

public void setOntologyRef(java.lang.String ontologyref)
                    throws java.lang.RuntimeException
Sets the ontology-ref (eg GO:0051458) for the annotation. This method only works when the value-type for the annotation has been set to ontology, otherwise an exception is thrown.

Parameters:
ontologyref - The ontology-ref.
Throws:
java.lang.RuntimeException - Thrown when the annotation is not of value-type ontology.

getOntologyRef

public java.lang.String getOntologyRef()
                                throws java.lang.RuntimeException
Returns the ontology-ref (eg GO:0051458) for the annotation. This method only works when the value-type for the annotation has been set to ontology, otherwise an exception is thrown.

Returns:
The ontology-ref.
Throws:
java.lang.RuntimeException - Thrown when the annotation is not of value-type ontology.