|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.unitesk.atp.tool.DynamicVariablesTable
public class DynamicVariablesTable
The table of dynamic variables.
A dynamic variable like usual Java variable has a name and a class. But dynamic variables are defined outside of program. It allows to change a set of defined dynamic variables and use them without program recompilation. For example, it can be used to extend program functionality in plugin-like way.
A table of dynamic variables has a name.
A class instance representing dynamic variable is created using class constructor without parameters.
Parameters are passed to variable using so-called plugin properties.
The value of plugin property property.name
for variable
var
of table tab
is passed through system property
tab.var.property.name
.
Constructor Summary | |
---|---|
DynamicVariablesTable(String name)
Creates an empty dynamic variables table with the specified name. |
|
DynamicVariablesTable(String name,
InputStream in)
Creates dynamic variables table with the specified name and loads variables from the specified input stream. |
Method Summary | |
---|---|
boolean |
containsName(String name)
Checks if this table contains a variable with the specified name. |
boolean |
containsObject(Object var)
Checks if this table contains the specified variable. |
Object |
get(String name)
Returns a variable with the specified name. |
String |
getName()
Gets the name of this table. |
String |
getProperty(Object var,
String property_name)
Gets the value of plugin property with the specified name for the specified variable. |
String |
getProperty(Object var,
String property_name,
String default_property_value)
Gets the value of plugin property with the specified name for the specified variable or default value if this property is not defined. |
String |
getPropertyName(Object var,
String property_name)
Gets the system property name for plugin property name of the specified variable. |
void |
load(InputStream in)
Loads variables from the specified input stream. |
void |
load(String name,
String type)
Loads a variable of the specified type and associates it with the specified name. |
Set |
names()
Returns the names of all defined variables. |
Object |
put(String name,
Object var)
Puts the new variable with the specifed name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DynamicVariablesTable(String name)
name
- the name of the table. It must be the name of Java
indentifier.
IllegalArgumentException
- if name
is incorrect formatpublic DynamicVariablesTable(String name, InputStream in) throws IOException, ClassNotFoundException
loads
variables from the specified input stream.
name
- The table name.in
- The input stream containing
dynamic variables definitions.
IOException
ClassNotFoundException
load(InputStream)
,
load(String,String)
,
Properties.load(InputStream)
Method Detail |
---|
public Set names()
public Object get(String name)
name
- The variable name.
null
if no such variable is defined.Map.get(Object)
public String getPropertyName(Object var, String property_name)
var
- The variable from this table.property_name
- The name of var
plugin property.
property.name
of variable with name var
from table tab
system property name is
tab.var.property.name
.
IllegalArgumentException
- If table doesn't contain var
.public String getProperty(Object var, String property_name)
var
- The variable from this table.property_name
- The name of var
plugin property.
IllegalArgumentException
- If table doesn't contain var
.getPropertyName( var, property_name )
public String getProperty(Object var, String property_name, String default_property_value)
var
- The variable from this table.property_name
- The name of var
plugin property.default_property_value
- A default value is used if for the specified variable
there is no plugin property with the specified name.
IllegalArgumentException
- If table doesn't contain var
.getPropertyName( var, property_name )
public String getName()
public boolean containsName(String name)
name
- The name to check.
true
if this table contains a variable
with specified name, false
otherwise.public boolean containsObject(Object var)
var
- The object to check.
true
if this table contains
the specified object, false
otherwise.public Object put(String name, Object var)
name
- The name of variable.var
- The value of variable.
null
if there was
no variable with such name.public void load(InputStream in) throws IOException, ClassNotFoundException
in
- The input stream containing
dynamic variables definitions.
The data format is specified in
(its structure is described in
Properties.load( InputStream )
description.
Property name is variable name
and property value is variable type
(fully-qualified Java class name).
IOException
- If there was an I/O error during the input stream reading.
IllegalArgumentException
- If there was no type defined for a variable.
or there is a syntax error in the variable name
or in the variable type.
ClassNotFoundException
- If the variable type is not found.
IllegalAccessException
- If an access to a definition of
the variable type is denied.
InstantiationException
- If the variable can not be created.load( String, String )
,
Properties.load( InputStream )
public void load(String name, String type) throws ClassNotFoundException
name
- The variable name.type
- The fully qualified name of variable's class.
IllegalArgumentException
- If there is a syntax error in the variable name
or in the variable type.
ClassNotFoundException
- If the variable type is not found
can not be accessed
or if the variable can not be created.
The exception message contains the class name.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |