SandMark version 2.0


sandmark.util
Class LabeledGrid

java.lang.Object
  |
  +--sandmark.util.LabeledGrid

public class LabeledGrid
extends java.lang.Object

A sandmark.util.LabeledGrid object provides a general-purpose fixed-size two-dimensional array with row and column labels. Values and labels can be objects of any type. Shortcut methods are provided for loading and storing primitive integer and floating types.


Constructor Summary
LabeledGrid(int ncols, int nrows)
          Constructs a LabeledGrid of specified size.
LabeledGrid(java.lang.Object[] collabels, java.lang.Object[] rowlabels)
          Constructs a LabeledGrid given two sets of labels.
 
Method Summary
 java.lang.Object[] getColumn(int i)
          Gets the values of an entire column.
 java.lang.Object getColumnLabel(int i)
          Returns the label of one column.
 java.lang.Object[] getColumnLabels()
          Returns a list of the column labels.
 double getDouble(int col, int row)
          Gets a grid value as a double.
 float getFloat(int col, int row)
          Gets a grid value as a float.
 int getInt(int col, int row)
          Gets a grid value as an int.
 long getLong(int col, int row)
          Gets a grid value as a long.
 java.lang.Object[] getRow(int j)
          Gets the values of an entire row.
 java.lang.Object getRowLabel(int i)
          Returns the label of one row.
 java.lang.Object[] getRowLabels()
          Returns a list of the row labels.
 java.lang.String getString(int col, int row)
          Gets a grid value as a String.
 java.lang.Object getValue(int col, int row)
          Gets a value from the grid.
static void main(java.lang.String[] args)
           
 void print(java.io.PrintStream p)
          Prints the contents of this grid.
 void setColumn(int i, java.lang.Object[] values)
          Sets all the values in a column.
 void setColumnLabel(int i, java.lang.Object o)
          Sets the label of one column.
 void setColumnLabels(java.lang.Object[] labels)
          Replaces the column labels.
 void setRow(int j, java.lang.Object[] values)
          Sets all the values in a row.
 void setRowLabel(int i, java.lang.Object o)
          Sets the label of one row.
 void setRowLabels(java.lang.Object[] labels)
          Replaces the row labels.
 void setValue(int col, int row, double value)
          Sets a value in the grid to a Double value.
 void setValue(int col, int row, long value)
          Sets a value in the grid to a Long value.
 void setValue(int col, int row, java.lang.Object value)
          Sets a value in the grid.
 java.lang.String toString()
          Returns a String representation of this LabeledGrid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LabeledGrid

public LabeledGrid(int ncols,
                   int nrows)
Constructs a LabeledGrid of specified size.


LabeledGrid

public LabeledGrid(java.lang.Object[] collabels,
                   java.lang.Object[] rowlabels)
Constructs a LabeledGrid given two sets of labels.

Method Detail

getValue

public java.lang.Object getValue(int col,
                                 int row)
Gets a value from the grid.


getInt

public int getInt(int col,
                  int row)
Gets a grid value as an int. A RuntimeException is thrown if the value is not a Number.


getLong

public long getLong(int col,
                    int row)
Gets a grid value as a long. A RuntimeException is thrown if the value is not a Number.


getFloat

public float getFloat(int col,
                      int row)
Gets a grid value as a float. A RuntimeException is thrown if the value is not a Number.


getDouble

public double getDouble(int col,
                        int row)
Gets a grid value as a double. A RuntimeException is thrown if the value is not a Number.


getString

public java.lang.String getString(int col,
                                  int row)
Gets a grid value as a String. A null value is returned as such; otherwise value.toString() is returned.


setValue

public void setValue(int col,
                     int row,
                     java.lang.Object value)
Sets a value in the grid.


setValue

public void setValue(int col,
                     int row,
                     long value)
Sets a value in the grid to a Long value. (This also serves to hold integer values.)


setValue

public void setValue(int col,
                     int row,
                     double value)
Sets a value in the grid to a Double value. (This also serves to hold float values.)


getColumn

public java.lang.Object[] getColumn(int i)
Gets the values of an entire column.


setColumn

public void setColumn(int i,
                      java.lang.Object[] values)
Sets all the values in a column.


getRow

public java.lang.Object[] getRow(int j)
Gets the values of an entire row.


setRow

public void setRow(int j,
                   java.lang.Object[] values)
Sets all the values in a row.


getColumnLabels

public java.lang.Object[] getColumnLabels()
Returns a list of the column labels.


setColumnLabels

public void setColumnLabels(java.lang.Object[] labels)
Replaces the column labels.


getColumnLabel

public java.lang.Object getColumnLabel(int i)
Returns the label of one column.


setColumnLabel

public void setColumnLabel(int i,
                           java.lang.Object o)
Sets the label of one column.


getRowLabels

public java.lang.Object[] getRowLabels()
Returns a list of the row labels.


setRowLabels

public void setRowLabels(java.lang.Object[] labels)
Replaces the row labels.


getRowLabel

public java.lang.Object getRowLabel(int i)
Returns the label of one row.


setRowLabel

public void setRowLabel(int i,
                        java.lang.Object o)
Sets the label of one row.


print

public void print(java.io.PrintStream p)
Prints the contents of this grid. This is mainly for debugging; no format control is provided.


toString

public java.lang.String toString()
Returns a String representation of this LabeledGrid.

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)

SandMark version 2.0

Mon Jun 17 12:30:47 MST 2002