gnu.javax.swing.text.html.parser.support.low

Class ReaderTokenizer

Known Direct Subclasses:
Parser

public class ReaderTokenizer
extends Constants

Reader splits the input char sequence into tokens.

Field Summary

protected boolean
advanced
This is set to true each time the getNextToken is called.
protected boolean
backupMode
If true, the returned tokens are also placed in the backup queue.

Fields inherited from class gnu.javax.swing.text.html.parser.support.low.Constants

AP, BEGIN, COMMENT_END, COMMENT_OPEN, COMMENT_TRIPLEDASH_END, DOUBLE_DASH, END, ENTITY, ENTITY_NAMED, ENTITY_NUMERIC, EOF, EQ, EXCLAMATION, NUMTOKEN, OTHER, QUOT, SCRIPT, SCRIPT_CLOSE, SCRIPT_OPEN, SGML, SLASH, STYLE, STYLE_CLOSE, STYLE_OPEN, TAG, TAG_CLOSE, WS, bDIGIT, bLETTER, bLINEBREAK, bNAME, bQUOTING, bSINGLE_CHAR_TOKEN, bSPECIAL, bWHITESPACE

Constructor Summary

ReaderTokenizer()
Creates a new ReaderTokenizer.

Method Summary

void
error(String msg, Token at)
Invokes the error handler.
String
getEndOfLineSequence()
Return the sequence, used to separate lines in the document.
Token
getNextToken()
Get the next token.
Token
getTokenAhead()
Get a token, bein immediatley ahead.
Token
getTokenAhead(int ahead)
Get a token, lying the given number of tokens ahead. getToken(0) will return the same token, what would be returned by getNextToken().
void
mark(boolean mode)
Turns the backup mode on or off.
void
reset()
Reset the internal cursor to the position where the mark() was last time called.
void
reset(Reader a_reader)
Prepare for new parsing from the given stream.

Methods inherited from class gnu.javax.swing.text.html.parser.support.low.Constants

endMatches

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

advanced

protected boolean advanced
This is set to true each time the getNextToken is called. Used in preventing loops when all patterns refuse to accept the invalid input.

backupMode

protected boolean backupMode
If true, the returned tokens are also placed in the backup queue.

Constructor Details

ReaderTokenizer

public ReaderTokenizer()
Creates a new ReaderTokenizer. The reset(...) method must be subsequently called to set the reader.

Method Details

error

public void error(String msg,
                  Token at)
Invokes the error handler.

getEndOfLineSequence

public String getEndOfLineSequence()
Return the sequence, used to separate lines in the document.
Returns:
one of \n, \r or \r\n.

getNextToken

public Token getNextToken()
Get the next token.
Returns:

getTokenAhead

public Token getTokenAhead()
Get a token, bein immediatley ahead. If the end of stream is reached, the EOF token is always returned. The method is equivalent calling getTokenAhead(0).

getTokenAhead

public Token getTokenAhead(int ahead)
Get a token, lying the given number of tokens ahead. getToken(0) will return the same token, what would be returned by getNextToken(). getToken(..) does change the current position in the input stream. If the end of stream is reached, the EOF token is always returned.

mark

public void mark(boolean mode)
Turns the backup mode on or off. It is possible to return where the mark(true) was last called by calling reset().
Parameters:
mode - True if it is required to save tokens, making returning to the current point possible.

reset

public void reset()
Reset the internal cursor to the position where the mark() was last time called. Switches the backup mode off.

reset

public void reset(Reader a_reader)
Prepare for new parsing from the given stream.
Parameters:
a_reader - A reader to parse from.

ReaderTokenizer.java -- splits the input char sequence int tokens. Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.