|
PAJES 2.3.9 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.pajes.html.PajeParser
The PajeParser class takes an input stream and parses it into
"tokens", allowing the tokens to be read one at a time. The parser can
recognize tags and raw text.
The most usual use of this class is to be passed to PajeTemplate.generate(org.pajes.html.PajeParser) methods to create a Paje instance. However,
a Paje can be generated directly from the parser with the toPaje()
method.
Alternatively, a typical application first constructs an instance of this
class and then repeatedly loops, calling the next method in
each iteration of the loop until it returns the value .
EOF
Note: will also be returned in the case of
invalid HTML code.
EOF
PajeTemplate| Field Summary | |
static int |
EOF
A constant indicating that the end of the stream has been read. |
static int |
READY
A constant used to indicate that no tokens have been read. |
static int |
TAG
A constant indicating that an HTML tag has been read. |
static int |
TEXT
A constant indicating that raw text has been read. |
| Constructor Summary | |
PajeParser(java.io.File f)
Creates an PajeParser from a given file system file. |
|
PajeParser(java.io.InputStream i)
Creates an PajeParser from an input stream. |
|
PajeParser(java.io.Reader r)
Creates an PajeParser from a Reader. |
|
PajeParser(java.lang.String f)
Creates an PajeParser from a given file system file. |
|
PajeParser(java.net.URL u)
Creates an PajeParser from a file from the given URL. |
|
| Method Summary | |
java.lang.String |
getAttribute(java.lang.String name)
Returns the value of the specified attribute name. |
java.lang.String[][] |
getAttributes()
Returns the attributes of the current token. |
int |
getColumnNumber()
Returns the current column number. |
int |
getLineNumber()
Returns the current line number. |
java.lang.String |
getToken()
Returns the text of the current token. |
static void |
main(java.lang.String[] args)
Allows the PajeParser to be called from the command line to validate one or more files. |
int |
next()
Reads the next token from the file. |
void |
pushBack()
The pushBack() method allows you to 'unread' the last token so that the next call to next() will return the same value. |
void |
setDecodeCharacterEntities(boolean decode)
Determines whether any HTML named character entities (", &, < and >) found in TEXT are to be
converted to the actual character. |
Paje |
toPaje()
Parses the HTML source and returns a Paje instance. |
Paje |
toPaje(PajeTemplate template)
Parses the HTML source using the specified template, and returns a Paje instance. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int EOF
public static final int READY
public static final int TAG
public static final int TEXT
| Constructor Detail |
public PajeParser(java.io.File f)
throws java.io.IOException
f - the file to be read.
java.io.IOException - if an exception occurs parsing the file.
java.io.FileNotFoundException - if the specified file does not exist or is
a directory.
public PajeParser(java.io.InputStream i)
throws java.io.IOException
i - the InputStream from which the file will be read.
java.io.IOException - if an exception occurs parsing the file.
java.io.FileNotFoundException - if the specified InputStream is null.
public PajeParser(java.io.Reader r)
throws java.io.IOException
r - the Reader from which the file will be read.
java.io.IOException - if an exception occurs parsing the file.
public PajeParser(java.lang.String f)
throws java.io.IOException
f - the name of the file to be read.
java.io.IOException - if an exception occurs parsing the file.
java.io.FileNotFoundException - if the specified file cannot be located.
public PajeParser(java.net.URL u)
throws java.net.MalformedURLException,
java.io.IOException
u - the URL from which the file will be read.
java.net.MalformedURLException - if a null URL is specified.
java.io.IOException - if an exception occurs parsing the file.| Method Detail |
public java.lang.String getAttribute(java.lang.String name)
name - The attribute name to be located.
TAG.getAttributes()public java.lang.String[][] getAttributes()
TAG, an array of the tag attributes will be returned. Otherwise, null
will be returned.
The value at index [0][0] will always be the tag name (e.g. input or a).
The value at index [0][1] will always be null, unless the TAG
is empty (i.e. it has the form <tag_name/>), in which case [0][1]
will contain "/". The attribute name (element 0 in the second array
dimension) will always be returned in LOWER case. The attribute value
(element 1 in the second array dimension) will always have any
surrounding single or double quotes removed. For attributes with no
value (e.g. mayscript or nowrap), the value will always be null. A
third null element (i.e. element 2 in the second array dimension) is
always returned in the second array dimension for whatever purpose may
be made of it.
getAttribute(java.lang.String)public int getColumnNumber()
public void setDecodeCharacterEntities(boolean decode)
TEXT are to be
converted to the actual character.
decode - if true, any named character entities found in a TEXT token will be returned as their actual character, or if
false (the default), they will be returned as named entities.public int getLineNumber()
public java.lang.String getToken()
TEXT, or
TAG, the corresponding text will be returned. Otherwise, null
will be returned.
For type TEXT, the text returned will be the text between tags.
For TAG, the contents of the tag (without the < and >
characters) will be returned.
public static void main(java.lang.String[] args)
args - the first argument is a file to be parsed and verified, or a
directory in which all files ending in .htm or .html will be
verified.
public int next()
throws java.io.IOException
EOF indicates that
the end of the input stream has been reached.
TAG indicates that the token is an
HTML tag. TEXT indicates that the
token is text between HTML tags. getToken(). To get the attributes of a
TAG token, use getAttributes() or getAttribute(java.lang.String).
java.io.IOException - if an exception occurs parsing the file.
PajeParserException - if an unmatched quote is detected.
public void pushBack()
throws java.io.IOException
next() will return the same value.
java.io.IOException - if an exception occurs 'unreading' the token.
public Paje toPaje()
throws java.io.IOException
Paje instance.
java.io.IOException - if an error occurs reading the HTML source.
public Paje toPaje(PajeTemplate template)
throws java.io.IOException
Paje instance.
template - the PajeTemplate that will be applied to the HTML source
to generate the Paje.
java.io.IOException - if an error occurs reading the HTML source.
|
PAJES 2.3.9 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||