uk.ac.ebi.adfconverter.common.data.tabulardata
Class DataRow

java.lang.Object
  extended byuk.ac.ebi.adfconverter.common.data.tabulardata.DataRow
Direct Known Subclasses:
ADFBioSequence, ADFDesignElement, ADFFeature

public class DataRow
extends java.lang.Object

Object representing collection of data items contained within one line of the data file

Version:
1 * ADF MAGE-TOOL - MicroArray Informatics Team / European Bioinformatics Institute (EBI) ArrayExpress License: ============================================================================== Copyright (c) 2002 The European Bioinformatics Institute. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name ArrayExpress must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact arrayexpress@ebi.ac.uk 4. Products derived from this software may not be called "ArrayExpress" nor may "ArrayExpress" appear in their names without prior written permission of the ArrayExpress developers. 5. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes software developed by ArrayExpress (http://www.ebi.ac.uk/arrayexpress)" THIS SOFTWARE IS PROVIDED BY THE ARRAYEXPRESS GROUP ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ARRAYEXPRESS GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The European Bioinformatics Institute may publish revised and/or new versions of this license with new releases of ArrayExpress software. ==============================================================================
Author:
Pierre MARGUERITE

Constructor Summary
DataRow()
          Creates a new DataRow instance.
DataRow(int initialCapacity)
          Creates a new DataRow instance.
DataRow(java.text.NumberFormat format)
          Creates a new DataRow instance.
 
Method Summary
 void add(DataBuffer datum)
          Adds a DataBuffer datum to the next location in the row
 void add(DataBuffer datum, int position)
          Adds a databuffer datum at a given position in the current row
 void add(java.lang.String datum)
          Adds a String datum to the next location in the Row
 void add(java.lang.StringBuffer datum)
          Adds a StringBuffer datum to the next location in the row
 void add(java.lang.StringBuffer datum, int position)
          Adds a StringBuffer datum at a given position in the current row stores as DataBuffer
 void add(java.lang.String datum, int position)
          Adds a String datum at a given position in the current row stores as DataBuffer
 void addEmpty()
          Adds an empty item (spacer)
 void clear()
          Remove the content of DataRow.
 boolean equals(java.lang.Object row)
          checks if the current object is equal to another one (which is supposed to be a DataRow object)
 DataBuffer getDataBuffer(int location)
          Retrieves the DataBuffer value contained in the specified location.
 DataBuffer getDataBuffer(int location, java.lang.String defaultVal)
          Retrieves the String value contained in the specified location or defaultVal if it does not.
 DataBuffer getDataBuffer(java.lang.String label)
          Retrieves the DataBuffer value located under specified column label.
 DataBuffer getDataBuffer(java.lang.String label, java.lang.String defaultVal)
          Retrieves the String value contained under the specified column label.
 java.util.Date getDate(int location, java.lang.String pattern)
          Retrieves the date using the specified pattern to parse the date.
 java.util.Date getDate(java.lang.String label, java.lang.String pattern)
          Retrieves the date corresponding to the specified column label.
 double getDouble(int location)
          Retrieves the double value of the datum contained in the specified location.
 double getDouble(int location, java.text.DecimalFormat format, double defaultVal)
          Retrieves the double value at specified location parsed using format.
 double getDouble(int location, double defaultVal)
          Retrieves the double value of the datum contained in the specified location.
 double getDouble(java.lang.String label)
          Retrieve the double value contained in data cell corresponding to the specified column label
 double getDouble(java.lang.String label, double defaultVal)
          Retrieve the double value contained in data cell corresponding to the specified column label.
 DataTableHeader getHeaderIndex()
          Method for DataFile to get the shared instance of a Hashtable that contains column label to index reference.
 int getInt(int location)
          Retrieves the int value of the datum contained in the specified location.
 int getInt(int location, java.text.DecimalFormat format, int defaultVal)
          Retrieves the int value at specified location parsed using format.
 int getInt(int location, int defaultVal)
          Retrieves the int value of the datum contained in the specified location.
 int getInt(java.lang.String label)
          Retrieves the int value of the datum contained under specified column label.
 int getInt(java.lang.String label, int defaultVal)
          Retrieves the int value under the specified column label.
 int getLineNumber()
          Retrieve dataRow Line number in the data file
 java.lang.String getString(int location)
          Retrieves the String value contained in the specified location.
 java.lang.String getString(int location, java.lang.String defaultVal)
          Retrieves the String value contained in the specified location or defaultVal if it does not.
 java.lang.String getString(java.lang.String label)
          Retrieves the String value located under specified column label.
 java.lang.String getString(java.lang.String label, java.lang.String defaultVal)
          Retrieves the String value contained under the specified column label.
 java.lang.StringBuffer getStringBuffer(int location)
          Retrieves the StringBuffer value contained in the specified location.
 java.lang.StringBuffer getStringBuffer(int location, java.lang.StringBuffer defaultVal)
          Retrieves the String value contained in the specified location or defaultVal if it does not.
 java.lang.StringBuffer getStringBuffer(java.lang.String label)
          Retrieves the StringBuffer value located under specified column label.
 java.lang.StringBuffer getStringBuffer(java.lang.String label, java.lang.StringBuffer defaultVal)
          Retrieves the String value contained under the specified column label.
 int getStringChecking()
          Retrieves the stringChecking attribut
 boolean isEmpty()
          Tests if this row has no elements.
 void setHeaderIndex(DataTableHeader index)
          Method for DataFile to set the shared instance of a Hashtable that contains column label to index reference.
 void setLineNumber(int lineNumber)
          sets dataRow Line number in the data file
 int size()
          Retrieves the number of location in row.
 java.util.ArrayList toArrayList()
          Converts the row of data into an arrayList
 java.lang.String toString()
          For debugging purpose.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataRow

public DataRow()
Creates a new DataRow instance. Uses JVM's locale for formatting numbers.


DataRow

public DataRow(int initialCapacity)
Creates a new DataRow instance. Uses JVM's locale for formatting numbers.

Parameters:
initialCapacity - the initial capacity of the row.

DataRow

public DataRow(java.text.NumberFormat format)
Creates a new DataRow instance. Uses specified NumberFormat object to read or write numbers.

Parameters:
format - a NumberFormat object
Method Detail

add

public void add(DataBuffer datum)
Adds a DataBuffer datum to the next location in the row

Parameters:
datum - String datum item

add

public void add(DataBuffer datum,
                int position)
Adds a databuffer datum at a given position in the current row

Parameters:
datum - databuffer datum item
position - the position to add the Object

add

public void add(java.lang.String datum)
Adds a String datum to the next location in the Row

Parameters:
datum - String datum item

add

public void add(java.lang.StringBuffer datum)
Adds a StringBuffer datum to the next location in the row

Parameters:
datum - String datum item

add

public void add(java.lang.StringBuffer datum,
                int position)
Adds a StringBuffer datum at a given position in the current row stores as DataBuffer

Parameters:
datum - StringBuffer datum item
position - the position to add the Object

add

public void add(java.lang.String datum,
                int position)
Adds a String datum at a given position in the current row stores as DataBuffer

Parameters:
datum - String datum item
position - the position to add the Object

addEmpty

public void addEmpty()
Adds an empty item (spacer)


clear

public void clear()
Remove the content of DataRow.


equals

public boolean equals(java.lang.Object row)
checks if the current object is equal to another one (which is supposed to be a DataRow object)

Parameters:
row - the datarow to compare with
Returns:
true, if both row are equals. false, otherwise

getDataBuffer

public DataBuffer getDataBuffer(int location)
Retrieves the DataBuffer value contained in the specified location.

Parameters:
location - an int value
Returns:
a String value or emty String if specified location does not exist. (never returns null)

getDataBuffer

public DataBuffer getDataBuffer(int location,
                                java.lang.String defaultVal)
Retrieves the String value contained in the specified location or defaultVal if it does not.

Parameters:
location - location of the item (starts at zero)
defaultVal - default value to use when the does not contain a value.
Returns:
a String value at specified location. If the value does not exist, defaultVal is returned.

getDataBuffer

public DataBuffer getDataBuffer(java.lang.String label)
Retrieves the DataBuffer value located under specified column label.

Parameters:
label - column label
Returns:
a String value corresponding to specified column label. If the column does not exist, empty String is returned.

getDataBuffer

public DataBuffer getDataBuffer(java.lang.String label,
                                java.lang.String defaultVal)
Retrieves the String value contained under the specified column label.

Parameters:
label - column label
defaultVal - default value to return when value does not exist or label fails to match any of the column names in header row.
Returns:
a String value corresponding to specified column label. If no such column exists or the value is empty, devaultVal is returned.

getDate

public java.util.Date getDate(int location,
                              java.lang.String pattern)
Retrieves the date using the specified pattern to parse the date. See java.text.SimpleDateFormat documentation valid date format patterns.

Parameters:
location - locationg of the item
pattern - date format pattern (i.e. "yyyy.MM.dd" for 2002.10.20")
Returns:
Date contained in specified location. If parsing fails using the specified pattern, returns NULL.

getDate

public java.util.Date getDate(java.lang.String label,
                              java.lang.String pattern)
Retrieves the date corresponding to the specified column label.

Parameters:
label - column label
pattern - see SimpleDateFormat for further description on pattern syntax.
Returns:
Date value under specified column label.

getDouble

public double getDouble(int location)
                 throws java.lang.NumberFormatException
Retrieves the double value of the datum contained in the specified location.

Parameters:
location - location of the item
Returns:
a double value
Throws:
java.lang.NumberFormatException - if the item cannot be parsed using normal number parser.

getDouble

public double getDouble(int location,
                        java.text.DecimalFormat format,
                        double defaultVal)
Retrieves the double value at specified location parsed using format. If the value does not exist or fails to parse into double, defaultVal is returned.

Parameters:
location - location of double value
format - double value parser to be used in extracting item.
defaultVal - default value to use in case of missing data or parse error.
Returns:
a double value at specified location or defaultVal

getDouble

public double getDouble(int location,
                        double defaultVal)
Retrieves the double value of the datum contained in the specified location. If the specified location does not contain a double value or empty, default value is returned.

Parameters:
location - location of the item.
defaultVal - default value to use when value does not exist or fails to parse correctly.
Returns:
a double value

getDouble

public double getDouble(java.lang.String label)
                 throws java.lang.NumberFormatException
Retrieve the double value contained in data cell corresponding to the specified column label

Parameters:
label - column label
Returns:
a double value
Throws:
java.lang.NumberFormatException - if the value cannot be parsed correctly.

getDouble

public double getDouble(java.lang.String label,
                        double defaultVal)
Retrieve the double value contained in data cell corresponding to the specified column label.

Parameters:
label - column label
defaultVal - default value to use when value does not exist or does not parse correctly.
Returns:
double value corresponding to the specified column label. If the specified column label does not exist or the value cannot parsed into a double, defaultValu.

getHeaderIndex

public DataTableHeader getHeaderIndex()
Method for DataFile to get the shared instance of a Hashtable that contains column label to index reference.

Returns:
column label to index reference table.

getInt

public int getInt(int location)
           throws java.lang.NumberFormatException
Retrieves the int value of the datum contained in the specified location.

Parameters:
location - location of the item.
Returns:
an int at the specified location.
Throws:
java.lang.NumberFormatException - if the value at specified location cannot parsed into an int

getInt

public int getInt(int location,
                  java.text.DecimalFormat format,
                  int defaultVal)
Retrieves the int value at specified location parsed using format. If the value does not exist or fails to parse into int, defaultVal is returned.

Parameters:
location - location of int value
format - int value parser to be used in extracting item.
defaultVal - default value to use in case of missing data or parse error.
Returns:
an int value at specified location or the defaultVal

getInt

public int getInt(int location,
                  int defaultVal)
Retrieves the int value of the datum contained in the specified location. If the specified location does not contain a int value or empty, default value is returned.

Parameters:
location - location of the item.
defaultVal - default value to use when value does not exist.
Returns:
a int value

getInt

public int getInt(java.lang.String label)
           throws java.lang.NumberFormatException
Retrieves the int value of the datum contained under specified column label.

Parameters:
label - column label
Returns:
a int value
Throws:
java.lang.NumberFormatException - if specified column label does not exist or the value cannot parsed into an int

getInt

public int getInt(java.lang.String label,
                  int defaultVal)
Retrieves the int value under the specified column label.

Parameters:
label - column label (header)
defaultVal - default value to use when value does not exist.
Returns:
int value corresponding to the specified column label. If the specified column label does not exist or cannot be convert into an int default value is returned.

getLineNumber

public int getLineNumber()
Retrieve dataRow Line number in the data file

Returns:
the corresponding line number in a file containing the associated dataTable

getString

public java.lang.String getString(int location)
Retrieves the String value contained in the specified location.

Parameters:
location - an int value
Returns:
a String value or emty String if specified location does not exist. (never returns null)

getString

public java.lang.String getString(int location,
                                  java.lang.String defaultVal)
Retrieves the String value contained in the specified location or defaultVal if it does not.

Parameters:
location - location of the item (starts at zero)
defaultVal - default value to use when the does not contain a value.
Returns:
a String value at specified location. If the value does not exist, defaultVal is returned.

getString

public java.lang.String getString(java.lang.String label)
Retrieves the String value located under specified column label.

Parameters:
label - column label
Returns:
a String value corresponding to specified column label. If the column does not exist, empty String is returned.

getString

public java.lang.String getString(java.lang.String label,
                                  java.lang.String defaultVal)
Retrieves the String value contained under the specified column label.

Parameters:
label - column label
defaultVal - default value to return when value does not exist or label fails to match any of the column names in header row.
Returns:
a String value corresponding to specified column label. If no such column exists or the value is empty, devaultVal is returned.

getStringBuffer

public java.lang.StringBuffer getStringBuffer(int location)
Retrieves the StringBuffer value contained in the specified location.

Parameters:
location - an int value
Returns:
a String value or emty String if specified location does not exist. (never returns null)

getStringBuffer

public java.lang.StringBuffer getStringBuffer(int location,
                                              java.lang.StringBuffer defaultVal)
Retrieves the String value contained in the specified location or defaultVal if it does not.

Parameters:
location - location of the item (starts at zero)
defaultVal - default value to use when the does not contain a value.
Returns:
a String value at specified location. If the value does not exist, defaultVal is returned.

getStringBuffer

public java.lang.StringBuffer getStringBuffer(java.lang.String label)
Retrieves the StringBuffer value located under specified column label.

Parameters:
label - column label
Returns:
a String value corresponding to specified column label. If the column does not exist, empty String is returned.

getStringBuffer

public java.lang.StringBuffer getStringBuffer(java.lang.String label,
                                              java.lang.StringBuffer defaultVal)
Retrieves the String value contained under the specified column label.

Parameters:
label - column label
defaultVal - default value to return when value does not exist or label fails to match any of the column names in header row.
Returns:
a String value corresponding to specified column label. If no such column exists or the value is empty, devaultVal is returned.

getStringChecking

public int getStringChecking()
Retrieves the stringChecking attribut

Returns:
Returns the stringChecking.

isEmpty

public boolean isEmpty()
Tests if this row has no elements.

Returns:
true if this list has no elements; false otherwise.

setHeaderIndex

public void setHeaderIndex(DataTableHeader index)
Method for DataFile to set the shared instance of a Hashtable that contains column label to index reference.

Parameters:
index - column label to index reference table.

setLineNumber

public void setLineNumber(int lineNumber)
sets dataRow Line number in the data file

Parameters:
lineNumber - the line number of the row in the file

size

public int size()
Retrieves the number of location in row.

Returns:
number of items contined in DataRow

toArrayList

public java.util.ArrayList toArrayList()
Converts the row of data into an arrayList

Returns:
arrayList representation of data row. null, if the row doesn't exist

toString

public java.lang.String toString()
For debugging purpose. Converts the row of data into String

Returns:
String representation of data row.


European Bioinformatics InstituteMicroarray Informatics Team