Package adams.flow.processor
Class AbstractActorProcessor
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.processor.AbstractActorProcessor
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,ShallowCopySupporter<ActorProcessor>,SizeOfHandler,ActorProcessor,Serializable,Comparable<ActorProcessor>
- Direct Known Subclasses:
AbstractListingProcessor,AbstractModifyingProcessor,ActorStatistics,CheckActorReferenceUsage,CheckPlaceholders,CheckStorageUsage,CheckVariableUsage,ListAllStorageNames,ListAllVariables
public abstract class AbstractActorProcessor extends AbstractOptionHandler implements ActorProcessor
Abstract base class for schemes that process a flow/actor in some fashion. Derived classes only have to override theprocessActor()method. Thereset()method can be used to reset an algorithms internal state, e.g., after setting options, which invalidate the previously generated data.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<String>m_Errorsfor collecting errors.-
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 AbstractActorProcessor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddError(String msg)Adds the error message to the internal list of errors.protected voidaddError(String msg, boolean output)Adds the error message to the internal list of errors and optionally outputs it on stderr.protected voidcheckData(Actor actor)The default implementation only checks whether there is any actor set.intcompareTo(ActorProcessor o)Compares this object with the specified object for order.booleanequals(Object o)Returns whether the two objects are the same.List<String>getErrors()Returns the list of errors (if any).booleanhasErrors()Checks whether any errors were encountered.protected voidinitialize()Initializes the members.voidprocess(Actor actor)Processes the actor.protected abstract voidprocessActor(Actor actor)Performs the actual processing.voidreset()Resets the scheme.ActorProcessorshallowCopy()Returns a shallow copy of itself, i.e., based on the commandline options.ActorProcessorshallowCopy(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.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, defineOptions, getOptionManager, toCommandLine
-
-
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractOptionHandler
-
reset
public void reset()
Resets the scheme.- Overrides:
resetin classAbstractOptionHandler
-
process
public void process(Actor actor)
Processes the actor.- Specified by:
processin interfaceActorProcessor- Parameters:
actor- the actor to process
-
checkData
protected void checkData(Actor actor)
The default implementation only checks whether there is any actor set.- Parameters:
actor- the actor to process
-
processActor
protected abstract void processActor(Actor actor)
Performs the actual processing.- Parameters:
actor- the actor to process (is a copy of original for processors implementing ModifyingProcessor)- See Also:
ModifyingProcessor
-
addError
protected void addError(String msg)
Adds the error message to the internal list of errors. Outputs the error on stderr as well.- Parameters:
msg- the error message to add
-
addError
protected void addError(String msg, boolean output)
Adds the error message to the internal list of errors and optionally outputs it on stderr.- Parameters:
msg- the error message to add
-
hasErrors
public boolean hasErrors()
Checks whether any errors were encountered.- Specified by:
hasErrorsin interfaceActorProcessor- Returns:
- true if errors were encountered
- See Also:
getErrors()
-
getErrors
public List<String> getErrors()
Returns the list of errors (if any).- Specified by:
getErrorsin interfaceActorProcessor- Returns:
- the errors
-
compareTo
public int compareTo(ActorProcessor 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:
compareToin interfaceActorProcessor- Specified by:
compareToin interfaceComparable<ActorProcessor>- 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 ActorProcessor shallowCopy()
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopyin interfaceActorProcessor- Specified by:
shallowCopyin interfaceShallowCopySupporter<ActorProcessor>- Returns:
- the shallow copy
-
shallowCopy
public ActorProcessor shallowCopy(boolean expand)
Returns a shallow copy of itself, i.e., based on the commandline options.- Specified by:
shallowCopyin interfaceActorProcessor- Specified by:
shallowCopyin interfaceShallowCopySupporter<ActorProcessor>- Parameters:
expand- whether to expand variables to their current values- Returns:
- the shallow copy
-
-