com.yosokumo.core
Class PredictorBlock

java.lang.Object
  extended by com.yosokumo.core.Block
      extended by com.yosokumo.core.PredictorBlock

 class PredictorBlock
extends Block

Represents a block of Predictors.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.yosokumo.core.Block
Block.Type
 
Field Summary
private  java.util.List<Predictor> predictorSequence
          A sequence of Predictors.
 
Constructor Summary
PredictorBlock()
          Initializes a newly created PredictorBlock object with default attributes.
PredictorBlock(java.util.Collection<Predictor> predictorCollection)
          Initializes a newly created PredictorBlock object with the predictor sequence specified by the input parameter.
PredictorBlock(java.lang.String id)
          Initializes a newly created PredictorBlock object with a study identifier.
PredictorBlock(java.lang.String id, java.util.Collection<Predictor> predictorCollection)
          Initializes a newly created PredictorBlock object with the study identifier and the predictor sequence specified by the input parameters.
 
Method Summary
(package private)  void addPredictor(Predictor predictor)
          Add a Predictor to the block.
(package private)  boolean addPredictors(java.util.Collection<Predictor> predictors)
          Add a collection of Predictors to the block.
(package private)  void clearPredictors()
          Remove all predictors from the block.
(package private)  Predictor getPredictor(int index)
          Return a predictor from the block.
(package private)  java.util.List<Predictor> getPredictorSequence()
          Return all predictors in the block as a List<Predictor>.
(package private)  Block.Type getType()
          Return the predictor block type.
(package private)  boolean isEmpty()
          Return true if the block contains no predictors.
(package private)  boolean removePredictors(int numPredictorsToRemove)
          Remove predictors from the end of the block.
(package private)  int size()
          Return the number of predictors in the block.
 java.lang.String toString()
          Return a string representation of this PredictorBlock.
 
Methods inherited from class com.yosokumo.core.Block
getStudyIdentifier, setStudyIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

predictorSequence

private java.util.List<Predictor> predictorSequence
A sequence of Predictors.

Constructor Detail

PredictorBlock

PredictorBlock()
Initializes a newly created PredictorBlock object with default attributes.


PredictorBlock

PredictorBlock(java.lang.String id)
Initializes a newly created PredictorBlock object with a study identifier.

Parameters:
id - a study identifier for the block.

PredictorBlock

PredictorBlock(java.util.Collection<Predictor> predictorCollection)
Initializes a newly created PredictorBlock object with the predictor sequence specified by the input parameter.

Parameters:
predictorCollection - the predictor sequence of the specimen.

PredictorBlock

PredictorBlock(java.lang.String id,
               java.util.Collection<Predictor> predictorCollection)
Initializes a newly created PredictorBlock object with the study identifier and the predictor sequence specified by the input parameters.

Parameters:
id - a study identifier for the block.
predictorCollection - the predictor sequence of the specimen.
Method Detail

getType

Block.Type getType()
Return the predictor block type.

Specified by:
getType in class Block
Returns:
the predictor block type: Type.PREDICTOR.

addPredictor

void addPredictor(Predictor predictor)
Add a Predictor to the block. The predictor parameter is appended to the end of the predictor sequence.

Parameters:
predictor - the Predictor to add to the block.

addPredictors

boolean addPredictors(java.util.Collection<Predictor> predictors)
Add a collection of Predictors to the block. The Predictors in the collection specified by the parameter are appended to the end of the predictor sequence. The order the predictors are appended is the order in which the collection's Iterator returns the predictors.

Parameters:
predictors - the collection of Predictors to add to the block.
Returns:
true if and only if the predictor sequence changes.

removePredictors

boolean removePredictors(int numPredictorsToRemove)
Remove predictors from the end of the block. The specified number of predictors are removed from the end of the predictor sequence.

Parameters:
numPredictorsToRemove - is the number of predictors to remove from the end of the block. If this value is zero or negative, no predictors are removed. If this value exceeds the number of predictors in the block, then all predictors are removed.
Returns:
true if and only if the sequence is changed.

getPredictor

Predictor getPredictor(int index)
Return a predictor from the block. This makes it possible to iterate over all predictors in the sequence like this:
   for (int i = 0;  i < predictorSequence.size();  ++i)
   {
       Predictor c = predictorSequence.getPredictor(i)
       process predictor c
   }
 
Caution: It is better to iterate over all predictors by using getPredictorSequence 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.

Parameters:
index - specifying the predictor of the 0-based block.
Returns:
the Predictor at the location specified by the index.

getPredictorSequence

java.util.List<Predictor> getPredictorSequence()
Return all predictors in the block as a List<Predictor>. This makes it possible to iterate over all predictors in the block like this:
   for (Predictor c : predictorSequence.getPredictorSequence())
   {
       process predictor c
   }
 

Returns:
a sequence of all predictors in the predictor sequence.

clearPredictors

void clearPredictors()
Remove all predictors from the block. After a call of this method, the sequence is empty, i.e., it contains no predictors.


size

int size()
Return the number of predictors in the block.

Returns:
the number of predictors in the block.

isEmpty

boolean isEmpty()
Return true if the block contains no predictors.

Returns:
true if the block contains no predictors. false otherwise.

toString

public java.lang.String toString()
Return a string representation of this PredictorBlock.

Specified by:
toString in class Block
Returns:
the string representation of this PredictorBlock.