|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.yosokumo.core.Specimen
public class Specimen
A row of values. Other terminology that is sometimes used: An
observation, a record, an example, or an instance. These are
the primary characteristics of a Specimen:
Cells containing the values
of the row
| Nested Class Summary | |
|---|---|
static class |
Specimen.Status
Provides a logical delete facility. |
| Field Summary | |
|---|---|
private java.util.List<Cell> |
cellSequence
A sequence of cells. |
private long |
key
|
private Value |
predictand
|
private Specimen.Status |
status
|
private long |
weight
|
| Constructor Summary | |
|---|---|
Specimen(long key)
Initializes a newly created Specimen object with key specified
by the input parameter. |
|
Specimen(long key,
java.util.Collection<Cell> cells)
Initializes a newly created Specimen object with key and
cell sequence as specified by the input parameters. |
|
Specimen(long key,
Specimen.Status status,
long weight,
Value predictand,
java.util.Collection<Cell> cells)
Initializes a newly created Specimen object with attributes
specified by the input parameters. |
|
Specimen(long key,
Value predictand,
java.util.Collection<Cell> cells)
Initializes a newly created Specimen object with key,
predictand, and cell sequence as specified by the input parameters. |
|
| Method Summary | |
|---|---|
(package private) void |
addCell(Cell cell)
Add a Cell to the cell sequence. |
(package private) boolean |
addCells(java.util.Collection<Cell> cells)
Add a collection of Cells to the cell sequence. |
(package private) void |
clearCells()
Remove all cells from the sequence. |
(package private) Cell |
getCell(int index)
Return a cell from the cell sequence. |
java.util.List<Cell> |
getCells()
Return all cells in the cell sequence as a List<Cell>. |
Value |
getPredictand()
Return the specimen predictand. |
long |
getSpecimenKey()
Return the specimen key. |
Specimen.Status |
getStatus()
Return the specimen status. |
long |
getWeight()
Return the specimen weight. |
boolean |
isEmpty()
Return true if the sequence contains no cells. |
(package private) boolean |
removeCells(int numCellsToRemove)
Remove cells from the end of the sequence. |
void |
setCells(java.util.List<Cell> cells)
Set the cells of this Specimen to the cell list specified
by the parameter. |
void |
setPredictand(Value v)
Set the specimen predictand. |
void |
setSpecimenKey(long key)
Set the specimen key. |
void |
setStatus(Specimen.Status s)
Set the specimen status. |
void |
setWeight(long w)
Set the specimen weight. |
int |
size()
Return the number of cells in the sequence. |
java.lang.String |
toString()
Return a string representation of this Specimen. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private long key
private Specimen.Status status
private long weight
private Value predictand
private java.util.List<Cell> cellSequence
| Constructor Detail |
|---|
public Specimen(long key)
Specimen object with key specified
by the input parameter. Other attributes are set to default values:
key - the key of the specimen.
public Specimen(long key,
java.util.Collection<Cell> cells)
Specimen object with key and
cell sequence as specified by the input parameters. Other attributes
are set to default values:
key - the key of the specimen.cells - the cell sequence of the specimen.
public Specimen(long key,
Value predictand,
java.util.Collection<Cell> cells)
Specimen object with key,
predictand, and cell sequence as specified by the input parameters.
Other attributes are set to default values:
key - the key of the specimen.predictand - the predictand of the specimen.cells - the cell sequence of the specimen.
public Specimen(long key,
Specimen.Status status,
long weight,
Value predictand,
java.util.Collection<Cell> cells)
Specimen object with attributes
specified by the input parameters.
key - the key of the specimen.status - the status of the specimen.weight - the weight of the specimen.predictand - the predictand of the specimen.cells - the cell sequence of the specimen.| Method Detail |
|---|
public void setSpecimenKey(long key)
key - the key to assign to this specimen. This is the
unique identification of the specimen. It must be positive.public long getSpecimenKey()
public void setStatus(Specimen.Status s)
s - the status to assign to this specimen.public Specimen.Status getStatus()
public void setWeight(long w)
w - the weight to assign to this specimen.public long getWeight()
public void setPredictand(Value v)
v - the predictand to assign to this specimen.public Value getPredictand()
void addCell(Cell cell)
Cell to the cell sequence. The Cell parameter is
appended to the end of the cell sequence.
cell - the Cell to add to the cell sequence.boolean addCells(java.util.Collection<Cell> cells)
Cells to the cell sequence. The
Cells in the collection specified by the parameter are appended
to the end of the cell sequence. The order the cells are appended is
the order in which the collection's Iterator returns the cells.
cells - the collection of Cells to add to the
cell sequence.
boolean removeCells(int numCellsToRemove)
numCellsToRemove - is the number of cells to remove from the
end of the sequence. If this value is zero or negative, no
cells are removed. If this value exceeds the number of cells
in the sequence, then all cells are removed.
Cell getCell(int index)
for (int i = 0; i < cellSequence.size(); ++i)
{
Cell c = cellSequence.getCell(i)
process cell c
}
Caution: It is better to iterate over all cells by using
getCells as shown below because that approach is efficient no
matter what kind of List is used to implement the sequence. Iterating
as shown just above is extremely expensive if the LinkedList
implementation is used.
index - specifying which cell of the sequence to return. 0-based.
Cell at the location specified by the index.public java.util.List<Cell> getCells()
List<Cell>.
This makes it possible to iterate over all cells in the sequence
like this:
for (Cell c : cellSequence.getCells())
{
process cell c
}
public void setCells(java.util.List<Cell> cells)
Specimen to the cell list specified
by the parameter.
cells - a list of cells to assign to this Specimenvoid clearCells()
public int size()
public boolean isEmpty()
true if the sequence contains no cells.
true if the sequence contains no cells.
false otherwise.public java.lang.String toString()
Specimen.
toString in class java.lang.ObjectSpecimen.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||