ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.xmlconfig
Class ParamWithSourceArray

java.lang.Object
  extended by umontreal.iro.lecuyer.xmlconfig.AbstractParam
      extended by umontreal.iro.lecuyer.xmlconfig.ParamWithSourceArray
All Implemented Interfaces:
Cloneable, Param, StorableParam
Direct Known Subclasses:
ArrayParam, ArrayParam2D

public class ParamWithSourceArray
extends AbstractParam
implements StorableParam, Cloneable

Represents a parameter object whose contents can be extracted from a source subset created from a source array. The source array is created by reading data from an external source such as a CSV file or a database. The source subset is then constructed by taking a possibly transposed portion of the source array.

In an XML element whose parameters are extracted from a source array, the source array is described using the CSV or DB subelements. The CSV element, represented by CSVSourceArray2D, takes a single URL attribute pointing to a CSV-formatted text file containing the data. The DB element, represented by DBSourceArray2D, requires a dataQuery attribute giving the query to perform on a database described by a database subelement.

A single source array can contain information for multiple destination arrays. For example, a spreadsheet containing one column of arrival rates for each call type might be exported to CSV, and used as a source array. Therefore, facilities are provided to subset the source array. For this, the startingRow, startingColumn, numRows, and numColumns attributes of a can be used to indicate the portion of the source array to consider. The first two attributes give the (zero-based) starting row and column of the subset. These are optional and defaults to 0. The last two attributes give the dimensions of the subset. If the number of rows [columns] is omitted, it defaults to the number of rows [columns] in the source array minus the starting row [column]. If the resulting subarray is rectangular, it can finally be transposed by using the transposed boolean attribute. This latter boolean attribute is also optional, and defaults to false, i.e., no transposition.


Constructor Summary
ParamWithSourceArray()
           
 
Method Summary
 void addCSV(CSVSourceArray2D dataMatrix)
           
 void addDB(DBSourceArray2D dataMatrix)
           
 void addExcel(ExcelSourceArray2D dataMatrix)
           
 ParamWithSourceArray clone()
           
 void disposeSourceArray()
          Clears the data in the source array.
 SourceArray2D getDataMatrix()
          Returns the matrix from which the data is extracted.
 int getNumColumn()
          Returns the number of columns to be extracted when the array comes from an external source.
 int getNumRows()
          Returns the number of rows to be extracted when the array comes from an external source.
 SourceArray2D getSourceSubset()
          Returns the source subset used to extract data.
 int getStartingColumn()
          Determines the first column to read in the matrix.
 int getStartingRow()
          Determines the first row to read in the matrix.
 void initSourceArray()
          Initializes the source array associated with this object.
 boolean isTransposed()
          Determines if the matrix of data must be transposed before data is extracted.
 void setDataMatrix(SourceArray2D dataMatrix)
          Sets the matrix to extract data from to dataMatrix.
 void setNumColumns(int numColumns)
          Sets the number of columns to be extracted from an external source to construct this array to numColumns
 void setNumRows(int numRows)
          Sets the number of rows to be extracted from an external source to construct this array to numRows
 void setStartingColumn(int startingColumn)
          Sets the starting column to extract external data from to startingColumn.
 void setStartingRow(int startingRow)
          Sets the starting row to extract external data from to startingRow.
 void setTransposed(boolean transposed)
          Sets the matrix transposition indicator to transposedDataMatrix.
 Element toElement(ClassFinder finder, Node parent, String elementName, int spc)
          Converts this parameter object to a DOM element using the class finder finder for formatting class names, with parent node parent, element name elementName, and spc spaces for each indentation level.
 
Methods inherited from class umontreal.iro.lecuyer.xmlconfig.AbstractParam
check, createDocument, getId, getXref, setId, setXref, toString, write, write, write, write, write, write, write, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParamWithSourceArray

public ParamWithSourceArray()
Method Detail

getDataMatrix

public SourceArray2D getDataMatrix()
Returns the matrix from which the data is extracted.

Returns:
the matrix to extract data from.

setDataMatrix

public void setDataMatrix(SourceArray2D dataMatrix)
Sets the matrix to extract data from to dataMatrix.

Parameters:
dataMatrix - the new matrix to extract data from.

isTransposed

public boolean isTransposed()
Determines if the matrix of data must be transposed before data is extracted.

Returns:
the status of the transpose indicator.

setTransposed

public void setTransposed(boolean transposed)
Sets the matrix transposition indicator to transposedDataMatrix.

Parameters:
transposed - the new value of the indicator.

getStartingRow

public int getStartingRow()
Determines the first row to read in the matrix.

Returns:
the starting row.

setStartingRow

public void setStartingRow(int startingRow)
Sets the starting row to extract external data from to startingRow.

Parameters:
startingRow - the starting row.

getNumRows

public int getNumRows()
Returns the number of rows to be extracted when the array comes from an external source. If the number of rows is set to Integer.MAX_VALUE, all available rows, starting from getStartingRow() are extracted. The default number of rows is Integer.MAX_VALUE.

Returns:
the number of rows in the array.

setNumRows

public void setNumRows(int numRows)
Sets the number of rows to be extracted from an external source to construct this array to numRows

Parameters:
numRows -

getStartingColumn

public int getStartingColumn()
Determines the first column to read in the matrix.

Returns:
the starting column.

setStartingColumn

public void setStartingColumn(int startingColumn)
Sets the starting column to extract external data from to startingColumn.

Parameters:
startingColumn - the starting column.

getNumColumn

public int getNumColumn()
Returns the number of columns to be extracted when the array comes from an external source. If the number of columns is set to Integer.MAX_VALUE, all available columns, starting from getStartingColumn() are extracted. The default number of rows is Integer.MAX_VALUE.

Returns:
the number of columns in the array.

setNumColumns

public void setNumColumns(int numColumns)
Sets the number of columns to be extracted from an external source to construct this array to numColumns

Parameters:
numColumns - the number of columns.

addCSV

public void addCSV(CSVSourceArray2D dataMatrix)

addDB

public void addDB(DBSourceArray2D dataMatrix)

addExcel

public void addExcel(ExcelSourceArray2D dataMatrix)

toElement

public Element toElement(ClassFinder finder,
                         Node parent,
                         String elementName,
                         int spc)
Description copied from interface: StorableParam
Converts this parameter object to a DOM element using the class finder finder for formatting class names, with parent node parent, element name elementName, and spc spaces for each indentation level. The method must create an Element instance with name elementName and add it to the node parent of the DOM tree. It is recommended to use DOMUtils helper methods for this. After the element is created, attributes can be set and nested contents can be added. The configured DOM element is then returned.

Specified by:
toElement in interface StorableParam
Parameters:
finder - the class finder used to format class names.
parent - the parent of the new element.
elementName - the name of the constructed element.
spc - the number of spaces for each indentation level.
Returns:
the newly-constructed element.

clone

public ParamWithSourceArray clone()
Overrides:
clone in class Object

initSourceArray

public void initSourceArray()
Initializes the source array associated with this object.


disposeSourceArray

public void disposeSourceArray()
Clears the data in the source array.


getSourceSubset

public SourceArray2D getSourceSubset()
Returns the source subset used to extract data.

Returns:
the source subset.

ContactCenters
V. 0.9.9.

To submit a bug or ask questions, send an e-mail to Richard Simard.