Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.aendvari.common.osm
Class OsmReader  view OsmReader download OsmReader.java

java.lang.Object
  extended bycom.aendvari.common.osm.OsmReader

public class OsmReader
extends java.lang.Object

This class reads an "XML-like" file and converts it into an Osm tree.

NOTE: The file uses a subset of the XML syntax. This class is NOT an XML parser, but instead the files used by this reader are able to be read by other XML parsers.


Nested Class Summary
protected static interface OsmReader.State
          An interface for setting the current state of a read.
 
Field Summary
protected static int currentLine
          The current line number being read.
protected static java.lang.String lastOpenTag
          The name of the last known "open" tag.
protected static int lastOpenTagLine
          The line number of the last known "open" tag.
protected static java.lang.String[][] specialCharacters
          Special characters that need to be converted into their text values
 
Constructor Summary
OsmReader()
           
 
Method Summary
private static java.lang.String convertSpecialCharacters(java.lang.String data)
          Converts the special characters of a string into their secondary form.
private static Osm executeRead(java.io.Reader bufferedReader)
          Initializes the OSM with the data from the reader.
private static void extractTagAttributes(OsmNode node, java.lang.String tag)
          Extract the attributes from a <tag>.
private static OsmNode nodeFromTag(Osm osm, java.lang.String tag)
          Create a new OsmNode from the given <tag>.
private static java.lang.String nodeNameFromTag(java.lang.String tag)
          Extracts the name of a node from the tag.
private static boolean peekMatch(java.io.Reader reader, java.lang.String match)
          Peeks into the read stream to see if the given string matches the same number of characters in the upcoming stream.
static Osm read(java.io.Reader bufferedReader)
          Parses a buffered stream into the reader.
private static void readBuffer(java.io.Reader reader, OsmNode node, int readState)
          Reads the buffer character by character matching with < and > to determine tags, and their contents.
private static java.lang.String replaceAll(java.lang.String source, java.lang.String original, java.lang.String replace)
          Replaces all the matching values of a string with their replacement value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentLine

protected static int currentLine
The current line number being read.


lastOpenTagLine

protected static int lastOpenTagLine
The line number of the last known "open" tag.


lastOpenTag

protected static java.lang.String lastOpenTag
The name of the last known "open" tag.


specialCharacters

protected static java.lang.String[][] specialCharacters
Special characters that need to be converted into their text values

Constructor Detail

OsmReader

public OsmReader()
Method Detail

read

public static Osm read(java.io.Reader bufferedReader)
                throws java.lang.Exception
Parses a buffered stream into the reader.


executeRead

private static Osm executeRead(java.io.Reader bufferedReader)
                        throws java.lang.Exception
Initializes the OSM with the data from the reader.


readBuffer

private static void readBuffer(java.io.Reader reader,
                               OsmNode node,
                               int readState)
                        throws java.lang.Exception
Reads the buffer character by character matching with < and > to determine tags, and their contents.


nodeNameFromTag

private static java.lang.String nodeNameFromTag(java.lang.String tag)
Extracts the name of a node from the tag.


nodeFromTag

private static OsmNode nodeFromTag(Osm osm,
                                   java.lang.String tag)
Create a new OsmNode from the given <tag>.


extractTagAttributes

private static void extractTagAttributes(OsmNode node,
                                         java.lang.String tag)
                                  throws java.lang.Exception
Extract the attributes from a <tag>.


peekMatch

private static boolean peekMatch(java.io.Reader reader,
                                 java.lang.String match)
                          throws java.lang.Exception
Peeks into the read stream to see if the given string matches the same number of characters in the upcoming stream.


convertSpecialCharacters

private static java.lang.String convertSpecialCharacters(java.lang.String data)
Converts the special characters of a string into their secondary form.


replaceAll

private static java.lang.String replaceAll(java.lang.String source,
                                           java.lang.String original,
                                           java.lang.String replace)
Replaces all the matching values of a string with their replacement value.