freemarker.core
public class CustomAttribute extends Object
ThreadLocal
, a
class that allows one to associate custom data with a thread.Modifier and Type | Field and Description |
---|---|
static int |
SCOPE_CONFIGURATION
Constant used in the constructor specifying that this attribute is
scoped by the configuration.
|
static int |
SCOPE_ENVIRONMENT
Constant used in the constructor specifying that this attribute is
scoped by the environment.
|
static int |
SCOPE_TEMPLATE
Constant used in the constructor specifying that this attribute is
scoped by the template.
|
Constructor and Description |
---|
CustomAttribute(int scope)
Creates a new custom attribute with the specified scope
|
Modifier and Type | Method and Description |
---|---|
protected Object |
create()
This method is invoked when
get() is invoked without
set(Object) being invoked before it to define the value in the
current scope. |
Object |
get() |
Object |
get(Template t) |
void |
set(Object value)
Sets the value of the attribute in the context of the current environment.
|
void |
set(Object value,
Template t)
Sets the value of a template-scope attribute in the context of the given
template.
|
public static final int SCOPE_ENVIRONMENT
public static final int SCOPE_TEMPLATE
public static final int SCOPE_CONFIGURATION
public CustomAttribute(int scope)
scope
- one of SCOPE_ constants.protected Object create()
get()
is invoked without
set(Object)
being invoked before it to define the value in the
current scope. Override it to create the attribute value on-demand.public final Object get()
IllegalStateException
- if there is no current environment (and
hence also no current template and configuration), therefore the
attribute's current scope object can't be resolved.public final Object get(Template t)
UnsupportedOperationException
- if this custom attribute is not a
template-scope attributeNullPointerException
- if t is nullpublic final void set(Object value)
value
- the new value of the attributeIllegalStateException
- if there is no current environment (and
hence also no current template and configuration), therefore the
attribute's current scope object can't be resolved.public final void set(Object value, Template t)
value
- the new value of the attributet
- the templateUnsupportedOperationException
- if this custom attribute is not a
template-scope attributeNullPointerException
- if t is null