nz.ac.waikato.mcennis.rat
Class AbstractFactory<Type>

java.lang.Object
  extended by nz.ac.waikato.mcennis.rat.AbstractFactory<Type>
Direct Known Subclasses:
ActorFactory, ActorQueryFactory, ActorQueryXMLFactory, AggregatorFunctionFactory, AggregatorXMLFactory, AlgorithmFactory, ANOVASignificanceTestFactory, CrawlerFilterFactory, DataAquisitionFactory, DataVectorXMLFactory, DistanceFactory, DistanceXMLFactory, GraphComparisonFactory, GraphFactory, GraphQueryFactory, GraphQueryXMLFactory, HandlerFactory, IndependentStatisticsTestFactory, InstanceFactoryFactory, IODescriptorFactory, LinkFactory, LinkQueryFactory, LinkQueryXMLFactory, ParameterFactory, ParserFactory, PropertiesFactory, PropertyFactory, PropertyQueryFactory, PropertyQueryXMLFactory, PropertyValueDatabaseFactory, PropertyValueXMLFactory, PropertyXMLFactory, SchedulerFactory, StopConditionFactory, SyntaxCheckerFactory

public abstract class AbstractFactory<Type>
extends java.lang.Object

Base class for all Factory objects in Graph-RAT. Any new types added to Graph-RAT should sub-class this object. The following additional static code should also be added in order to activate automated inclusion in the DynamicLoader: public static void initialization(){ if(instance == null){ DynamicLoader.initialization(); instance = new {Factory Constructor}(); DynamicLoader.newInstance().addFactoryType(instance); } } static public {FactoryName} newInstance(){ initialization(); return instance; } The parameters consist of:


Field Summary
protected  java.util.HashMap<java.lang.String,Type> map
           
protected  PropertiesInternal properties
           
 
Constructor Summary
protected AbstractFactory()
          Abstract Superconstructor creating metadata common to all factory objects.
 
Method Summary
 void addDefaultProperty(java.lang.String type, java.lang.Object value)
          Set a default value in the factory's internal properties object.
 void addType(java.lang.String type, Type prototype)
          Registers the given value as a prototype linked with the given name key.
 boolean check(Parameter parameter)
          Verify, without modifying the underlying property lists, that the given Parameter object can be merged with this factory, satisfying all constraints.
 boolean check(Properties props)
          Verify, without modifying the underlying property lists, that the given Properties object can be merged with this factory, satisfying all constraints.
abstract  Type create(Properties props)
          Create the given object using the settings in the Properties object.
abstract  Parameter getClassParameter()
          Return the parameter containing the name of the default type produced by this object.
 java.util.Collection<java.lang.String> getKnownTypes()
          Obtain a collection containing all of the string key names describing all object types this factory can produce.
 Properties getParameter()
          Get all parameters associated with this object.
 Parameter getParameter(java.lang.String type)
          Obtain a particular parameter with the given string as its key.
 void setDefaultProperty(ParameterInternal value)
          Set a default value in the factory's internal properties object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected java.util.HashMap<java.lang.String,Type> map

properties

protected PropertiesInternal properties
Constructor Detail

AbstractFactory

protected AbstractFactory()
Abstract Superconstructor creating metadata common to all factory objects. This consists of creating a Graph-RAT Properties object (properties) and creating an empty prototype map (map).

Method Detail

create

public abstract Type create(Properties props)
Create the given object using the settings in the Properties object. This function is the only global creation object, but each factory should also define a more user-friendly version consisting of a set of commonly used creation parameters as well as a version combining commonly used features with a Properties object. The property may be null. if the creation fails, the factory should log to the Logger the explanation and return null. If at all possible, the factory should provide a reasonable fail-over value rather than return null.

Parameters:
props - parameters used to control the factory.
Returns:
newly created object or null

setDefaultProperty

public void setDefaultProperty(ParameterInternal value)
Set a default value in the factory's internal properties object. If the property already exists, it overwrites the given value as determined by the replace(ParameterInternal) procedure on the Properties object. Null values are permitted, resulting in a warning and a null-operation.

Parameters:
value - property to set as default.
See Also:
Properties.replace(ParameterInternal)

addDefaultProperty

public void addDefaultProperty(java.lang.String type,
                               java.lang.Object value)
                        throws InvalidObjectTypeException
Set a default value in the factory's internal properties object. If the property already exists, it adds the given value to the list of parameter settings as determined by the add(String,Object) procedure on the Properties object. Null values are permitted, resulting in a warning and a null-operation.

Parameters:
value - property to set as default.
Throws:
InvalidObjectTypeException
See Also:
Properties.replace(ParameterInternal)

getParameter

public Properties getParameter()
Get all parameters associated with this object. By default, this returns a reference, not a copy

Returns:
Properties object backing this factory

getParameter

public Parameter getParameter(java.lang.String type)
Obtain a particular parameter with the given string as its key. By default, the parameter is a reference, not a copy. Null values are permitted, resulting in a warning and a null parameter. If no parameters of the given type are defined, a null value is returned.

Parameters:
type - parameter key
Returns:
parameter with the given key

addType

public void addType(java.lang.String type,
                    Type prototype)
Registers the given value as a prototype linked with the given name key. This makes the assumption that all objects returned by this factory implement the Prototype pattern.

Parameters:
type - key that indicates that the given object should be created
prototype - prototype of an object this factory can return.

check

public boolean check(Properties props)
Verify, without modifying the underlying property lists, that the given Properties object can be merged with this factory, satisfying all constraints. nulls are permitted, resulting in a check of the internal Properties object only.

Parameters:
props - Properties object that might be merged in
Returns:
will the merged result satisfy property constraints

check

public boolean check(Parameter parameter)
Verify, without modifying the underlying property lists, that the given Parameter object can be merged with this factory, satisfying all constraints. nulls are permitted, returning false.

Parameters:
props - Parameter object that might be merged in
Returns:
will the merged result satisfy property constraints

getClassParameter

public abstract Parameter getClassParameter()
Return the parameter containing the name of the default type produced by this object. The parameter will have exactly one value of type String. The type name of this parameter is the type that controls which class of object is produced.

Returns:
parameter containing the default type.

getKnownTypes

public java.util.Collection<java.lang.String> getKnownTypes()
Obtain a collection containing all of the string key names describing all object types this factory can produce.

Returns:
collection of object key strings.

Get Relational Analysis Toolkit at SourceForge.net. Fast, secure and Free Open Source software downloads