com.fdsapi
Class DataSetMap

java.lang.Object
  |
  +--com.fdsapi.DataSetMap
All Implemented Interfaces:
java.lang.Cloneable

public class DataSetMap
extends java.lang.Object
implements java.lang.Cloneable

This class maps DataSets to x,y coordinates. This class is used to add prefixes and suffixes to values in a tabular DataSet (for example a cell or a row). This allows the separation of data (a ResultSet) from presentation (HTML).

You can define the following types of coordinates for DataSets affixes.
1) A DataSet for a particular coordinate (represented by rownumber, columnnumber)
2) A DataSet for a row (x coordinate) default (represented by rownumber, 0)
3) A DataSet for a column (y coordinate) default (represented by 0, columnnumber)
4) An overall default (represented by 0, 0)

For any coordinate being retrieved with getDataSet(x, y) the order of precedence is 1,2,3 then 4. For example if we are displaying the value in coordinate (4,5) of a ResultSet, the following values would be checked to determine what DataSet to use.

1) If (4,5) has an entry then use this value
2) else if (4,0) has an entry then use this value
3) else if (0,5) has an entry then use this value
4) else use the default (0,0) entry which always exists.

(See the main() method which is used for testing for further details.)

Note the flyweight pattern from the Erich Gamma Design Patterns is used to reduce the number of coordinates that need to be created.



View Code


Constructor Summary
protected DataSetMap(int maxX, int maxY)
           
 
Method Summary
 java.lang.Object clone()
           
 DataSet getDataSet(int x, int y)
          Gets the DataSet value for a specific coordinate.
 int getMaxX()
           
 int getMaxY()
           
 void setDataSet(int x, int y, DataSet dataSet)
          Associate a DataSet with a specified (x,y) coordinate.
 void setDataSetParm(DataSetParm dsp)
          Iterate through the map and set the DataSetParms for all DataSets that it contains
 void setMaxX(int x)
           
 void setMaxY(int y)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSetMap

protected DataSetMap(int maxX,
                     int maxY)
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
java.lang.CloneNotSupportedException

setDataSetParm

public void setDataSetParm(DataSetParm dsp)
Iterate through the map and set the DataSetParms for all DataSets that it contains


setDataSet

public void setDataSet(int x,
                       int y,
                       DataSet dataSet)

Associate a DataSet with a specified (x,y) coordinate. The getDataSet(x,y) method will return this DataSet.

Sample call:

setAffix(1, 100, "");  


setMaxX

public void setMaxX(int x)

setMaxY

public void setMaxY(int y)

getMaxX

public int getMaxX()

getMaxY

public int getMaxY()

getDataSet

public DataSet getDataSet(int x,
                          int y)

Gets the DataSet value for a specific coordinate.

Sample call:

    setDataSet(1, 100, new MyDataSet());
    DataSet ds = getDataSet(1, 100);  
 

See the class comment and the main() method to see what happens when a coordinate that is used in the getDataSet() call doesn't exist.