Package org.rapidcontext.core.proc
Class Bindings
java.lang.Object
org.rapidcontext.core.proc.Bindings
A procedure bindings container. The procedure bindings contain
virtually all data, information and parameters required by a
procedure, and are used during serialization, unserialization,
introspection and execution. Each binding has a name, a type and
a value. The value object class depends on the binding type, but
is frequently a string. The bindings can be linked together into a
hierarchy, which is used when redefining binding values (such as
when binding call argument values). The bindings can also be
sealed, thereby protecting the particular bindings instance from
further modifications (it can still be inherited, though).
- Version:
- 1.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The argument binding type.static final int
The connection pool name binding type.static final int
The static string data binding type.static final int
The procedure name binding type. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetDescription
(String name) Returns the human-readable description for a binding.String[]
getNames()
Returns an array with all names defined in the hierarchy of bindings.int
Finds the type for a binding.getTypeName
(String name) Finds the type name identifier for a binding.Finds the value for a binding.Finds the value for a binding.boolean
Checks if the specified binding name exists.processTemplate
(String tpl, TextEncoding encoding) Replaces template variables with the corresponding argument value from the bindings.void
seal()
Seals these bindings and prevents future modification.void
Sets the value for a binding.
-
Field Details
-
DATA
public static final int DATAThe static string data binding type. Any data value of this type must be a string.- See Also:
-
PROCEDURE
public static final int PROCEDUREThe procedure name binding type. Any data value of this type must be a string containing the procedure name.- See Also:
-
CONNECTION
public static final int CONNECTIONThe connection pool name binding type. Any data value of this type must be a string containing the connection pool name.- See Also:
-
ARGUMENT
public static final int ARGUMENTThe argument binding type. The data values of this type can be any object.- See Also:
-
-
Constructor Details
-
Bindings
public Bindings()Creates a new empty bindings container. -
Bindings
Creates a new empty child bindings container.- Parameters:
parent
- the parent bindings container
-
Bindings
Creates a new bindings container with the specified data.- Parameters:
parent
- the parent bindings container, or nullarr
- the data array to use, or null
-
-
Method Details
-
hasName
Checks if the specified binding name exists.- Parameters:
name
- the binding name- Returns:
- true if the name exists, or false otherwise
-
getNames
Returns an array with all names defined in the hierarchy of bindings.- Returns:
- an array with all binding names
-
getType
Finds the type for a binding.- Parameters:
name
- the binding name- Returns:
- the binding data type
- Throws:
ProcedureException
- if the binding name wasn't found
-
getTypeName
Finds the type name identifier for a binding. Use the getType() method for most access. Only use this string value for debug printing or serialization.- Parameters:
name
- the binding name- Returns:
- the binding data type name
- Throws:
ProcedureException
- if the binding name wasn't found
-
getValue
Finds the value for a binding.- Parameters:
name
- the binding name- Returns:
- the value binding
- Throws:
ProcedureException
- if the binding name wasn't found or if the value was null
-
getValue
Finds the value for a binding.- Parameters:
name
- the binding namedefaultValue
- the default value- Returns:
- the value binding
- Throws:
ProcedureException
- if the binding name wasn't found
-
getDescription
Returns the human-readable description for a binding.- Parameters:
name
- the binding name- Returns:
- the binding description, or an empty string if not set
- Throws:
ProcedureException
- if the binding name wasn't found
-
set
Sets the value for a binding. If the binding already exists locally it will be modified, otherwise it will be added. If the description is set to null, any parent binding description will be used instead.- Parameters:
name
- the binding nametype
- the binding typevalue
- the binding value, or nulldescription
- the binding description, or null- Throws:
ProcedureException
- if this object was sealed
-
seal
public void seal()Seals these bindings and prevents future modification. This method is used by built-in procedures once they have created their default (read-only) binding objects. -
processTemplate
Replaces template variables with the corresponding argument value from the bindings. This method supports both raw (e.g. "@key") and encoded (e.g. ":key") template variables.- Parameters:
tpl
- the template string to processencoding
- the text encoding for values- Returns:
- the processed template string
-