| java.lang.Object org.wings.template.parser.SGMLTag
SGMLTag | public class SGMLTag (Code) | | Convenient class for parsing SGML tokens from a page.
This class is optimized for speed, not ease of use.
(Though I'd contend its fairly easy to use anyway!).
Other than earlier versions of this class this one reads
its content from a Reader to avoid reading
the whole file into a String before parsing it.
The Reader is required to support the mark()
operation.
Tags are only read enough to find out what the tag name is;
If you want to read the full tag call parse(inputReader) .
This is done so that applications don't spend time processing
tags about which they care little.
Here's a sample piece of code which uses this class to read
all SGML tags on a page:
void showTags(PrintWriter out, Reader input)
{
SGMLTag tag = new SGMLTag(input);
while (!tag.finished()) {
out.println ("tag: " + tag.toString());
tag = new SGMLTag (input);
}
}
author: Tim Williams author: Henner Zeller |
Constructor Summary | |
public | SGMLTag(Reader input, boolean parseIt) Create new SGML tag reference, starting at current location
of the Reader.
At first, only the type of tag (first argument) is read if
parseIt is false.
Tag may not be well-formed: if interested, call "parse(input)"
directly afterwards (without reading any characters
from the Reader) to get the attributes.
Note that this constructor skips over any HTML-style comments,
as denoted by matched <-- ... | public | SGMLTag(Reader input) Create new SGML tag reference, starting at current location
of the Reader. |
COMMENT_STARTCOMMENT_END | final static String COMMENT_STARTCOMMENT_END(Code) | | |
doubleQuote | final public static char doubleQuote(Code) | | |
singleQuote | final public static char singleQuote(Code) | | |
SGMLTag | public SGMLTag(Reader input, boolean parseIt) throws IOException(Code) | | Create new SGML tag reference, starting at current location
of the Reader.
At first, only the type of tag (first argument) is read if
parseIt is false.
Tag may not be well-formed: if interested, call "parse(input)"
directly afterwards (without reading any characters
from the Reader) to get the attributes.
Note that this constructor skips over any HTML-style comments,
as denoted by matched <-- ... --> pairs.
Parameters: input - the Reader being parsed for SGML tags Parameters: parseIt - boolean which denotes if SGMLTag should beparsed fully See Also: SGMLTag.attributes |
SGMLTag | public SGMLTag(Reader input) throws IOException(Code) | | Create new SGML tag reference, starting at current location
of the Reader. Read all attributes.
Note that this constructor skips over any HTML-style comments,
as denoted by matched <-- ... --> pairs.
Parameters: input - the Reader being parsed for SGML tags See Also: SGMLTag.attributes |
attributes | public Iterator attributes(boolean upperCase)(Code) | | Get list of attribute names.
Parameters: upperCase - true returns names in all uppercase (good forcase-insensitive applications), false returns attribute nameswith same case as in original text enumeration of attribute names specified as strings,or null if this tag is poorly formed |
finished | public boolean finished()(Code) | | Checked whether this tag indicates we're at the end of the list.
Note: The end tag is not usuable as an SGML tag.
true if this tag represents end of tags, and is not usuable |
getAttribute | public String getAttribute(String key, String defaultValue)(Code) | | Return value of attribute (parameter) setting in SGML tag.
Parameters: key - name (uppercase) of attribute for which to check Parameters: defaultValue - value if attribute unset See Also: SGMLTag.attributes See Also: SGMLTag.value value of that attribute, or default if not defined |
getName | public String getName()(Code) | | get the Name of this SGML tag, in uppercase format.
For example, P for paragraph, B for bold, etc.
This value is set to null when whitespace or another
problem was encountered where the tag would be.
|
getOffset | public int getOffset()(Code) | | returns the number of chars skipped before the
starting '<'
|
isNamed | public boolean isNamed(String name)(Code) | | Check name of tag.
(Comparision is case-insensitive.)
true if passed tag matches this one. |
isWellFormed | public boolean isWellFormed()(Code) | | Check for well-formedness of this tag.
Note that calling this method causes rest of tag to be parsed.
true if tag is a well-formed SGML tag, false otherwise |
nextToken | public String nextToken(Reader input) throws IOException(Code) | | Read next token from string.
A token is a space-delimited word, a string in quotes
(returned with quotes), a delimiter such as a greater-than,
less-than, or equals sign.
Quotes marks inside quoted strings may be escaped with a
backslash (\) character.
next token, or null if whitespace was encountered |
nextToken | public String nextToken(Reader input, boolean skipWhitespaces) throws IOException(Code) | | Read next token from string.
A token is a space-delimited word, a string in quotes
(returned with quotes), a delimiter such as a greater-than,
less-than, or equals sign.
Quotes marks inside quoted strings may be escaped with a
backslash (\) character.
next token, or null if whitespace was encountered |
searchStart | protected void searchStart(Reader input) throws IOException(Code) | | Skip over any HTML-style comments,
as denoted by matched <-- ... --> pairs.
Parameters: input - the reader being parsed for SGMLtags |
toString | public String toString()(Code) | | Render this tag as a string.
SGML tag as string, showing range and values |
value | public String value(String attributeName, String defaultValue)(Code) | | Get attribute value, or default if not set.
Case is ignored, value("a") will return the same
result as value("A"). Note also that if wish to
check whether value was set, you can pass null
as the defaultValue.
Parameters: attributeName - attribute for which to check Parameters: defaultValue - value if attribute unset value of attribute, or defaultValue if not available |
|
|