Search this API

y.io.gml
Class GMLTokenizer

java.lang.Object
  extended by y.io.gml.GMLTokenizer

public class GMLTokenizer
extends java.lang.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.

 
Your browser does not support SVG content.

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
          The type constant for '&'
protected static int CLOSE
          The closing brace type constant ']'
protected static int COMMENT
          The type constant for a comment in a gml file
protected static int DIGIT
          The type constant for a digit in GML
protected static int EOF
          The type constant for the end of file token
protected static int LETTER
          The type constant for a letter in GML
protected static int NEWLINE
          The type constant for a newline in a gml file
protected static int OPEN
          The opening brace type constant '['
protected static int QUOTE
          The type constant for '"'
protected static int UNKNOWN
          The type constant for anything that cannot be categorized in GML
protected static int WHITESPACE
          The type constant for any type of whitespace in GML
 
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(java.io.PushbackReader reader)
          takes a look at the next character in the stream and classifies it using one of the constants.
protected  void parse(java.io.PushbackReader pbReader)
          this is the actual parsing method
 void parse(java.io.Reader reader)
          starts the parsing and will fire events to the registered callback
protected  void parseComment(java.io.PushbackReader reader)
          parses a comment whitespace
protected  char parseEntity(java.io.PushbackReader reader)
          parses an entity from a GML "instring"
protected  java.lang.String parseInString(java.io.PushbackReader reader)
          parses the GML "instring"
protected  java.lang.String parseKey(java.io.PushbackReader reader)
          parses a key
protected  java.util.List parseList(java.io.PushbackReader reader)
          parses a GML list
protected  java.lang.Number parseNumber(java.io.PushbackReader reader)
          parses a Number (Double or Integer)
protected  java.lang.String parseString(java.io.PushbackReader reader)
          parses a GML String, i.e. removes the quotes and replaces ISO 8859-1 entities with their corresponding characters.
protected  java.lang.Object parseValue(java.io.PushbackReader reader)
          parses a value, which might be either a String, or a Number, i.e. either Integer or Double
protected  void parseWhiteSpace(java.io.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
The opening brace type constant '['

See Also:
Constant Field Values

CLOSE

protected static final int CLOSE
The closing brace type constant ']'

See Also:
Constant Field Values

AMPERSAND

protected static final int AMPERSAND
The type constant for '&'

See Also:
Constant Field Values

QUOTE

protected static final int QUOTE
The type constant for '"'

See Also:
Constant Field Values

WHITESPACE

protected static final int WHITESPACE
The type constant for any type of whitespace in GML

See Also:
Constant Field Values

LETTER

protected static final int LETTER
The type constant for a letter in GML

See Also:
Constant Field Values

DIGIT

protected static final int DIGIT
The type constant for a digit in GML

See Also:
Constant Field Values

EOF

protected static final int EOF
The type constant for the end of file token

See Also:
Constant Field Values

NEWLINE

protected static final int NEWLINE
The type constant for a newline in a gml file

See Also:
Constant Field Values

COMMENT

protected static final int COMMENT
The type constant for a comment in a gml file

See Also:
Constant Field Values

UNKNOWN

protected static final int UNKNOWN
The type constant for anything that cannot be categorized in GML

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(java.io.Reader reader)
           throws java.io.IOException
starts the parsing and will fire events to the registered callback

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

lookAhead

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

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

parse

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

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

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(java.io.PushbackReader reader)
                        throws java.io.IOException
parses whitespace

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

parseComment

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

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

parseKey

protected java.lang.String parseKey(java.io.PushbackReader reader)
                             throws java.io.IOException
parses a key

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

parseValue

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

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

parseNumber

protected java.lang.Number parseNumber(java.io.PushbackReader reader)
                                throws java.io.IOException
parses a Number (Double or Integer)

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

parseString

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

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

parseInString

protected java.lang.String parseInString(java.io.PushbackReader reader)
                                  throws java.io.IOException
parses the GML "instring"

Throws:
java.io.IOException

parseEntity

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

Throws:
java.io.IOException

parseList

protected java.util.List parseList(java.io.PushbackReader reader)
                            throws java.io.IOException
parses a GML list

Throws:
java.io.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-2022,
yWorks GmbH.
All rights reserved.