2.17.2: 2011-06-17

net.sf.basedb.util.bfs
Class MatrixModel

java.lang.Object
  extended by net.sf.basedb.util.bfs.MatrixModel
All Implemented Interfaces:
EventHandler

public class MatrixModel
extends Object
implements EventHandler

A model container for BFS data files. This class is primarily intended to be used when parsing small data files. It is not recommended to use this class with large files since it may use too much memory.

After parsing data is available as

Version:
2.15
Author:
Nicklas
Last modified
$Date: 2010-01-27 14:03:33 +0100 (Wed, 27 Jan 2010) $

Field Summary
private  List<String[]> data
           
private  int numColumns
           
 
Constructor Summary
MatrixModel()
          Create a new annotation model.
 
Method Summary
 void addRow(String... row)
          Add a row of data to the model.
 int getColumnCount()
          Get the number of columns.
 String getData(int rowIndex, int colIndex)
          Get the data element at a given row and column index.
 String[] getRowByIndex(int rowIndex)
           
 int getRowCount()
          Get the number of rows.
<T> void
handleEvent(EventType<T> eventType, T eventData, BfsParser parser)
          The method is called by the parser when it has found something interesting in a BFS file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

data

private List<String[]> data

numColumns

private int numColumns
Constructor Detail

MatrixModel

public MatrixModel()
Create a new annotation model.

Method Detail

handleEvent

public <T> void handleEvent(EventType<T> eventType,
                            T eventData,
                            BfsParser parser)
Description copied from interface: EventHandler
The method is called by the parser when it has found something interesting in a BFS file. See the respective parser documentation for documentation about the events that it generates. There is usually some kind of information associated with the event. This information is sent to the event handler as an object. The parser should document what kind of information it sends so that event handler implementation can react and use the information.

It is recommended that event handlers ignore event types they don't know about.

Specified by:
handleEvent in interface EventHandler
Parameters:
eventType - The type of event. See the parser documentation for more information about the event types it generates
eventData - The data that is associated with the event
parser - The parser that is resposible for parsing the file

addRow

public void addRow(String... row)
Add a row of data to the model. The number of array elements in the array should be the same as the number of columns.


getColumnCount

public int getColumnCount()
Get the number of columns.


getRowCount

public int getRowCount()
Get the number of rows.


getData

public String getData(int rowIndex,
                      int colIndex)
Get the data element at a given row and column index.

Parameters:
rowIndex - The row index, a value between 0 and getRowCount()-1
colIndex - The column index, a value between 0 and getColumnCount()-1
Returns:
The data at the given location

getRowByIndex

public String[] getRowByIndex(int rowIndex)

2.17.2: 2011-06-17