|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfreemarker.core.CustomAttribute
public class CustomAttribute
A class that allows one to associate custom data with a configuration,
a template, or environment. It works pretty much like ThreadLocal, a
class that allows one to associate custom data with a thread.
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
CustomAttribute(int scope)
Creates a new custom attribute with the specified scope |
|
| Method Summary | |
|---|---|
protected java.lang.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. |
java.lang.Object |
get()
|
java.lang.Object |
get(Template t)
|
void |
set(java.lang.Object value)
Sets the value of the attribute in the context of the current environment. |
void |
set(java.lang.Object value,
Template t)
Sets the value of a template-scope attribute in the context of the given template. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int SCOPE_ENVIRONMENT
public static final int SCOPE_TEMPLATE
public static final int SCOPE_CONFIGURATION
| Constructor Detail |
|---|
public CustomAttribute(int scope)
scope - one of SCOPE_ constants.| Method Detail |
|---|
protected java.lang.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 java.lang.Object get()
java.lang.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 java.lang.Object get(Template t)
java.lang.UnsupportedOperationException - if this custom attribute is not a
template-scope attribute
java.lang.NullPointerException - if t is nullpublic final void set(java.lang.Object value)
value - the new value of the attribute
java.lang.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 void set(java.lang.Object value,
Template t)
value - the new value of the attributet - the template
java.lang.UnsupportedOperationException - if this custom attribute is not a
template-scope attribute
java.lang.NullPointerException - if t is null
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||