|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.myfaces.renderkit.html.util.ReducedHTMLParser
public class ReducedHTMLParser
A class which detects the open/close tags in an HTML document and reports them to a listener class.
This is unfortunately necessary when using JSF with JSP, as tags in the body of the document can need to output commands into the document at points earlier than the tag occurred (particularly into the document HEAD section). This can only be implemented by buffering the response and post-processing it to find the relevant HTML tags and modifying the buffer as needed.
This class tries to do the parsing as quickly as possible; many of the details of HTML are not relevant for the purposes this class is used for.
Field Summary | |
---|---|
static int |
BODY_TAG
|
static int |
HEAD_TAG
|
static int |
SCRIPT_TAG
|
Constructor Summary | |
---|---|
ReducedHTMLParser(java.lang.CharSequence s,
CallbackListener l)
Constructor, package-scope for unit testing. |
Method Summary | |
---|---|
(package private) void |
closedTag(int startOffset,
int endOffset,
java.lang.String tagName)
|
(package private) java.lang.String |
consumeAttrName()
Eat up a sequence of chars which form a valid XML attribute name. |
(package private) java.lang.String |
consumeAttrValue()
Assuming we have already encountered "attrname=", consume the value part of the attribute definition. |
(package private) java.lang.String |
consumeElementName()
Eat up a sequence of chars which form a valid XML element name. |
(package private) void |
consumeExcept(java.lang.String s)
Discard all characters in the input until one in the specified string (character-set) is found. |
(package private) boolean |
consumeMatch(java.lang.String s)
If the next chars in the input sequence exactly match the specified string then skip over them and return true. |
(package private) java.lang.String |
consumeNonWhitespace()
Eat up a sequence of non-whitespace characters and return them. |
(package private) java.lang.String |
consumeString(char quote)
Eat up a string which is terminated with the specified quote character. |
(package private) void |
consumeWhitespace()
Advance the current parse position over any whitespace characters. |
(package private) int |
getCurrentLineNumber()
|
(package private) boolean |
isFinished()
Return true if there are no more characters to parse. |
(package private) void |
openedTag(int startOffset,
int endOffset,
java.lang.String tagName)
Invoke a callback method to inform the listener that we have found a start tag. |
(package private) void |
parse()
Process the entire input buffer, invoking callbacks on the listener object as appropriate. |
static void |
parse(java.lang.CharSequence seq,
CallbackListener l)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BODY_TAG
public static final int HEAD_TAG
public static final int SCRIPT_TAG
Constructor Detail |
---|
ReducedHTMLParser(java.lang.CharSequence s, CallbackListener l)
s
- is the sequence of chars to parse.l
- is the listener to invoke callbacks on.Method Detail |
---|
public static void parse(java.lang.CharSequence seq, CallbackListener l)
boolean isFinished()
int getCurrentLineNumber()
void consumeWhitespace()
java.lang.String consumeNonWhitespace()
boolean consumeMatch(java.lang.String s)
If there is not a match then leave the current parse position unchanged and return false.
s
- is the exact string to match.
java.lang.String consumeElementName()
TODO: implement this properly in compliance with spec
java.lang.String consumeAttrName()
TODO: implement this properly in compliance with spec
java.lang.String consumeString(char quote)
This method assumes that the leading quote has already been consumed.
java.lang.String consumeAttrValue()
void consumeExcept(java.lang.String s)
s
- is a set of characters that should not be discarded.void parse()
void openedTag(int startOffset, int endOffset, java.lang.String tagName)
startOffset
- endOffset
- tagName
- void closedTag(int startOffset, int endOffset, java.lang.String tagName)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |