//Artefact:JavaClass/com/sphenon/basics/expression/DynamicString
Synopsis
public DynamicString
extends Object
Overview
A DynamicString is a string that can contain expressions.
Basically, a dynamic string looks like this "interpreter:expression".
There a many different interpreters available, e.g. "js:3*3" would
calculate the product with a javascript interpreter, "placeholder:${name}"
would replace the term "${name}" with the value of a variable called
"name" (depending on context, obviously), or "s:Hello" is a "static"
string which just uses everything after the colon, thereby providing
a simple way to effectively escape further evaluation.
DynamicStrings are useful in situations where usually a normal string
is used, but in certain cases an evaluation is desired. E.g., EM/OS
uses many DynamicStrings in configuration properties.
The syntax for the "interpreter" part is "id%actor@locator#session".
The "id" is mandatory and names the type of interpreter, e.g.:
- placeholder: replace placeholders "${...}"
- catch: in case of errors, use an alternative
- process: recursively interpret string as dynamic string
- regexp : do regular expression replacements
- static: use string as is
- text: convert some value from the scope to a string
- unicode: apply unicode syntax replacements (syntactic sugar)
- bash: execute as bash command
- browser: open in a browser
- console: open in a console
- control: return from procedure or break from loop
- date: retrieve formatted date
- define: define variables, then recursively process rest as dynamic string
- editor: open in text editor
- error: signal an error
- evaluate: evaluate as dynamic expression
- expression: evaluate simple expressions
- identity: use string as is
- program: control structure (block, loop)
- request: send REST request
- scope: access and manipulate scope
The other parts, i.e. "%actor", "@locator", and "#session" are optional.
"actor" is the name of an actor in case credentials are required to
perform an operation, like e.g. sending a REST request. "locator"
defines where to execute the operation, e.g. a "bash:" command can
be executed locally, or via ssh at some remote server. Finally,
"session" denotes an execution session, e.g. a sequence of "bash:"
commands executed remotely can share a session and thereby use
environment variables within it.
Please be aware that DynamicStrings are an enormously powerful
instrument and can easily be abused. Like code, SQL or command
shell access, they have to be treated as security critical.
Also, the locations where they are used become likewise
security relevant. It is e.g. an absolute NoGo to pass
unchecked, non sanitised values via the user interface
into DynamicStrings.
//Artefact:Constructor/com/sphenon/basics/expression/DynamicString/DynamicString
Synopsis
public DynamicString (CallContext context, String string_template)
//Artefact:Constructor/com/sphenon/basics/expression/DynamicString/DynamicString
Synopsis
public DynamicString (CallContext context, String string_template, Scope scope)
//Artefact:Constructor/com/sphenon/basics/expression/DynamicString/DynamicString
Synopsis
public DynamicString (CallContext context, String string_template, String default_processors)
//Artefact:Constructor/com/sphenon/basics/expression/DynamicString/DynamicString
Synopsis
public DynamicString (CallContext context, String string_template, String default_processors, String default_session)
//Artefact:Constructor/com/sphenon/basics/expression/DynamicString/DynamicString
Synopsis
public DynamicString (CallContext context, String string_template, String default_processors, String default_session, Scope scope)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/process
Synopsis
public static java.lang.String process (CallContext context, String string_template)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/process
Synopsis
public static java.lang.String process (CallContext context, String string_template, Scope scope)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/process
Synopsis
public static java.lang.String process (CallContext context, String string_template, String default_processors)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/process
Synopsis
public static java.lang.String process (CallContext context, String string_template, String default_processors, Scope scope)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/process
Synopsis
public static java.lang.String process (CallContext context, String string_template, String default_processors, java.lang.Object[] arguments)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/process
Synopsis
public static java.lang.String process (CallContext context, String string_template, String default_processors, java.util.Map arguments)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/getStringTemplate
Synopsis
public java.lang.String getStringTemplate (CallContext context)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/getDefaultProcessors
Synopsis
public java.lang.String getDefaultProcessors (CallContext context)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/setStringTemplate
Synopsis
public void setStringTemplate (CallContext context, String string_template)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/setStringTemplate
Synopsis
public void setStringTemplate (CallContext context, String string_template, String default_processors)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/setStringTemplate
Synopsis
public void setStringTemplate (CallContext context, String string_template, String default_processors, String default_session)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/attachScope
Synopsis
public void attachScope (CallContext context, Scope attached_scope)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/get
Synopsis
public java.lang.String get (CallContext context)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/get
Synopsis
public java.lang.String get (CallContext context, Scope scope)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/get
Synopsis
public java.lang.String get (CallContext context, java.lang.Object[] arguments)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/get
Synopsis
public java.lang.String get (CallContext context, java.util.Map arguments)
//Artefact:Method/com/sphenon/basics/expression/DynamicString/toString
Synopsis
public java.lang.String toString ()

