Package adams.data.spreadsheet
Class RowIdentifier
- java.lang.Object
-
- adams.data.spreadsheet.RowIdentifier
-
- All Implemented Interfaces:
Serializable
public class RowIdentifier extends Object implements Serializable
Uses a range of columns to identify rows.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Range
m_Columns
the range of columns used as identifier.protected ArrayList<String>
m_Keys
the generated keys.protected HashMap<String,ArrayList<Integer>>
m_Rows
the relationship key/identified rows.static String
MISSING
the placeholder for cells if missing.static String
SEPARATOR
the separator between cells in the key.
-
Constructor Summary
Constructors Constructor Description RowIdentifier(Range keys)
Initializes the row identifier with the specified range of columns.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
generateKey(SpreadSheet sheet, int index, int[] indices)
Generates a key for the specified row.Range
getColumns()
Returns the columns used as keys.String
getKey(int keyIndex)
Returns the key at the specified location.List<String>
getKeys()
Returns the generated keys.List<Integer>
getRows(int keyIndex)
Returns the list of row indices.List<Integer>
getRows(String key)
Returns the list of row indices associated with the specified key.void
identify(SpreadSheet sheet)
Configures the identifier with the specified sheet.int
size()
Returns the number of generated keys.String
toString()
Returns a short description of the object.
-
-
-
Field Detail
-
SEPARATOR
public static final String SEPARATOR
the separator between cells in the key.- See Also:
- Constant Field Values
-
MISSING
public static final String MISSING
the placeholder for cells if missing.- See Also:
- Constant Field Values
-
m_Columns
protected Range m_Columns
the range of columns used as identifier.
-
-
Constructor Detail
-
RowIdentifier
public RowIdentifier(Range keys)
Initializes the row identifier with the specified range of columns.- Parameters:
keys
- the columns to use as key columns
-
-
Method Detail
-
generateKey
protected String generateKey(SpreadSheet sheet, int index, int[] indices)
Generates a key for the specified row.- Parameters:
sheet
- the spreadsheet to work onindex
- the index of the row to generate the key forindices
- the column indices to use- Returns:
- the generated key
-
identify
public void identify(SpreadSheet sheet)
Configures the identifier with the specified sheet.- Parameters:
sheet
- the sheet to use as basis
-
getColumns
public Range getColumns()
Returns the columns used as keys.- Returns:
- the range
-
size
public int size()
Returns the number of generated keys.- Returns:
- the number of keys
-
getKey
public String getKey(int keyIndex)
Returns the key at the specified location.- Parameters:
keyIndex
- the position of the key- Returns:
- the key
-
getRows
public List<Integer> getRows(int keyIndex)
Returns the list of row indices.- Returns:
- the associated list of rows, null if not available
-
getRows
public List<Integer> getRows(String key)
Returns the list of row indices associated with the specified key.- Returns:
- the associated list of rows, null if not available
-
-