Package adams.flow.condition.test
Class AbstractTestCondition
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.condition.test.AbstractTestCondition
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<TestCondition>
,SizeOfHandler
,TestCondition
,Serializable
,Comparable
- Direct Known Subclasses:
AbstractScript
,AbstractScriptedCondition
,DirExists
,FileExists
,MultiCondition
,True
public abstract class AbstractTestCondition extends AbstractOptionHandler implements Comparable, TestCondition
Abstract base class for conditions. Derived classes only have to override theperformTest()
method. Thereset()
method can be used to reset an algorithms internal state, e.g., after setting options, which invalidate the previously run tests.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_Tested
whether the condition has been tested.protected String
m_TestResult
the test result, null=test passed, otherwise error message.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractTestCondition()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(Object o)
Compares this object with the specified object for order.boolean
equals(Object o)
Returns whether the two objects are the same.static TestCondition
forCommandLine(String cmdline)
Instantiates the filter from the given commandline (i.e., classname and optional options).static TestCondition
forName(String classname, String[] options)
Instantiates the filter with the given options.static String[]
getConditions()
Returns a list with classnames of filters.String
getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.String
getTestResult()
Returns the test result of testing the conditions.protected void
initialize()
Initializes the members.protected abstract String
performTest()
Performs the actual testing of the condition.void
reset()
Resets the condition.TestCondition
shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.TestCondition
shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Tested
protected boolean m_Tested
whether the condition has been tested.
-
m_TestResult
protected String m_TestResult
the test result, null=test passed, otherwise error message.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractOptionHandler
-
reset
public void reset()
Resets the condition. Derived classes must call this method in set-methods of parameters to assure the invalidation of previously generated data.- Overrides:
reset
in classAbstractOptionHandler
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.
Default implementation returns null.- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Specified by:
getQuickInfo
in interfaceTestCondition
- Returns:
- null if no info available, otherwise short string
-
performTest
protected abstract String performTest()
Performs the actual testing of the condition.- Returns:
- the test result, null if everything OK, otherwise the error message
-
getTestResult
public String getTestResult()
Returns the test result of testing the conditions. Performs the test, if necessary.- Specified by:
getTestResult
in interfaceTestCondition
- Returns:
- the test result, null if everything OK, otherwise the error message
-
compareTo
public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Only compares the commandlines of the two objects.- Specified by:
compareTo
in interfaceComparable
- Parameters:
o
- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException
- if the specified object's type prevents it from being compared to this object.
-
equals
public boolean equals(Object o)
Returns whether the two objects are the same.
Only compares the commandlines of the two objects.
-
shallowCopy
public TestCondition shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceShallowCopySupporter<TestCondition>
- Specified by:
shallowCopy
in interfaceTestCondition
- Returns:
- the shallow copy
-
shallowCopy
public TestCondition shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopy
in interfaceShallowCopySupporter<TestCondition>
- Specified by:
shallowCopy
in interfaceTestCondition
- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
getConditions
public static String[] getConditions()
Returns a list with classnames of filters.- Returns:
- the filter classnames
-
forName
public static TestCondition forName(String classname, String[] options)
Instantiates the filter with the given options.- Parameters:
classname
- the classname of the filter to instantiateoptions
- the options for the filter- Returns:
- the instantiated filter or null if an error occurred
-
forCommandLine
public static TestCondition forCommandLine(String cmdline)
Instantiates the filter from the given commandline (i.e., classname and optional options).- Parameters:
cmdline
- the classname (and optional options) of the filter to instantiate- Returns:
- the instantiated filter or null if an error occurred
-
-