|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.taco.text.AbstractStringToObjectConverter
com.taco.text.StringToInstanceConverter
com.taco.text.StringToBeanShellInstanceConverter
public class StringToBeanShellInstanceConverter
A converter from a string that specifies an instance of an object to an
object. The string may have the syntax as in
StringToInstanceConverter
, as well as be a BeanShell
expression enclosed in '{' and '}'. Each conversion attempt uses a new
BeanShell interpreter.
Field Summary | |
---|---|
protected java.util.Map |
_environment
A map of variables to values to be put into the bean shell environment before execution. |
protected java.util.Collection |
_imports
An ordered collection of strings which are the imports to be added to the bean shell environment before execution. |
protected java.util.Collection |
_staticImports
An ordered collection of strings which are the static imports to be added to the bean shell environment before execution. |
static StringToBeanShellInstanceConverter |
instance
The singleton instance of this class, which does not impose any type constraint, does not put any variables in the BeanShell environment, and does not add any imports to the BeanShell environment. |
Fields inherited from class com.taco.text.StringToInstanceConverter |
---|
_returnType |
Constructor Summary | |
---|---|
protected |
StringToBeanShellInstanceConverter()
Construct an instance that does not impose a type constraint on returned objects, puts no variables into the BeanShell environment, and adds no imports to the BeanShell environment. |
|
StringToBeanShellInstanceConverter(java.lang.Class returnType)
Construct an instance that imposes a type constraint on returned objects and puts no variables into the BeanShell environment. |
|
StringToBeanShellInstanceConverter(java.lang.Class returnType,
java.util.Collection imports)
Construct an instance that imposes a type constraint on returned objects. |
|
StringToBeanShellInstanceConverter(java.lang.Class returnType,
java.util.Map environment)
Construct an instance that imposes a type constraint on returned objects. |
|
StringToBeanShellInstanceConverter(java.lang.Class returnType,
java.util.Map environment,
java.util.Collection imports)
Construct an instance that imposes a type constraint on returned objects. |
|
StringToBeanShellInstanceConverter(java.lang.Class returnType,
java.util.Map environment,
java.util.Collection imports,
java.util.Collection staticImports)
Construct an instance that imposes a type constraint on returned objects. |
|
StringToBeanShellInstanceConverter(java.util.Collection imports)
Construct an instance that does not impose a type constraint on returned objects, puts no variables into the BeanShell environment. |
|
StringToBeanShellInstanceConverter(java.util.Map environment)
Construct an instance that does not impose a type constraint on returned objects. |
|
StringToBeanShellInstanceConverter(java.util.Map environment,
java.util.Collection imports)
Construct an instance that does not impose a type constraint on returned objects. |
Method Summary | |
---|---|
protected void |
_addImports(bsh.Interpreter interpreter)
Add the return type and the imports in _imports to
the argument BeanShell interpreter. |
protected void |
_addStaticImports(bsh.Interpreter interpreter)
Add the static imports in _staticImports to the argument
BeanShell interpreter. |
protected bsh.Interpreter |
_getInterpreter()
Return a BeanShell interpreter suitable for evaluating a BeanShell expression. |
protected void |
_setEnvironment(bsh.Interpreter interpreter)
Add the variables in _environment to the argument
BeanShell interpreter. |
protected java.lang.Object |
_toObject(java.lang.String s)
If the string starts with a brace, evaluate the string using the BeanShell intepreter returned by _getInterpreter() . |
java.lang.Object |
clone()
|
Methods inherited from class com.taco.text.StringToInstanceConverter |
---|
_checkType, _parseInstanceString, _parseJavaLiteral, main, toObject |
Methods inherited from class com.taco.text.AbstractStringToObjectConverter |
---|
map |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Map _environment
protected java.util.Collection _imports
protected java.util.Collection _staticImports
public static final StringToBeanShellInstanceConverter instance
Constructor Detail |
---|
protected StringToBeanShellInstanceConverter()
public StringToBeanShellInstanceConverter(java.util.Map environment)
environment
is interpreted
as a variable name, with a value which is the corresponding value in
environment
. All these variables are put into the
BeanShell enviornment before it interprets expression strings.
The environment is only referenced, so the caller must be sure not
to modify it afterwards.
public StringToBeanShellInstanceConverter(java.lang.Class returnType)
public StringToBeanShellInstanceConverter(java.util.Collection imports)
imports
is not null
, The strings in
imports
are also added to the BeanShell environment. No
variables are set in the BeanShell environment.
public StringToBeanShellInstanceConverter(java.lang.Class returnType, java.util.Map environment)
environment
is interpreted as a variable name, with a
value which is the corresponding value in environment
. All
these variables are put into the BeanShell environment before it
interprets expression strings. The environment is only referenced, so
the caller must be sure not to modify it afterwards. No additional
imports are added to the BeanShell environment.
public StringToBeanShellInstanceConverter(java.lang.Class returnType, java.util.Collection imports)
imports
is not null
, The strings in
imports
are also added to the BeanShell environment. The
imports are only referenced, so the caller must be sure not to modify
them afterwards. No variables are set in the BeanShell environment.
public StringToBeanShellInstanceConverter(java.util.Map environment, java.util.Collection imports)
imports
is not null
, The
strings in imports
are also added to the BeanShell
environment. If environment is not null
, each key in
environment
is interpreted as a variable name, with a
value which is the corresponding value in environment
. All
these variables are put into the BeanShell environment before it
interprets expression strings. The environment and the imports are only
referenced, so the caller must be sure not to modify them afterwards.
public StringToBeanShellInstanceConverter(java.lang.Class returnType, java.util.Map environment, java.util.Collection imports)
imports
is not null
, The strings in
imports
are also added to the BeanShell environment. If
environment is not null
, each key in
environment
is interpreted as a variable name, with a
value which is the corresponding value in environment
. All
these variables are put into the BeanShell environment before it
interprets expression strings. The environment and the imports are only
referenced, so the caller must be sure not to modify them afterwards.
public StringToBeanShellInstanceConverter(java.lang.Class returnType, java.util.Map environment, java.util.Collection imports, java.util.Collection staticImports)
imports
is not null
, The strings in
imports
are imported into the BeanShell environment. If
staticImports
is not null
, The strings in
staticImports
are staticly imported into the BeanShell
environment. If environment is not null
, each key in
environment
is interpreted as a variable name, with a
value which is the corresponding value in environment
. All
these variables are put into the BeanShell environment before it
interprets expression strings. The environment, the imports, and the
static imports are only referenced, so the caller must be sure not to
modify them afterwards.
Method Detail |
---|
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class StringToInstanceConverter
java.lang.CloneNotSupportedException
protected java.lang.Object _toObject(java.lang.String s) throws java.text.ParseException
_getInterpreter()
.
Otherwise, use the superclass's implementation.
_toObject
in class StringToInstanceConverter
java.text.ParseException
protected bsh.Interpreter _getInterpreter()
_toObject()
to get an
interpreter after is determined that the string to convert is a
BeanShell expression. This implementation constructs a new one, imports
the return type, adds the imports in _imports
, and sets
the variables defined by _environment
. Subclasses may
choose to share interpreters by overriding this method.
protected void _addImports(bsh.Interpreter interpreter)
_imports
to
the argument BeanShell interpreter.
protected void _addStaticImports(bsh.Interpreter interpreter)
_staticImports
to the argument
BeanShell interpreter.
protected void _setEnvironment(bsh.Interpreter interpreter)
_environment
to the argument
BeanShell interpreter.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |