public class PluginContext
extends java.lang.Object
This class holds a number of useful items which should be shared by all plugin objects. Such data cannot be stored on the PluginRules or PluginManager classes, as there can be multiple instances of these at various times during a parse.
The name "Context" refers to the similarity between this class and a ServletContext class in a servlet engine. A ServletContext object provides access to the container's services such as obtaining global configuration parameters for the container, or getting access to logging services. For plugins, a Digester instance can be regarded as "the container".
Modifier and Type | Field and Description |
---|---|
java.lang.String |
DFLT_PLUGIN_CLASS_ATTR |
java.lang.String |
DFLT_PLUGIN_CLASS_ATTR_NS |
java.lang.String |
DFLT_PLUGIN_ID_ATTR |
java.lang.String |
DFLT_PLUGIN_ID_ATTR_NS |
Constructor and Description |
---|
PluginContext() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getPluginClassAttr()
Get the namespace for the xml attribute which indicates to a
PluginCreateRule which class is to be plugged in.
|
java.lang.String |
getPluginClassAttrNs()
Get the namespace for the xml attribute which indicates to a
PluginCreateRule which class is to be plugged in.
|
java.lang.String |
getPluginIdAttr()
Get the namespace for the xml attribute which indicates to a
PluginCreateRule which previous plugin declaration should be used.
|
java.lang.String |
getPluginIdAttrNs()
Get the namespace for the xml attribute which indicates to a
PluginCreateRule which previous plugin declaration should be used.
|
java.util.List |
getRuleFinders()
Return the list of RuleFinder objects.
|
void |
setPluginClassAttribute(java.lang.String namespaceUri,
java.lang.String attrName)
Sets the xml attribute which the input xml uses to indicate to a
PluginCreateRule which class should be instantiated.
|
void |
setPluginIdAttribute(java.lang.String namespaceUri,
java.lang.String attrName)
Sets the xml attribute which the input xml uses to indicate to a
PluginCreateRule which plugin declaration is being referenced.
|
void |
setRuleFinders(java.util.List ruleFinders)
Set the list of RuleFinder objects.
|
public final java.lang.String DFLT_PLUGIN_CLASS_ATTR_NS
public final java.lang.String DFLT_PLUGIN_CLASS_ATTR
public final java.lang.String DFLT_PLUGIN_ID_ATTR_NS
public final java.lang.String DFLT_PLUGIN_ID_ATTR
public java.util.List getRuleFinders()
It is explicitly permitted for the caller to modify this list by inserting or removing RuleFinder objects.
public void setRuleFinders(java.util.List ruleFinders)
If the intent is just to add an additional rule-finding algorithm, then it may be better to call #getRuleFinders, and insert a new object into the start of the list.
public void setPluginClassAttribute(java.lang.String namespaceUri, java.lang.String attrName)
Example:
setPluginClassAttribute(null, "class");will allow this in the input xml:
<root> <some-plugin class="com.acme.widget"> ......instead of the default syntax:
<root> <some-plugin plugin-class="com.acme.widget"> ......This is particularly useful if the input xml document is not in English.
Note that the xml attributes used by PluginDeclarationRules are not affected by this method.
namespaceUri
- is the namespace uri that the specified attribute
is in. If the attribute is in no namespace, then this should be null.
Note that if a namespace is used, the attrName value should not
contain any kind of namespace-prefix. Note also that if you are using
a non-namespace-aware parser, this parameter must be null.attrName
- is the attribute whose value contains the name of the
class to be instantiated.public void setPluginIdAttribute(java.lang.String namespaceUri, java.lang.String attrName)
Example:
setPluginIdAttribute(null, "id");will allow this in the input xml:
<root> <some-plugin id="widget"> ......rather than the default behaviour:
<root> <some-plugin plugin-id="widget"> ......This is particularly useful if the input xml document is not in English.
Note that the xml attributes used by PluginDeclarationRules are not affected by this method.
namespaceUri
- is the namespace uri that the specified attribute
is in. If the attribute is in no namespace, then this should be null.
Note that if a namespace is used, the attrName value should not
contain any kind of namespace-prefix. Note also that if you are using
a non-namespace-aware parser, this parameter must be null.attrName
- is the attribute whose value contains the id of the
plugin declaration to be used when instantiating an object.public java.lang.String getPluginClassAttrNs()
May be null (in fact, normally will be).
public java.lang.String getPluginClassAttr()
The return value is never null.
public java.lang.String getPluginIdAttrNs()
May be null (in fact, normally will be).
public java.lang.String getPluginIdAttr()
The return value is never null.
Copyright © 2001-2012 Apache Software Foundation. All Rights Reserved.