|
EchoPoint 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object echopoint.ui.template.SGMLTag
Convenient class for parsing SGML tokens from a page.
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); } }
Field Summary | |
static char |
doubleQuote
|
static char |
singleQuote
|
Constructor Summary | |
SGMLTag(PositionReader input)
Create new SGML tag reference, starting at current location of the PositionReader. |
|
SGMLTag(PositionReader input,
boolean parseIt)
Create new SGML tag reference, starting at current location of the PositionReader. |
Method Summary | |
java.util.Iterator |
attributes(boolean upperCase)
Get list of attribute names. |
boolean |
finished()
Checked whether this tag indicates we're at the end of the list. |
java.lang.String |
getAttribute(java.lang.String key,
java.lang.String defaultValue)
Return value of attribute (parameter) setting in SGML tag. |
java.util.HashMap |
getAttributesWithValues()
Return tag attributes and values. |
long |
getEnd()
Gets the end position of the tag in the stream ie: just AFTERE the closing > character. |
java.lang.String |
getName()
get the Name of this SGML tag, in uppercase format. |
int |
getOffset()
returns the number of chars skipped before the starting '<' |
long |
getStart()
Gets the start position of the tag in the stream ie: just AFTER the starting < character |
static boolean |
isDelimiter(char c)
Decide whether character is SGML delimiter or equals. |
boolean |
isNamed(java.lang.String name)
Check name of tag. |
boolean |
isSelfTerminated()
|
boolean |
isWellFormed()
Check for well-formedness of this tag. |
java.lang.String |
nextToken(PositionReader input)
Read next token from string. |
java.lang.String |
nextToken(PositionReader input,
boolean skipWhitespaces)
Read next token from string. |
void |
parse(PositionReader input)
Attempts to read all the attribuets of the tag up to its closing > character. |
protected void |
searchStart(PositionReader input)
Skip over any HTML-style comments, as denoted by matched <-- ... |
static int |
skipWhiteSpace(PositionReader r)
could be overwritten |
java.lang.String |
toString()
Render this tag as a string. |
java.lang.String |
value(java.lang.String attributeName,
java.lang.String defaultValue)
Get attribute value, or default if not set. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final char doubleQuote
public static final char singleQuote
Constructor Detail |
public SGMLTag(PositionReader input) throws java.io.IOException
Note that this constructor skips over any HTML-style comments, as denoted by matched <-- ... --> pairs.
public SGMLTag(PositionReader input, boolean parseIt) throws java.io.IOException
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.
Method Detail |
public java.util.Iterator attributes(boolean upperCase)
public boolean finished()
public java.lang.String getAttribute(java.lang.String key, java.lang.String defaultValue)
public java.util.HashMap getAttributesWithValues()
public java.lang.String getName()
public int getOffset()
public boolean isSelfTerminated()
public boolean isNamed(java.lang.String name)
public boolean isWellFormed()
public java.lang.String nextToken(PositionReader input) throws java.io.IOException
java.io.IOException
public java.lang.String nextToken(PositionReader input, boolean skipWhitespaces) throws java.io.IOException
java.io.IOException
public void parse(PositionReader input) throws java.io.IOException
input
- - the input PositionReader
java.io.IOException
- - of courseprotected void searchStart(PositionReader input) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
public java.lang.String value(java.lang.String attributeName, java.lang.String defaultValue)
public static boolean isDelimiter(char c)
public static int skipWhiteSpace(PositionReader r) throws java.io.IOException
java.io.IOException
public long getEnd()
Note this is the same as the tag start if the attributes of the tag have not been parsed.
public long getStart()
|
EchoPoint 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |