peakml.io
Class Header

java.lang.Object
  extended by peakml.Annotatable
      extended by peakml.io.Header

public class Header
extends Annotatable

Central header class, collecting all information about the header stored in a mass spectrometry related file. It acts as a repository for instances of SetInfo, MeasurementInfo, FileInfo, and SampleInfo. For keeping track of this information convenience functions are provided. Additionally, the class tracks the number of peaks, owner, and annotation at the file level.


Constructor Summary
Header()
          Constructs a new, empty instance of the header class.
 
Method Summary
 void addApplicationInfo(ApplicationInfo application)
          Adds the given application information to the header.
 void addMeasurementInfo(MeasurementInfo measurement)
          Adds the given measurement information to the header.
 void addMeasurementInfos(java.util.Collection<MeasurementInfo> measurements)
          Adds the given measurement informations to the header.
 void addSampleInfo(SampleInfo sample)
          Adds the given sample information instance to the header.
 void addSetInfo(SetInfo set)
          Adds the given set information to the header.
 void addSetInfos(java.util.Collection<SetInfo> sets)
          Adds the given set informations to the header.
 void addVocabulary(Vocabulary vocabulary)
          Adds the given vocabulary to the list of vocabularies associated with the header.
 ApplicationInfo getApplicationInfo(int index)
          Returns the application information with the given id.
 java.util.Vector<ApplicationInfo> getApplicationInfos()
          Returns the vector with all the application information instances.
 java.util.Date getDate()
          Returns the date at which the file was created.
 java.lang.String getDateAsString()
          Returns the date at which the file was created in string format.
 java.lang.String getDescription()
          Returns an optional description for the information stored in the file.
 MeasurementInfo getMeasurementInfo(int id)
          Returns the measurement information with the given id.
 java.util.Vector<MeasurementInfo> getMeasurementInfos()
          Returns the list of measurement informations associated with the header.
 java.util.Vector<MeasurementInfo> getMeasurementInfos(SetInfo set)
          Returns the list of measurement informations associated to the given set.
 int getNrApplicationInfos()
          Returns the number of application information instances stored in the header.
 int getNrMeasurementInfos()
          Returns the number of measurement informations associated with the header.
 int getNrPeaks()
          Returns the number of peaks associated with this header.
 int getNrSampleInfos()
          Returns the number of sample information instances associated with the header.
 int getNrSetInfos()
          Returns the number of set informations stored in the header.
 int getNrVocabularies()
          Returns the number of vocabularies associated with the header.
 java.lang.String getOwner()
          Returns the owner of the file.
 SampleInfo getSampleInfo(java.lang.String id)
          Returns the sample information with the given id.
 java.util.Vector<SampleInfo> getSampleInfos()
          Returns a list of all the sample information instances associated with the header.
 SetInfo getSetInfo(java.lang.String id)
          Returns the set information with the given id.
 SetInfo getSetInfoForMeasurementID(int measurementid)
          Returns the set information which contains the given measurement id.
 java.util.Vector<SetInfo> getSetInfos()
          Returns all the set informations stored in the header.
 java.util.Vector<Vocabulary> getVocabularies()
          Returns a list of all vocabularies associated with the header.
 Vocabulary getVocabulary(java.lang.String namespace)
          Returns the vocabulary of the given namespace.
 int indexOfMeasurementInfo(int id)
          Returns the index of the measurement information with the given id.
 int indexOfMeasurementInfo(java.lang.String label)
          Returns the index of the measurement information with the given label.
 int indexOfSetInfo(SetInfo setinfo)
          Returns the index of the set information with the given id.
 int indexOfSetInfo(java.lang.String id)
          Returns the index of the set information with the given id.
 void setDate(java.util.Date date)
          Sets the new date of the file to the given value.
 void setDate(java.lang.String date)
          Sets the new date of the file to the given value.
 void setDescription(java.lang.String description)
          Sets an optional description for the information stored in the file.
 void setNrPeaks(int nrpeaks)
          Sets the number of peaks associated with this header.
 void setOwner(java.lang.String owner)
          Sets the new owner of the file.
 
Methods inherited from class peakml.Annotatable
addAnnotation, addAnnotation, addAnnotation, addAnnotation, addAnnotation, addAnnotations, getAnnotation, getAnnotations, removeAllAnnotations, removeAnnotation
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Header

public Header()
Constructs a new, empty instance of the header class.

Method Detail

getNrPeaks

public int getNrPeaks()
Returns the number of peaks associated with this header. This value is mostly used for sending progress information with the classes ParserProgressListener and WriterProgressListener.

Returns:
The number of peaks.

setNrPeaks

public void setNrPeaks(int nrpeaks)
Sets the number of peaks associated with this header. See getNrPeaks() for more information.

Parameters:
nrpeaks - The number of peaks.

getDate

public java.util.Date getDate()
Returns the date at which the file was created.

Returns:
The date at which the file was created.

getDateAsString

public java.lang.String getDateAsString()
Returns the date at which the file was created in string format. See setDate(Date) for a description of the format used.

Returns:
The date as string.

setDate

public void setDate(java.util.Date date)
Sets the new date of the file to the given value.

Parameters:
date - The new date at which the file was created.

setDate

public void setDate(java.lang.String date)
             throws java.text.ParseException
Sets the new date of the file to the given value. The string represention of the date needs to be in the US (long) locale, which means it needs to be in the format 'September 12, 2008'. This locale is also used in the file format for storing dates and numbers.

When the string representation is not in the US locale a ParseException is thrown.

Parameters:
date - String representation of the new date
Throws:
ParseException - Thrown when the string is not encoded in the US (long) locale

getOwner

public java.lang.String getOwner()
Returns the owner of the file.

Returns:
The owner of the PeakML file.

setOwner

public void setOwner(java.lang.String owner)
Sets the new owner of the file.

Parameters:
owner - The new owner of the PeakML file.

getDescription

public java.lang.String getDescription()
Returns an optional description for the information stored in the file.

Returns:
Optional description of the file contents.

setDescription

public void setDescription(java.lang.String description)
Sets an optional description for the information stored in the file.

Parameters:
description - Optional description of the file contents.

getVocabulary

public Vocabulary getVocabulary(java.lang.String namespace)
Returns the vocabulary of the given namespace. When the namespace has not been registered with the header null is returned.

Parameters:
namespace - The namespace of the vocabulary to be retrieved.
Returns:
The vocabulary with the given namespace.

getNrVocabularies

public int getNrVocabularies()
Returns the number of vocabularies associated with the header.

Returns:
The number of vocabularies associated with the header.

getVocabularies

public java.util.Vector<Vocabulary> getVocabularies()
Returns a list of all vocabularies associated with the header.

Returns:
The vocabularies associated with the header.

addVocabulary

public void addVocabulary(Vocabulary vocabulary)
Adds the given vocabulary to the list of vocabularies associated with the header. The given vocabulary is registered with its namespace (can be retrieved Vocabulary.getDefaultNamespace()). If the namespace has already been registered the old vocabulary is overwritten.

Parameters:
vocabulary - The vocabulary to be added to the header.

getSampleInfo

public SampleInfo getSampleInfo(java.lang.String id)
Returns the sample information with the given id. When no such id is registered with the header null is returned.

Parameters:
id - The id of the sample information.
Returns:
The sample information.

getNrSampleInfos

public int getNrSampleInfos()
Returns the number of sample information instances associated with the header.

Returns:
The number of sample information instances.

getSampleInfos

public java.util.Vector<SampleInfo> getSampleInfos()
Returns a list of all the sample information instances associated with the header.

Returns:
A list of all the sample information instances.

addSampleInfo

public void addSampleInfo(SampleInfo sample)
Adds the given sample information instance to the header. When the id of the sample information (SampleInfo.getID()) has already been registered, the old instance is overwritten.

Parameters:
sample - The sample information to be stored.

getMeasurementInfo

public MeasurementInfo getMeasurementInfo(int id)
Returns the measurement information with the given id.

Parameters:
id - The id of the measurement information to be retrieved.

indexOfMeasurementInfo

public int indexOfMeasurementInfo(int id)
Returns the index of the measurement information with the given id. When the id cannot be found -1 is returned.

Parameters:
id - The id of the measurement information.
Returns:
The index of the measurement information with the given id.

indexOfMeasurementInfo

public int indexOfMeasurementInfo(java.lang.String label)
Returns the index of the measurement information with the given label. When the label cannot be found -1 is returned.

Parameters:
label - The label of the measurement information.
Returns:
The index of the measurement information with the given label.

getNrMeasurementInfos

public int getNrMeasurementInfos()
Returns the number of measurement informations associated with the header.

Returns:
The index of the measurement information.

getMeasurementInfos

public java.util.Vector<MeasurementInfo> getMeasurementInfos()
Returns the list of measurement informations associated with the header.

Returns:
The list of measurement informations associated with the header.

getMeasurementInfos

public java.util.Vector<MeasurementInfo> getMeasurementInfos(SetInfo set)
Returns the list of measurement informations associated to the given set.


addMeasurementInfo

public void addMeasurementInfo(MeasurementInfo measurement)
Adds the given measurement information to the header. When the id of the measurement information has already been registered the old instance is overwritten.

Parameters:
measurement - The measurement information to be added.

addMeasurementInfos

public void addMeasurementInfos(java.util.Collection<MeasurementInfo> measurements)
Adds the given measurement informations to the header. When the id of a measurement information has already been registered the old instance is overwritten.

Parameters:
measurements - The measurement informations to be added.

addSetInfo

public void addSetInfo(SetInfo set)
Adds the given set information to the header. When the id of a set information has already been registered the old instance is overwritten.

Parameters:
set - The set information to be added.

getSetInfo

public SetInfo getSetInfo(java.lang.String id)
Returns the set information with the given id.

Returns:
The set information with the given id.

getNrSetInfos

public int getNrSetInfos()
Returns the number of set informations stored in the header.

Returns:
The number of set informations.

getSetInfos

public java.util.Vector<SetInfo> getSetInfos()
Returns all the set informations stored in the header.

Returns:
The set informations.

getSetInfoForMeasurementID

public SetInfo getSetInfoForMeasurementID(int measurementid)
Returns the set information which contains the given measurement id.

Returns:
The set information containing the measurement id.

indexOfSetInfo

public int indexOfSetInfo(java.lang.String id)
Returns the index of the set information with the given id.

Returns:
The set information with the given id.

indexOfSetInfo

public int indexOfSetInfo(SetInfo setinfo)
Returns the index of the set information with the given id.

Returns:
The set information with the given id.

addSetInfos

public void addSetInfos(java.util.Collection<SetInfo> sets)
Adds the given set informations to the header. When the id of a set information has already been registered the old instance is overwritten.

Parameters:
sets - The set informations to be added.

addApplicationInfo

public void addApplicationInfo(ApplicationInfo application)
Adds the given application information to the header. When the id of a application information has already been registered the old instance is overwritten.

Parameters:
application - The application information to be added.

getApplicationInfo

public ApplicationInfo getApplicationInfo(int index)
Returns the application information with the given id.

Returns:
The application information at the given index.

getApplicationInfos

public java.util.Vector<ApplicationInfo> getApplicationInfos()
Returns the vector with all the application information instances.

Returns:
The vector with all application information instances.

getNrApplicationInfos

public int getNrApplicationInfos()
Returns the number of application information instances stored in the header.

Returns:
The number of application information instances.