Package adams.flow.container
Class AbstractContainer
- java.lang.Object
-
- adams.flow.container.AbstractContainer
-
- All Implemented Interfaces:
CloneHandler<Container>
,GlobalInfoSupporter
,SpreadSheetSupporter
,Container
,Serializable
- Direct Known Subclasses:
AbstractFilterContainer
,ControlChartContainer
,EncapsulatedActorsContainer
,FeatureConverterContainer
,FileBasedDatasetContainer
,HttpRequestResult
,ImageSegmentationContainer
,OutlierContainer
,OutlierDetectorContainer
,PredictionEccentricityContainer
,ProcessActorContainer
,RemoteCommandContainer
,SequencePlotterContainer
,SpreadSheetCellSelectionContainer
,TimingContainer
,TrainTestSetContainer
,WekaAttributeSelectionContainer
,WekaClusterEvaluationContainer
,WekaClusteringContainer
,WekaEvaluationContainer
,WekaExperimentContainer
,WekaFilterContainer
,WekaForecastContainer
,WekaGeneticAlgorithmContainer
,WekaGeneticAlgorithmInitializationContainer
,WekaModelContainer
,WekaNearestNeighborSearchContainer
,WekaPredictionContainer
,WekaTrainTestSetContainer
public abstract class AbstractContainer extends Object implements Container
Ancestor of all containers. A container allows the access to the stored values via their names.
NB: containers need to declare a default constructor. The default constructor is used to generate help information.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractContainer()
Initializes the container.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
addAdditionalName(String name)
Adds the specified name as valid name for a value.void
addHelp(String name, String desc)
Stores the help for the given name if valid name.void
addHelp(String name, String desc, Class type)
Stores the help for the given name if valid name.void
addHelp(String name, String desc, Class[] types)
Stores the help for the given name if valid name.protected void
checkDefaultConstructor()
Checks whether a default constructor is available - necessary for generating HTML help.AbstractContainer
getClone()
Returns a clone of itself using serialization.String
getHelp(String name)
Returns the help associated with the given name.Object
getValue(String name)
Returns the value associated with the given name.<T> T
getValue(String name, Class<T> cls)
Returns the value associated with the given name.String
globalInfo()
Returns a short info on the container, namely the value names.boolean
hasHelp(String name)
Checks whether a given help is non-null.boolean
hasValue(String name)
Checks whether a given value is non-null.protected void
initHelp()
Initializes the help strings.abstract boolean
isValid()
Checks whether the setup of the container is valid.protected boolean
isValidName(String name)
Checks whether the name of the object is valid.abstract Iterator<String>
names()
Returns all value names that can be used (theoretically).boolean
removeAdditionalName(String name)
Removes the additional name again.boolean
setValue(String name, Object value)
Sets the named value.protected boolean
store(String name, Object value)
Stores the value under the name.Iterator<String>
stored()
Returns all available stored value names.SpreadSheet
toSpreadSheet()
Returns the content as spreadsheet.String
toString()
Returns a short description of the stored data.
-
-
-
Method Detail
-
checkDefaultConstructor
protected void checkDefaultConstructor()
Checks whether a default constructor is available - necessary for generating HTML help.
-
getClone
public AbstractContainer getClone()
Returns a clone of itself using serialization.- Specified by:
getClone
in interfaceCloneHandler<Container>
- Specified by:
getClone
in interfaceContainer
- Returns:
- the clone
-
globalInfo
public String globalInfo()
Returns a short info on the container, namely the value names.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Returns:
- the info
-
addHelp
public void addHelp(String name, String desc)
Stores the help for the given name if valid name.- Specified by:
addHelp
in interfaceContainer
- Parameters:
name
- the name to store the help underdesc
- the help description- See Also:
isValidName(String)
-
addHelp
public void addHelp(String name, String desc, Class type)
Stores the help for the given name if valid name.- Specified by:
addHelp
in interfaceContainer
- Parameters:
name
- the name to store the help underdesc
- the help descriptiontype
- the type of the data- See Also:
isValidName(String)
-
addHelp
public void addHelp(String name, String desc, Class[] types)
Stores the help for the given name if valid name.- Specified by:
addHelp
in interfaceContainer
- Parameters:
name
- the name to store the help underdesc
- the help descriptiontypes
- the types of the data- See Also:
isValidName(String)
-
initHelp
protected void initHelp()
Initializes the help strings.
Default implementation does nothing.
-
names
public abstract Iterator<String> names()
Returns all value names that can be used (theoretically).
-
hasValue
public boolean hasValue(String name)
Checks whether a given value is non-null.
-
getValue
public <T> T getValue(String name, Class<T> cls)
Returns the value associated with the given name.
-
hasHelp
public boolean hasHelp(String name)
Checks whether a given help is non-null.
-
isValidName
protected boolean isValidName(String name)
Checks whether the name of the object is valid.- Parameters:
name
- the name to check- Returns:
- true if valid
- See Also:
names()
-
store
protected boolean store(String name, Object value)
Stores the value under the name.- Parameters:
name
- the name of the valuevalue
- the value to store- Returns:
- true if successfully stored, i.e., value is not null
-
isValid
public abstract boolean isValid()
Checks whether the setup of the container is valid.
-
addAdditionalName
public boolean addAdditionalName(String name)
Adds the specified name as valid name for a value.- Specified by:
addAdditionalName
in interfaceContainer
- Parameters:
name
- the name to add- Returns:
- true if the additional names list changed
-
removeAdditionalName
public boolean removeAdditionalName(String name)
Removes the additional name again.- Specified by:
removeAdditionalName
in interfaceContainer
- Parameters:
name
- the name to remove- Returns:
- true if the name was present and got removed
-
toString
public String toString()
Returns a short description of the stored data.
-
toSpreadSheet
public SpreadSheet toSpreadSheet()
Returns the content as spreadsheet.- Specified by:
toSpreadSheet
in interfaceContainer
- Specified by:
toSpreadSheet
in interfaceSpreadSheetSupporter
- Returns:
- the content
-
-