public class RewriteContext extends HtmlRewriter
tag_xxx
or
tag_slash_xxx
which will get called when the corrosponding HTML entity
<xxx ...>
or
</xxx ...>
is found in the content being filtered.
An instance of this class is passed to each tag
method, permitting introspection of the current filtering context.
Modifier and Type | Field and Description |
---|---|
java.lang.String |
prefix
The prefix to use for locating keys in the server or request properties
objects.
|
Request |
request
The Request object, as passed to a handler's respond method.
|
Server |
server
The server object, as passed to a handler's init method.
|
java.lang.String |
sessionId
A unique session id, if available.
|
java.lang.String |
templatePrefix
This is the prefix defined by the invoker of a set of templates.
|
lex, sb
Constructor and Description |
---|
RewriteContext(Server server,
java.lang.String prefix,
Request request,
java.lang.String content,
java.lang.String sessionId,
TemplateRunner runner,
java.util.Vector templates) |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Cause this RewriteContext to abort its processing.
|
void |
addClosingTag(java.lang.String tag)
Add a closing tag to the list of tags that mark un-interpreted text
Deal with the tag prefix, if any
|
boolean |
checkRewriteState(int state)
Check whether this RewriteContext is in the specified state.
|
void |
decrNestingLevel()
Decrement the nesting level counter.
|
java.lang.String |
get(java.lang.String name)
overwrite "get" to automatically do ${...} substitutions
The default is "true".
|
java.lang.String |
get(java.lang.String name,
boolean subst)
Get an attribute value, and optionally perform ${...} substitutions.
|
java.lang.String |
get(java.lang.String name,
java.lang.String dflt)
Get a tag attribute, with a default value.
|
java.util.Properties |
getNamespaceProperties()
Get the proper properties table based on the "namespace"
attribute.
|
int |
getNestingLevel()
Return the current nesting level counter.
|
void |
incrNestingLevel()
Increment the nesting level counter.
|
boolean |
isClosingFor(java.lang.String tag)
See if the current token is the closing tag for the given string.
|
boolean |
isClosingFor(java.lang.String tag,
boolean close)
See if the current token is the closing tag for the given string.
|
boolean |
isTrue(java.lang.String name)
Determine the value of a boolean attribute in the current tag.
|
void |
process()
Invoke a template on this token, if any template is interested in this
token.
|
boolean |
setRewriteState(int state)
Set the given state of this RewriteContext.
|
java.lang.String |
snarfTillClose()
Grab all the markup between the current tag, and the corrosponding
closing tag.
|
void |
substAttributeValues()
Substitute all attribute values.
|
int |
tagsSeen()
Return the number of HTML tags seen to this point.
|
Template |
templateFromTag(java.lang.String tag)
Get the template that will process the supplied tag (if any).
|
void |
unsetRewriteState(int state)
Unset the given state of this RewriteContext.
|
accumulate, append, appendToken, getArgs, getBody, getMap, getTag, getToken, getType, isSingleton, keys, killToken, nextTag, nextToken, pushback, put, quote, remove, reset, setSingleton, setTag, setType, tagCount, tokenCount, toString
public Server server
public java.lang.String prefix
public java.lang.String templatePrefix
public Request request
public java.lang.String sessionId
public RewriteContext(Server server, java.lang.String prefix, Request request, java.lang.String content, java.lang.String sessionId, TemplateRunner runner, java.util.Vector templates)
public void abort()
public boolean setRewriteState(int state)
public void unsetRewriteState(int state)
public boolean checkRewriteState(int state)
public void incrNestingLevel()
public void decrNestingLevel()
public int getNestingLevel()
public void process()
public int tagsSeen()
public java.lang.String get(java.lang.String name)
get
in class HtmlRewriter
null
if the key was not in the attributes.LexML.getAttributes()
public java.lang.String get(java.lang.String name, boolean subst)
public java.lang.String get(java.lang.String name, java.lang.String dflt)
dflt
is used instead.name
- The name of the attribute to look updflt
- The default attribute value (may be null)public boolean isTrue(java.lang.String name)
name
- The name of the boolean attributepublic boolean isClosingFor(java.lang.String tag)
tag
- tag whose match ( e.g. /[prefix]tag is to be foundpublic boolean isClosingFor(java.lang.String tag, boolean close)
tag
- tag whose match ( e.g. /[prefix]tag is to be foundclose
- if set, "tag" matches "/[prefix]tag", otherwise
tag matches "[prefix]tag".public java.lang.String snarfTillClose()
public void addClosingTag(java.lang.String tag)
public java.util.Properties getNamespaceProperties()
public Template templateFromTag(java.lang.String tag)
tag
- the name of the html tag that will get processedpublic void substAttributeValues()