| |
|
| java.lang.Object freemarker.core.CustomAttribute
CustomAttribute | public class CustomAttribute (Code) | | 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.
author: Attila Szegedi version: $Id: CustomAttribute.java,v 1.3 2003/11/10 14:05:22 ddekany Exp $ |
Field Summary | |
final public static int | SCOPE_CONFIGURATION Constant used in the constructor specifying that this attribute is
scoped by the configuration. | final public static int | SCOPE_ENVIRONMENT Constant used in the constructor specifying that this attribute is
scoped by the environment. | final public static int | SCOPE_TEMPLATE Constant used in the constructor specifying that this attribute is
scoped by the template. |
Constructor Summary | |
public | CustomAttribute(int scope) Creates a new custom attribute with the specified scope
Parameters: scope - one of SCOPE_ constants. |
SCOPE_CONFIGURATION | final public static int SCOPE_CONFIGURATION(Code) | | Constant used in the constructor specifying that this attribute is
scoped by the configuration.
|
SCOPE_ENVIRONMENT | final public static int SCOPE_ENVIRONMENT(Code) | | Constant used in the constructor specifying that this attribute is
scoped by the environment.
|
SCOPE_TEMPLATE | final public static int SCOPE_TEMPLATE(Code) | | Constant used in the constructor specifying that this attribute is
scoped by the template.
|
CustomAttribute | public CustomAttribute(int scope)(Code) | | Creates a new custom attribute with the specified scope
Parameters: scope - one of SCOPE_ constants. |
create | protected Object create()(Code) | | This method is invoked when
CustomAttribute.get() is invoked without
CustomAttribute.set(Object) being invoked before it to define the value in the
current scope. Override it to create the attribute value on-demand.
the initial value for the custom attribute. By default returns null. |
get | final public Object get()(Code) | | the value of the attribute in the context of the current environment. throws: IllegalStateException - if there is no current environment (andhence also no current template and configuration), therefore theattribute's current scope object can't be resolved. |
set | final public void set(Object value)(Code) | | Sets the value of the attribute in the context of the current environment.
Parameters: value - the new value of the attribute throws: IllegalStateException - if there is no current environment (andhence also no current template and configuration), therefore theattribute's current scope object can't be resolved. |
set | final public void set(Object value, Template t)(Code) | | Sets the value of a template-scope attribute in the context of the given
template.
Parameters: value - the new value of the attribute Parameters: t - the template throws: UnsupportedOperationException - if this custom attribute is not atemplate-scope attribute throws: NullPointerException - if t is null |
|
|
|