y.io.gml
Class GMLTokenizer

java.lang.Object
  |
  +--y.io.gml.GMLTokenizer

public class GMLTokenizer
extends Object

This class is used to parse a valid stream from a reader, which contains well formed gml. A callback method must be registered with this class, whose methods will be invoked during the parsing of the stream.


Nested Class Summary
static interface GMLTokenizer.Callback
          The interface used for the callback during parsing.
static class GMLTokenizer.DebugCallback
          An implementation of the callback which can be used to debug the parser.
static class GMLTokenizer.EncoderCallback
          An implementation of the callback, which will call the appropriate methods on an encoder.
 
Field Summary
protected static int AMPERSAND
           
protected static int CLOSE
           
protected static int COMMENT
           
protected static int DIGIT
           
protected static int EOF
           
protected static int LETTER
           
protected static int NEWLINE
           
protected static int OPEN
           
protected static int QUOTE
           
protected static int UNKNOWN
           
protected static int WHITESPACE
           
 
Constructor Summary
GMLTokenizer()
          Creates a new instance of GMLTokenizer
GMLTokenizer(GMLTokenizer.Callback callback)
          Creates a new instance of GMLTokenizer and installs the given callback
 
Method Summary
protected  int classify(char c)
          classifies the given character
 GMLTokenizer.Callback getCallback()
          Getter for property callback.
protected  int lookAhead(PushbackReader reader)
          takes a look at the next character in the stream and classifies it using one of the constants.
protected  void parse(PushbackReader pbReader)
          this is the actual parsing method
 void parse(Reader reader)
          starts the parsing and will fire events to the registered callback
protected  void parseComment(PushbackReader reader)
          parses a comment whitespace
protected  char parseEntity(PushbackReader reader)
          parses an entity from a GML "instring"
protected  String parseInString(PushbackReader reader)
          parses the GML "instring"
protected  String parseKey(PushbackReader reader)
          parses a key
protected  List parseList(PushbackReader reader)
          parses a GML list
protected  Number parseNumber(PushbackReader reader)
          parses a Number (Double or Integer)
protected  String parseString(PushbackReader reader)
          parses a GML String, i.e. removes the quotes and replaces ISO 8859-1 entities with their corresponding characters.
protected  Object parseValue(PushbackReader reader)
          parses a value, which might be either a String, or a Number, i.e. either Integer or Double
protected  void parseWhiteSpace(PushbackReader reader)
          parses whitespace
 void setCallback(GMLTokenizer.Callback callback)
          Setter for property callback.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN

protected static final int OPEN
See Also:
Constant Field Values

CLOSE

protected static final int CLOSE
See Also:
Constant Field Values

AMPERSAND

protected static final int AMPERSAND
See Also:
Constant Field Values

QUOTE

protected static final int QUOTE
See Also:
Constant Field Values

WHITESPACE

protected static final int WHITESPACE
See Also:
Constant Field Values

LETTER

protected static final int LETTER
See Also:
Constant Field Values

DIGIT

protected static final int DIGIT
See Also:
Constant Field Values

EOF

protected static final int EOF
See Also:
Constant Field Values

NEWLINE

protected static final int NEWLINE
See Also:
Constant Field Values

COMMENT

protected static final int COMMENT
See Also:
Constant Field Values

UNKNOWN

protected static final int UNKNOWN
See Also:
Constant Field Values
Constructor Detail

GMLTokenizer

public GMLTokenizer()
Creates a new instance of GMLTokenizer


GMLTokenizer

public GMLTokenizer(GMLTokenizer.Callback callback)
Creates a new instance of GMLTokenizer and installs the given callback

Parameters:
callback - the callback to be used
Method Detail

parse

public void parse(Reader reader)
           throws IOException
starts the parsing and will fire events to the registered callback

Throws:
IOException - in the case of an I/O Exception
Parameters:
reader - the stream to be parsed

lookAhead

protected int lookAhead(PushbackReader reader)
                 throws IOException
takes a look at the next character in the stream and classifies it using one of the constants.

Throws:
IOException - in the case of an I/O Exception
Parameters:
reader - the reader from which to read
Returns:
one of the constants defined in this class

parse

protected void parse(PushbackReader pbReader)
              throws IOException
this is the actual parsing method

Throws:
IOException - in the case of an I/O Exception
Parameters:
pbReader - the reader which will be used to parse the stream

classify

protected int classify(char c)
classifies the given character

Parameters:
c - the character
Returns:
one of the constants defined in this class

parseWhiteSpace

protected void parseWhiteSpace(PushbackReader reader)
                        throws IOException
parses whitespace

Throws:
IOException - in the case of an I/O Exception
Parameters:
reader - the reader

parseComment

protected void parseComment(PushbackReader reader)
                     throws IOException
parses a comment whitespace

Throws:
IOException - in the case of an I/O Exception
Parameters:
reader - the reader

parseKey

protected String parseKey(PushbackReader reader)
                   throws IOException
parses a key

Throws:
IOException - in the case of an I/O Exception
Parameters:
reader - the reader
Returns:
the key

parseValue

protected Object parseValue(PushbackReader reader)
                     throws IOException
parses a value, which might be either a String, or a Number, i.e. either Integer or Double

Throws:
IOException - in the case of an I/O Exception
Parameters:
reader - the reader
Returns:
a String or a Number

parseNumber

protected Number parseNumber(PushbackReader reader)
                      throws IOException
parses a Number (Double or Integer)

Throws:
IOException - in the case of an I/O Exception
Parameters:
reader - the reader
Returns:
a Number (Double or Integer)

parseString

protected String parseString(PushbackReader reader)
                      throws IOException
parses a GML String, i.e. removes the quotes and replaces ISO 8859-1 entities with their corresponding characters.

Throws:
IOException - in the case of an I/O Exception
Parameters:
reader - the reader
Returns:
the translated GML "instring"

parseInString

protected String parseInString(PushbackReader reader)
                        throws IOException
parses the GML "instring"

IOException

parseEntity

protected char parseEntity(PushbackReader reader)
                    throws IOException
parses an entity from a GML "instring"

IOException

parseList

protected List parseList(PushbackReader reader)
                  throws IOException
parses a GML list

IOException

getCallback

public GMLTokenizer.Callback getCallback()
Getter for property callback.

Returns:
Value of property callback.

setCallback

public void setCallback(GMLTokenizer.Callback callback)
Setter for property callback.

Parameters:
callback - New value of property callback.

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003