ncsa.tools.ogrescript.tasks.core
Class Assign
java.lang.Object
ncsa.tools.ogrescript.OgreScriptElement
ncsa.tools.ogrescript.tasks.OgreScriptBaseTask
ncsa.tools.ogrescript.tasks.OgreScriptTaskContainer
ncsa.tools.ogrescript.tasks.core.Assign
- All Implemented Interfaces:
- IIdentifiable, ISelfConfiguring, ITask, UserFacing
- Direct Known Subclasses:
- Add, AddAll, Declare, Put, PutAll, Set, Set
- public class Assign
- extends OgreScriptTaskContainer
Assignment of values to the environment. The global attribute
indicates that the reference goes on the outermost
(bottommost) frame (default = false). Otherwise it goes on the current frame.
castTo does a transformation from one to another numerical type via
their string constructors.
Strings, Primitives, File or URI descriptors can all be assigned directly to
as attributes. If the attribute is given as an expression, this will be evaluated
in the current context prior to assignment.
A single embedded element can be handled in several different ways.
If the configured option is set to true (default = true),
the child element will be configured in the current context and the resulting
instance assigned to the variable name. Otherwise, with the exception of the
special cases discussed below, the element will be wrapped and
its wrapper assigned to the environment without configuration.
This allows the element to be configured and instantiated at the point of
consumption without the composing task having to deal directly with the wrapper.
To delay primitive configuration in a similar way, add a <value&g;
element with the configure option turned off. If the object to be configured
is an Expression or Statement, it is also evaluated
before assignment.
If multiple child elements are present, execution of this task will fail.
There are a number of special element tags available for this task:
$lt;to-string> takes either its child element and
calls toString() on it, or dereferences its text element to an object
and calls toString() on it.
<serialized> takes either its child element and
serializes it, or dereferences its text element to an object and attempts
to serialize it. If the object is not a Primitive/File/URI, or is not
UserFacing, the task will fail.
<deserialized> takes a text element and attempts to deserialize
it using UserFacing deserialization. If the object contains
any references to the environment, these will be dereferenced before
instantiation. If the object is not UserFacing, the task will fail.
<literal> takes a text element and assigns it without
dereferencing it in the current context (the configured is ignored in
this case).
<new> takes either a text element denoting an element tag, or a
<java-constructor> element, and constructs an empty new
instance of the type. In the case of the constructor, configuration must
precede, since any parameters to the constructor must be real instances.
The difference between these two options depends on the following:
when running in an OSGI container (e.g., Eclipse), it is not possible to
instantiate arbitrary objects whose type is unknown at compile time (using
newInstance() ); only declared extensions (registered tags) can be safely
constructed. If running outside an OSGI container, however, construction
of fully qualified class names will be possible, but the Java classes of
element tags will be unknown unless the tag is a known extension
(these are written to ogre.taskdefs.properties and a typedef.properties
files and placed in a top-level resource directory). Thus, if running in Eclipse,
<new> can be used to make new instances of a known type, but
<java-constructor> will not work; outside of Eclipse,
<new> will only work it the extension definitions are
in the classpath, but <java-constructor> should generally succeed.
- Author:
- arossi
|
Field Summary |
static java.lang.String |
TAG_SELF
|
| Methods inherited from class ncsa.tools.ogrescript.tasks.OgreScriptBaseTask |
execute, getInstanceId, getPlugin, getScript, getTaskId, getTaskName, setEnvironment, setInstanceId, setScript, setTaskId, setTaskName, toString |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
TAG_SELF
public static final java.lang.String TAG_SELF
- See Also:
- Constant Field Values
Assign
public Assign()
setString
public void setString(java.lang.String value)
setBoolean
public void setBoolean(java.lang.Boolean value)
setInt
public void setInt(java.lang.Integer value)
setLong
public void setLong(java.lang.Long value)
setDouble
public void setDouble(java.lang.Double value)
setFile
public void setFile(java.io.File value)
setUri
public void setUri(java.net.URI value)
setObject
public void setObject(java.lang.Object object)
setConfigured
public void setConfigured(boolean configured)
setGlobal
public void setGlobal(boolean global)
setCastTo
public void setCastTo(java.lang.String type)
setName
public void setName(java.lang.String name)