|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.wkb4j.engine.WKBParser
Generate events from the submitted array of bytes holding binary data in the Well-Known Binary format.
It generates a beginGeometry event when it sees the beginning of a given Geometry,
an endGeometry event when it sees the end of a given Geometry, and an abortGeometry
event if something happens that makes the completion of the current Geometry impossible.
Points are treated differently from other Geometries: all the points in a Geometry are collected into a single
array of byte and passed to the WKBFactory all at once.
Events are nested, meaning that for a classical MultiLineString element with two LineStrings
made of respectively 3 and 2 Points each, the following events will occur:
The basic idea is to provide the author of each factory with as much freedom as possible while
allowing for strong performance.
wkbByteOrder aren't taken into account because will rely on the database to provide the data in the Big-Endian
format (MSB, Most Significant Byte), the Endian used in Java.
Inspired by the SAX API.
Creation date: 6 juil. 2002 23:49:28
Field Summary | |
static int |
DIMENSION2
|
static int |
DIMENSION3
|
protected boolean |
endianess
|
protected org.wkb4j.engine.WKBFactory |
factory
|
protected java.io.DataInputStream |
inputStream
|
protected org.wkb4j.engine.ResetableByteArrayInputStream |
internalBuffer
|
protected static org.apache.log4j.Logger |
log
|
protected java.lang.String[] |
words
|
Fields inherited from interface org.wkb4j.engine.WKBGeometryTypes |
linearRing, wkbGeometryCollection, wkbLineString, wkbMultiLineString, wkbMultiPoint, wkbMultiPolygon, wkbPoint, wkbPolygon |
Constructor Summary | |
WKBParser(org.wkb4j.engine.WKBFactory _factory)
Constructor for WKBParser. |
|
WKBParser(org.wkb4j.engine.WKBFactory _factory,
java.lang.String[] _words,
boolean _endianess)
Constructor for WKBParser. |
Method Summary | |
protected void |
decodeData(java.lang.String[] words,
int[] values)
Read the raw WKB data from the DataInputStream and generate the beginUnit/endUnit calls and the calls to the top-level geometries ( MultiLineString, LineString, Polygon, MultiPolygon,
GeometryCollection, Point |
private java.io.DataInputStream |
getInputStream()
Returns the DataInputStream used to transform bytes into native types ( int and double in our case). |
private org.wkb4j.engine.ResetableByteArrayInputStream |
getInternalBuffer()
Returns the ResetableByteArrayInputStream |
void |
parseData(byte[] buffer,
byte[] sridBuffer)
Load the raw bytes in the WKB format representing one record of the DB and generates the events. |
void |
parseData(byte[] buffer,
byte[][] datas)
Load the raw bytes in the WKB format and generates the events. |
void |
parseData(byte[] buffer,
int srid)
Load the raw bytes in the WKB format and generates the events. |
protected int |
parseInt(byte[] intBuffer,
boolean endianess)
|
protected boolean |
parseType(int geotype,
int dimension)
Read the given and generates the corresponding events. |
protected void |
readGeometryCollection()
Reads a GeometryCollection. |
protected void |
readLinearRing(int dimension)
Method readLinearRing. |
protected void |
readLineString(int dimension)
Reads a LineString. |
protected void |
readMultiLineString()
Reads a MultiLineString. |
protected void |
readMultiPoint()
Reads a MultiPoint. |
protected void |
readMultiPolygon(int dimension)
Reads a MultiPolygon. |
protected void |
readPoint(int dimension)
Reads a Point. |
protected void |
readPoints(int pointCount,
int dimension)
Reads a number of Points. |
protected void |
readPolygon(int dimension)
Reads a Polygon. |
private void |
setInternalBuffer(org.wkb4j.engine.ResetableByteArrayInputStream internalBuffer)
Sets the ResetableByteArrayInputStream |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static org.apache.log4j.Logger log
protected org.wkb4j.engine.WKBFactory factory
public static final int DIMENSION2
public static final int DIMENSION3
protected org.wkb4j.engine.ResetableByteArrayInputStream internalBuffer
protected java.io.DataInputStream inputStream
protected java.lang.String[] words
protected final boolean endianess
Constructor Detail |
public WKBParser(org.wkb4j.engine.WKBFactory _factory)
_factory
- that will receive the events.public WKBParser(org.wkb4j.engine.WKBFactory _factory, java.lang.String[] _words, boolean _endianess)
_factory
- that will receive the events.Method Detail |
public void parseData(byte[] buffer, byte[] sridBuffer) throws java.io.IOException
sridBuffer should contain an array of bytes holding the SRID of the current geometry.
If sridBuffer is null or longer than 4 bytes, the SRID of the current geometry is set to -1
- Parameters:
buffer
- array of bytes holding the data in the WKB formatsridBuffer
- .
java.io.IOException
protected int parseInt(byte[] intBuffer, boolean endianess) throws java.io.IOException
java.io.IOException
public void parseData(byte[] buffer, byte[][] datas) throws java.io.IOException
buffer
- array of bytes holding the data in the WKB format
java.io.IOException
public void parseData(byte[] buffer, int srid) throws java.io.IOException
buffer
- array of bytes holding the data in the WKB formatsrid
- The SRID of the current geometry.
java.io.IOException
private org.wkb4j.engine.ResetableByteArrayInputStream getInternalBuffer()
private void setInternalBuffer(org.wkb4j.engine.ResetableByteArrayInputStream internalBuffer)
internalBuffer
- The ResetableByteArrayInputStream to setprivate java.io.DataInputStream getInputStream()
int
and double
in our case).
protected void decodeData(java.lang.String[] words, int[] values)
MultiLineString, LineString, Polygon, MultiPolygon,
GeometryCollection, Point)
All the readGeometry method can throw IOException if something goes wrong.
protected boolean parseType(int geotype, int dimension) throws java.io.IOException
geotype
- type of the next Geometry.dimension
- dimension of the points contained in the next geometry.
java.io.IOException
protected void readMultiLineString() throws java.io.IOException
java.io.IOException
protected void readLineString(int dimension) throws java.io.IOException
dimension
- dimension of the points contained in this geometry.
java.io.IOException
protected void readPoints(int pointCount, int dimension) throws java.io.IOException
pointCount
- dimension
- unused parameter
java.io.IOException
protected void readMultiPolygon(int dimension) throws java.io.IOException
dimension
- dimension of the points contained in this geometry.
java.io.IOException
protected void readPolygon(int dimension) throws java.io.IOException
dimension
- dimension of the points contained in this geometry.
java.io.IOException
protected void readLinearRing(int dimension) throws java.io.IOException
dimension
- dimension of the points contained in this geometry.
java.io.IOException
protected void readMultiPoint() throws java.io.IOException
java.io.IOException
protected void readGeometryCollection() throws java.io.IOException
java.io.IOException
protected void readPoint(int dimension) throws java.io.IOException
dimension
- dimension of the points contained in this geometry.
java.io.IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |