de.jstacs.results
Class Result

java.lang.Object
  extended by de.jstacs.results.Result
All Implemented Interfaces:
Storable
Direct Known Subclasses:
AbstractScoreBasedClassifier.DoubleTableResult, GalaxyAdaptor.FileResult, ImageResult, ListResult, SampleResult, SimpleResult, StorableResult

public abstract class Result
extends Object
implements Storable

The abstract class for any result. Each result should be immutable. In analogy to the Parameter classes, the Result classes provide the possibility to return the results of a computation together with some annotation in a standardized way.

Author:
Jan Grau

Field Summary
protected  String comment
          The comment for the result.
protected  DataType datatype
          The data type of the result.
protected  String name
          The name of the result.
 
Constructor Summary
protected Result(StringBuffer rep)
          The standard constructor for the interface Storable.
protected Result(String name, String comment, DataType datatype)
          The main constructor which takes the main information of a result.
 
Method Summary
protected  void appendMainInfo(StringBuffer buf)
          This method can be used in the method Storable.toXML() to append the main information (name, comment, datatype).
static boolean checkDatatype(DataType datatype, Object value)
          This method provides the possibility to check the compliance of some result value with one of the pre-defined DataTypes before creating a new Result and possibly running into an Exception.
static Result createResult(String name, String comment, DataType datatype, Object value)
          Factory method to create a new Result.
protected  void extractMainInfo(StringBuffer buf)
          This method can be used in the method fromXML(StringBuffer) to extract the main information (name, comment, data type).
protected abstract  void fromXML(StringBuffer rep)
          This method is used in Result(StringBuffer) to extract the information.
 String getComment()
          Returns the comment on the Result.
 DataType getDatatype()
          Returns the data type of the Result.
 String getName()
          Returns the name of the Result.
abstract  Object getResult()
          Returns the value of the Result.
 boolean isCastableResult(Result test)
          Returns true if the data type of the Result test can be casted to that of this instance and both have the same name and comment for the Result.
 boolean isComparableResult(Result test)
          Returns true if the Result test and the current object have the same data type, name and comment for the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jstacs.Storable
toXML
 

Field Detail

name

protected String name
The name of the result.


comment

protected String comment
The comment for the result.


datatype

protected DataType datatype
The data type of the result.

Constructor Detail

Result

protected Result(String name,
                 String comment,
                 DataType datatype)
The main constructor which takes the main information of a result.

Parameters:
name - the name of the result
comment - the comment for the result
datatype - the data type of the result

Result

protected Result(StringBuffer rep)
          throws NonParsableException
The standard constructor for the interface Storable. Creates a new Result out of its XML representation.

Parameters:
rep - the XML representation as StringBuffer
Throws:
NonParsableException - if the XML representation is not parsable
See Also:
Storable
Method Detail

fromXML

protected abstract void fromXML(StringBuffer rep)
                         throws NonParsableException
This method is used in Result(StringBuffer) to extract the information. The method can be seen as opposite of Storable.toXML() and should not be made public.

Parameters:
rep - the XML represenation of the Result to be parsed
Throws:
NonParsableException - if the XML representation is not parsable
See Also:
extractMainInfo(StringBuffer)

appendMainInfo

protected void appendMainInfo(StringBuffer buf)
This method can be used in the method Storable.toXML() to append the main information (name, comment, datatype).

Parameters:
buf - a XML representation of the main information as StringBuffer
See Also:
Storable.toXML()

extractMainInfo

protected void extractMainInfo(StringBuffer buf)
                        throws NonParsableException
This method can be used in the method fromXML(StringBuffer) to extract the main information (name, comment, data type).

Parameters:
buf - a XML represenation of the main information as StringBuffer
Throws:
NonParsableException - if the XML representation is not parsable
See Also:
fromXML(StringBuffer)

getDatatype

public final DataType getDatatype()
Returns the data type of the Result.

Returns:
the data type of the Result

getResult

public abstract Object getResult()
Returns the value of the Result.

Returns:
the value of the Result

getName

public final String getName()
Returns the name of the Result.

Returns:
the name of the Result

getComment

public final String getComment()
Returns the comment on the Result.

Returns:
the comment on the Result

isComparableResult

public boolean isComparableResult(Result test)
Returns true if the Result test and the current object have the same data type, name and comment for the result.
The method does NOT answer whether the method getResult() returns an instance of Comparable.

Parameters:
test - the Result to be tested
Returns:
true if the Result test and the current object have the same data type, name and comment for the result

isCastableResult

public boolean isCastableResult(Result test)
Returns true if the data type of the Result test can be casted to that of this instance and both have the same name and comment for the Result.
The method does NOT answer whether the method getResult() returns an instance of Comparable.

Parameters:
test - the Result to be tested
Returns:
true if the Result test and the current object have a castable data type, name and comment for the result

checkDatatype

public static boolean checkDatatype(DataType datatype,
                                    Object value)
This method provides the possibility to check the compliance of some result value with one of the pre-defined DataTypes before creating a new Result and possibly running into an Exception.

Parameters:
datatype - the data type the value should comply to
value - the value
Returns:
if value can be stored in a Result of DataType datatype

createResult

public static Result createResult(String name,
                                  String comment,
                                  DataType datatype,
                                  Object value)
                           throws SimpleParameter.IllegalValueException
Factory method to create a new Result.

Parameters:
name - the name of the Result as chosen by the user
comment - the comment on the Result as chosen by the user
datatype - the data type of value
value - the value of the Result
Returns:
the new Result instance
Throws:
SimpleParameter.IllegalValueException - if datatype is DataType.HTML, DataType.LIST or another DataType not implemented, yet