public class Context extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Context.Builder
A context builder.
|
Modifier and Type | Field and Description |
---|---|
static String |
CALLEE
Last callee of a partial block.
|
protected Map<String,Object> |
data
A thread safe storage.
|
protected Context |
extendedContext
Additional, data can be stored here.
|
static String |
INLINE_PARTIALS
Inline partials.
|
static String |
INVOCATION_STACK
The qualified name for partials.
|
static String |
PARAM_SIZE
Number of parameters of a helper.
|
protected Context |
parent
The parent context.
|
static String |
PARTIALS
The qualified name for partials.
|
protected ValueResolver |
resolver
The value resolver.
|
Modifier | Constructor and Description |
---|---|
protected |
Context(Object model)
Creates a new context.
|
Modifier and Type | Method and Description |
---|---|
Context |
combine(Map<String,?> model)
Insert all the attributes in the context-stack.
|
Context |
combine(String name,
Object model)
Insert a new attribute in the context-stack.
|
static Context |
copy(Context context,
Object model)
Creates a new context but keep the
data attribute. |
Context |
data(Map<String,?> attributes)
Store the map in the data storage.
|
<T> T |
data(String name)
Read the attribute from the data storage.
|
Context |
data(String name,
Object value)
Set an attribute in the data storage.
|
void |
destroy()
Destroy this context by cleaning up instance attributes.
|
Object |
get(List<PathExpression> path)
Lookup the given key inside the context stack.
|
Object |
get(String key)
Lookup the given key inside the context stack.
|
Object |
get(String key,
boolean parentScopeResolution)
Lookup the given key inside the context stack.
|
boolean |
isBlockParams() |
Object |
model()
Resolved as '.' or 'this' inside templates.
|
static Context |
newBlockParamContext(Context parent,
List<String> names,
List<Object> values)
Creates a new block param context.
|
static Context.Builder |
newBuilder(Context parent,
Object model)
Start a new context builder.
|
static Context.Builder |
newBuilder(Object model)
Start a new context builder.
|
protected Context |
newChildContext(Object model)
Creates an empty/default context.
|
static Context |
newContext(Context parent,
Object model)
Creates a new child context.
|
static Context |
newContext(Object model)
Creates a new root context.
|
static Context |
newPartialContext(Context ctx,
String scope,
Map<String,Object> hash)
Creates a new partial context.
|
Context |
parent()
The parent context or null.
|
Set<Map.Entry<String,Object>> |
propertySet()
List all the properties and values of
model() . |
Set<Map.Entry<String,Object>> |
propertySet(Object context)
List all the properties and values for the given object.
|
String |
toString() |
public static final String PARTIALS
public static final String INLINE_PARTIALS
public static final String INVOCATION_STACK
public static final String PARAM_SIZE
public static final String CALLEE
protected Context parent
protected Context extendedContext
protected ValueResolver resolver
protected Context(Object model)
model
- The target value. Resolved as '.' or 'this' inside templates. Required.public Context combine(String name, Object model)
name
- The attribute's name. Required.model
- The model data.public Context combine(Map<String,?> model)
model
- The model attributes.public <T> T data(String name)
T
- Data type.name
- The attribute's name.public Context data(String name, Object value)
name
- The attribute's name. Required.value
- The attribute's value. Required.public Context data(Map<String,?> attributes)
attributes
- The attributes to add. Required.public final Object model()
public final Context parent()
public Set<Map.Entry<String,Object>> propertySet(Object context)
context
- The context object.public Set<Map.Entry<String,Object>> propertySet()
model()
.model()
.public boolean isBlockParams()
public Object get(List<PathExpression> path)
path
- The object path.null
if no value is found.public Object get(String key)
key
- The object key.null
if no value is found.public Object get(String key, boolean parentScopeResolution)
key
- The object key.parentScopeResolution
- False, if we want to restrict lookup to current scope.null
if no value is found.public void destroy()
public static Context.Builder newBuilder(Context parent, Object model)
parent
- The parent context. Required.model
- The model data.public static Context.Builder newBuilder(Object model)
model
- The model data.public static Context newContext(Context parent, Object model)
parent
- The parent context. Required.model
- The model data.public static Context newBlockParamContext(Context parent, List<String> names, List<Object> values)
parent
- The parent context. Required.names
- A list of names to set in the block param context.values
- A list of values to set in the block param context.public static Context newPartialContext(Context ctx, String scope, Map<String,Object> hash)
ctx
- Current scope.scope
- Scope switch.hash
- Partial hash.public static Context newContext(Object model)
model
- The model data.protected Context newChildContext(Object model)
model
- A model/data.Copyright © 2022. All rights reserved.