|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--anthill.factory.Factory
A generic factory for creating object instances of a class matching a particular interface and possibly taking arguments. The mapping between an implementing class and an interface, and also the arguments to be used to instantiate the class are all read from a configuration file.
Constructor Summary | |
Factory()
Create a parser object and pass this factory object allowing the parser to place the parsed elements directly into the HashMap using the factory API method put . |
|
Factory(java.lang.String[] configURLs)
Create a parser object and pass this factory object allowing the parser to place the parsed elements directly into the HashMap using the factory API method put . |
Method Summary | |
double |
doubleValue(java.lang.String name)
Method used to obtain the double value associated to a particular configuration parameter |
float |
floatValue(java.lang.String name)
Method used to obtain the double value associated to a particular configuration parameter |
java.lang.Object |
get(java.lang.Class cl)
The get method is used to obtain an instantiation of
a class implementing the requested interface. |
java.lang.Object |
get(java.lang.String iface)
The get method is used to obtain an instantiation of
a class implementing the requested interface. |
java.lang.Object |
getValue(java.lang.String name)
Method used to obtain the value associated to a particular configuration parameter |
int |
getVersion(java.lang.Class cl)
Check the version of the class, argument pair stored in the factory database under the key iface . |
int |
getVersion(java.lang.String iface)
Check the version of the class, argument pair stored in the factory database under the key iface . |
int |
intValue(java.lang.String name)
Method used to obtain the integer value associated to a particular configuration parameter |
void |
put(java.lang.String iface,
java.lang.String clazz,
java.lang.String[] names,
java.lang.Class[] types,
java.lang.Object[] args)
Method used to insert or update an interface mapping in the factory database. |
void |
putValue(java.lang.String name,
double value)
Method used to insert or update a double configuration value associated to a configuration name. |
void |
putValue(java.lang.String name,
float value)
Method used to insert or update a double configuration value associated to a configuration name. |
void |
putValue(java.lang.String name,
int value)
Method used to insert or update an integer configuration value associated to a configuration name. |
void |
putValue(java.lang.String name,
java.lang.Object value)
Method used to insert or update a configuration value associated to a configuration name. |
java.lang.String |
stringValue(java.lang.String name)
Method used to obtain the String value associated to a particular configuration parameter |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Factory(java.lang.String[] configURLs) throws ConfigFormatException, java.io.IOException
put
. The parser will
use the provided URLs for the configuration file location.configURLs
- An array of URLs pointing to the configuration files to parse.ConfigFormatException
- Thrown when there is a problem parsing or validating the content
of the system configuration file.IOException
- Thrown when one of the urls cannot be accessed due to an I/O
problem.public Factory() throws ConfigFormatException, java.io.IOException
put
. The parser will
use the default configuration file location.ConfigFormatException
- Thrown when there is a problem parsing or validating the content
of the system configuration file.IOException
- Thrown when one of the urls cannot be accessed due to an I/O
problem.Method Detail |
public java.lang.Object get(java.lang.Class cl) throws ConfigFormatException, ConstructorException
get
method is used to obtain an instantiation of
a class implementing the requested interface.cl
- The interface used as mapping key.ConfigFormatException
- Thrown if specified classes and interfaces
cannot be found.ConstructorException
- Thrown if the constructor reflectively invoked
by get raises an exceptionpublic java.lang.Object get(java.lang.String iface) throws ConfigFormatException, ConstructorException
get
method is used to obtain an instantiation of
a class implementing the requested interface.iface
- The interface name used as mapping key.ConfigFormatException
- Thrown if specified classes and interfaces
cannot be found.ConstructorException
- Thrown if the constructor reflectively invoked
by get raises an exceptionpublic int getVersion(java.lang.Class cl)
iface
.cl
- The interface to check the current version of.public int getVersion(java.lang.String iface)
iface
.iface
- The interface to check the current version of.public void put(java.lang.String iface, java.lang.String clazz, java.lang.String[] names, java.lang.Class[] types, java.lang.Object[] args)
iface
- The interface name used as mapping key.clazz
- The class name implementing the above interface.args
- Array of arguments used for instantiating the above class.public void putValue(java.lang.String name, java.lang.Object value)
name
- The name associated to the value.value
- The value to be inserted.public void putValue(java.lang.String name, int value)
name
- The name associated to the value.value
- The value to be inserted.public void putValue(java.lang.String name, double value)
name
- The name associated to the value.value
- The value to be inserted.public void putValue(java.lang.String name, float value)
name
- The name associated to the value.value
- The value to be inserted.public java.lang.Object getValue(java.lang.String name)
name
- The name identifying the configuration parameterpublic java.lang.String stringValue(java.lang.String name)
name
- The name identifying the configuration parameterpublic int intValue(java.lang.String name)
name
- The name identifying the configuration parameterpublic double doubleValue(java.lang.String name)
name
- The name identifying the configuration parameterpublic float floatValue(java.lang.String name)
name
- The name identifying the configuration parameterpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |