marf.Storage
Class ResultSet

java.lang.Object
  extended by marf.Storage.ResultSet
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class ResultSet
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Class ResultSet represents classification result set - IDs and some stats. May be sorted.

$Id: ResultSet.java,v 1.22 2007/12/23 06:29:46 mokhov Exp $

Since:
0.3.0.2
Version:
$Revision: 1.22 $
Author:
Serguei Mokhov
See Also:
Serialized Form

Field Summary
protected  Result[] aoResultSetSorted
          References to the objects in the oResultSet in the sorted order.
protected  int iSortMode
          Used to remember in which direction sorting was performed, so some methods can work correctly.
protected  java.util.Vector oResultSet
          Distances from other samples and other stats or probabilities and likelihood (growable and shrinkable).
private static long serialVersionUID
          For serialization versioning.
static int UNSORTED
          Indicates that this result set is unsorted.
 
Constructor Summary
ResultSet()
          Default constructor, which is equivalent to ResultSet(new Vector()).
ResultSet(ResultSet poResultSet)
          Copy-constructor.
ResultSet(java.util.Vector poResultSet)
          ID Vector ResultSet Constructor.
 
Method Summary
 void addResult(int piID, double pdOutcome)
          Add result to the result set.
 void addResult(int piID, double pdOutcome, java.lang.String pstrDescription)
          Add result to the result set.
 void addResult(Result poResult)
          Add result to the result set based on already pre-constructed object.
 java.lang.Object clone()
          Implements Cloneable interface for the ResultSet object.
 int getAverageID()
          Retrieves ID of a subject with average distance/probability.
 Result getAverageResult()
          Retrieves the result from the result set with the average outcome value.
static java.lang.String getMARFSourceCodeRevision()
          Returns source code revision information.
 int getMaximumID()
          Retrieves ID of a subject with maximum distance/probability.
 Result getMaximumResult()
          Retrieves the result from the result set with the maximum outcome value.
 Result getMinimumResult()
          Retrieves the result from the result set with the minimum outcome value.
 int getMininumID()
          Retrieves ID of a subject with minimum distance/probability.
 int getRandomID()
          Retrieves a pseudo random ID of a subject.
 Result getRandomResult()
          Retrieves pseudo-random result object from the result set.
 Result[] getResultSetSorted()
          Allows querying the current array of references to the contained Result objects sorted (if sorting was performed).
 java.util.Vector getResultSetVector()
          Retrieves the underlying unsorted result collection.
 int getSecondClosestID()
          Returns second closest ID.
 int getSecondMaximumID()
          Retrieves ID of a subject with the distance/probability next to the maximum.
 int getSecondMininumID()
          Retrieves ID of a subject with the distance/probability next to the minimum.
 int getSortMode()
          Allows querying the sort mode the result set may be currently sorted in accordance with.
 void setResultSetSorted(Result[] paoResultSetSorted)
          Allows setting the current array of sorted references to the contained Result objects if sorted outside.
 void setResultSetVector(java.util.Vector poResultSet)
          Sets the underlying unsorted result collection.
 void setSortMode(int piSortMode)
          Allows setting the sort mode the result set may be sorted next time in accordance with.
 int size()
          Retrieves result count of the results in this result set.
 void sort(int piMode)
          Perform sorting of the results in the result set.
 java.lang.String toString()
          Returns inner ResultSet data converted to string.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNSORTED

public static final int UNSORTED
Indicates that this result set is unsorted.

Since:
0.3.0.4
See Also:
Constant Field Values

oResultSet

protected java.util.Vector oResultSet
Distances from other samples and other stats or probabilities and likelihood (growable and shrinkable).


aoResultSetSorted

protected Result[] aoResultSetSorted
References to the objects in the oResultSet in the sorted order.


iSortMode

protected int iSortMode
Used to remember in which direction sorting was performed, so some methods can work correctly. Default is UNSORTED. Otherwise, it is SortComparator.ASCENDING or SortComparator.DESCENDING. It is set by the sort() method only.

Since:
0.3.0.3
See Also:
getSecondClosestID(), sort(int), SortComparator.ASCENDING, SortComparator.DESCENDING, UNSORTED

serialVersionUID

private static final long serialVersionUID
For serialization versioning. When adding new members or make other structural changes regenerate this number with the serialver tool that comes with JDK.

Since:
0.3.0.4
See Also:
Constant Field Values
Constructor Detail

ResultSet

public ResultSet()
Default constructor, which is equivalent to ResultSet(new Vector()).


ResultSet

public ResultSet(java.util.Vector poResultSet)
ID Vector ResultSet Constructor.

Parameters:
poResultSet - Vector of relevant data
Throws:
java.lang.IllegalArgumentException - if the parameter is null

ResultSet

public ResultSet(ResultSet poResultSet)
Copy-constructor.

Parameters:
poResultSet - ResultSet object reference to make a copy of
Since:
0.3.0.5
Method Detail

getMininumID

public final int getMininumID()
Retrieves ID of a subject with minimum distance/probability.

Returns:
integer ID
Throws:
java.lang.ArrayIndexOutOfBoundsException - if there are no results

getSecondMininumID

public final int getSecondMininumID()
Retrieves ID of a subject with the distance/probability next to the minimum.

Returns:
integer ID
Throws:
java.lang.ArrayIndexOutOfBoundsException - if there is only one or no result in the result set.

getMaximumID

public final int getMaximumID()
Retrieves ID of a subject with maximum distance/probability.

Returns:
integer ID
Throws:
java.lang.ArrayIndexOutOfBoundsException - if there are no results

getSecondMaximumID

public final int getSecondMaximumID()
Retrieves ID of a subject with the distance/probability next to the maximum.

Returns:
integer ID
Throws:
java.lang.ArrayIndexOutOfBoundsException - if there is only one or no result in the result set.

getSecondClosestID

public final int getSecondClosestID()
Returns second closest ID.

Returns:
ID of an entity (speaker, instrument, emotion, etc.); or -1 if the first ID was not retrieved yet.
See Also:
getSecondMininumID(), getSecondMaximumID()

getAverageID

public final int getAverageID()
Retrieves ID of a subject with average distance/probability.

Returns:
integer ID
Throws:
java.lang.ArrayIndexOutOfBoundsException - if there are no results

getRandomID

public final int getRandomID()
Retrieves a pseudo random ID of a subject. Used in the base-line testing.

Returns:
integer ID
Throws:
java.lang.ArrayIndexOutOfBoundsException - if there are no results

sort

public final void sort(int piMode)
Perform sorting of the results in the result set.

Parameters:
piMode - sorting mode, either SortComparator.ASCENDING or SortComparator.DESCENDING.
Throws:
java.lang.IllegalArgumentException - if the parameter is neither of the two modes
See Also:
SortComparator.ASCENDING, SortComparator.DESCENDING

addResult

public final void addResult(int piID,
                            double pdOutcome,
                            java.lang.String pstrDescription)
Add result to the result set.

Parameters:
piID - subject ID recognized
pdOutcome - outcome of the recognition distance or likelihood
pstrDescription - textual description of the result

addResult

public final void addResult(int piID,
                            double pdOutcome)
Add result to the result set. Generates description based on the two parameters.

Parameters:
piID - subject ID recognized
pdOutcome - outcome of the recognition distance or likelihood

addResult

public final void addResult(Result poResult)
Add result to the result set based on already pre-constructed object.

Parameters:
poResult - Result object prepared outside
Throws:
java.lang.IllegalArgumentException - of the parameter is null

getMinimumResult

public Result getMinimumResult()
Retrieves the result from the result set with the minimum outcome value.

Returns:
corresponding Result object

getAverageResult

public Result getAverageResult()
Retrieves the result from the result set with the average outcome value.

Returns:
corresponding Result object

getRandomResult

public Result getRandomResult()
Retrieves pseudo-random result object from the result set. Used in base-line testing.

Returns:
corresponding Result object

getMaximumResult

public Result getMaximumResult()
Retrieves the result from the result set with the maximum outcome value.

Returns:
corresponding Result object

getResultSetVector

public java.util.Vector getResultSetVector()
Retrieves the underlying unsorted result collection.

Returns:
Vector of Results

getResultSetSorted

public Result[] getResultSetSorted()
Allows querying the current array of references to the contained Result objects sorted (if sorting was performed). The sorting is usually done when querying for minimum or maximum results.

Returns:
Returns the aoResultSetSorted.
Since:
0.3.0.5

setResultSetVector

public void setResultSetVector(java.util.Vector poResultSet)
Sets the underlying unsorted result collection.

Parameters:
poResultSet - the result set vector to set
Since:
0.3.0.6

setResultSetSorted

public void setResultSetSorted(Result[] paoResultSetSorted)
Allows setting the current array of sorted references to the contained Result objects if sorted outside.

Parameters:
paoResultSetSorted - the new collection of sorted references
Since:
0.3.0.6

setSortMode

public void setSortMode(int piSortMode)
Allows setting the sort mode the result set may be sorted next time in accordance with.

Parameters:
piSortMode - the sort mode to set
Since:
0.3.0.6
See Also:
UNSORTED, SortComparator.ASCENDING, SortComparator.DESCENDING, iSortMode

getSortMode

public final int getSortMode()
Allows querying the sort mode the result set may be currently sorted in accordance with.

Returns:
the current sort mode
Since:
0.3.0.5
See Also:
UNSORTED, SortComparator.ASCENDING, SortComparator.DESCENDING, iSortMode

toString

public java.lang.String toString()
Returns inner ResultSet data converted to string.

Overrides:
toString in class java.lang.Object
Returns:
String representation of a ResultSet object

size

public int size()
Retrieves result count of the results in this result set.

Returns:
integer result count

clone

public java.lang.Object clone()
Implements Cloneable interface for the ResultSet object.

Overrides:
clone in class java.lang.Object
Since:
0.3.0.5
See Also:
Object.clone()

getMARFSourceCodeRevision

public static java.lang.String getMARFSourceCodeRevision()
Returns source code revision information.

Returns:
revision string


SourceForge Logo