Spatial DataBlade
JAVA API v8.21

com.ibm.spatial.io
Class GeometryReader

java.lang.Object
  extended by com.ibm.spatial.io.GeometryReader

public abstract class GeometryReader
extends java.lang.Object

An abstract superclass for reading and decoding of geometry objects. This class must be subclassed by classes that read geometries.

GeometryReader objects can normally read a specific format. When an input source is set (using the setInput method), it may be marked as "seek forward only". This setting means that geometries contained within the input source will only be read in order, possibly allowing the reader to avoid caching portions of the input containing data associated with geometries that have been read previously.

See Also:
GeometryWriter, SpatialManager

Method Summary
 void abort()
          Requests that any current read operation be aborted.
 void dispose()
          Allows any resources held by this object to be released.
 java.lang.String getFormatName()
          Returns a String identifying the format of the input source.
 java.lang.Object getInput()
          Returns the InputStream or other Object previously set as the input source.
 int getMinIndex()
          Returns the lowest valid index for reading a geometry.
 int getNumGeometries()
          Returns the number of geometries available from the current input source.
 boolean isSeekForwardOnly()
          Returns true if the current input source has been marked as seek forward only by passing true as the seekForwardOnly argument to the setInput method.
 Geometry read(int index)
          Reads the geometry at position specified by index, using supplied arguments specified by args.
abstract  Geometry read(int index, java.lang.Object[] args)
          Reads the geometry at position specified by index, using supplied arguments specified by args.
 java.util.Iterator readAll(java.lang.Object[] args)
          Returns an Iterator containing all the geometries, starting at the index given by getMinIndex, from the input source in the form of Geometry objects.
 boolean ready()
          Tell whether this stream is ready to be read.
 void reset()
          Restores the GeometryReader to its initial state.
 void setInput(java.lang.Object input)
          Sets the input source to the specified InputStream or other Object.
 void setInput(java.lang.Object input, boolean seekForwardOnly)
          Sets the input source to the specified InputStream or other Object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

reset

public void reset()
Restores the GeometryReader to its initial state. This implementation calls setInput(null, false).


dispose

public void dispose()
Allows any resources held by this object to be released. The default implementation does nothing.


getFormatName

public java.lang.String getFormatName()
Returns a String identifying the format of the input source.

This implementation returns an empty string.

Returns:
a String object identifying the format of the input source.

getMinIndex

public int getMinIndex()
Returns the lowest valid index for reading a geometry. The default value, returned by this implementation, is 0.

Returns:
the lowest valid index for reading a geometry.

getNumGeometries

public int getNumGeometries()
Returns the number of geometries available from the current input source. If the reader can't find the answer (for example, by querying the input source), then it returns -1.

The default value, returned by this implementation, is 1.

Returns:
the number of geometries available from the current input source

isSeekForwardOnly

public boolean isSeekForwardOnly()
Returns true if the current input source has been marked as seek forward only by passing true as the seekForwardOnly argument to the setInput method.

Returns:
true if the current input source has been marked as seek forward only, otherwise return false

ready

public boolean ready()
              throws java.io.IOException
Tell whether this stream is ready to be read. This implementation always returns true.

Returns:
True if the next read operation is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.
Throws:
java.io.IOException - if an I/O error occurs

read

public Geometry read(int index)
              throws java.io.IOException,
                     SpatialException
Reads the geometry at position specified by index, using supplied arguments specified by args. Reads a geometry from a position specified by index.

This implementation returns read(index, null).

Parameters:
index - the position in the current input source
Returns:
a geometry object read from the current input source, at the position apecified by index, or null if the end of the input data source has been reached
Throws:
java.lang.IllegalStateException - if the input source has not been set
java.lang.IndexOutOfBoundsException - if the supplied index is less than the minimum accepted index (index < getMinIndex()).
java.io.IOException - if an error occurs during reading
SpatialException - if a spatial data format error occurs during reading

read

public abstract Geometry read(int index,
                              java.lang.Object[] args)
                       throws java.io.IOException,
                              SpatialException
Reads the geometry at position specified by index, using supplied arguments specified by args. Reads a geometry from a position specified by index.

Read arguments may optionally be supplied in args. If no read arguments are needed, then args is ignored.

Parameters:
index - the position in the current input source
args - array of Object holding arguments supplied to this reader
Returns:
a geometry object read from the current input source, at the position apecified by index, or null if the end of the input data source has been reached
Throws:
java.lang.IllegalStateException - if the input source has not been set
java.lang.IndexOutOfBoundsException - if the supplied index is less than the minimum accepted index (index < getMinIndex()).
java.io.IOException - if an error occurs during reading
SpatialException - if a spatial data format error occurs during reading

readAll

public java.util.Iterator readAll(java.lang.Object[] args)
                           throws java.io.IOException,
                                  SpatialException
Returns an Iterator containing all the geometries, starting at the index given by getMinIndex, from the input source in the form of Geometry objects. An optional array of parameters can be specified in args to control the read operation.

Parameters:
args - an array of objects to control the read operation
Returns:
an Iterator representing the objects read as Geometrys
Throws:
java.lang.IllegalStateException - if the input source has not been set
java.io.IOException - if an error occurs during reading
SpatialException - if a spatial data format error occurs during reading

setInput

public void setInput(java.lang.Object input,
                     boolean seekForwardOnly)
Sets the input source to the specified InputStream or other Object. The input source must be set before any read methods are used. Any currently set input source will be removed if input is null. minIndex is initialized to 0.

If seekForwardOnly parameter is true, then the value returned by getMinIndex is increased as each geometry or other object is read, otherwise getMinIndex will return the value passed by the last read operation if the case, or 0.

Parameters:
input - the InputStream or other Object to use as a data source
seekForwardOnly - if true, geometries may only be read in ascending order from this input source.
Throws:
java.lang.IllegalArgumentException - if input is not an acceptable instance
See Also:
getInput()

setInput

public void setInput(java.lang.Object input)
Sets the input source to the specified InputStream or other Object. The input source must be set before any read methods are used. Any currently set input source will be removed if input is null. minIndex is initialized to 0.

This method is equivalent to setInput(input, false).

Parameters:
input - the InputStream or other Object to use as a data source
Throws:
java.lang.IllegalArgumentException - if input is not an acceptable instance
See Also:
getInput()

getInput

public java.lang.Object getInput()
Returns the InputStream or other Object previously set as the input source. If the input source has not been set, null is returned.

Returns:
the Object that will be used for future decoding, or null.
See Also:
setInput(java.lang.Object, boolean)

abort

public void abort()
Requests that any current read operation be aborted.

Readers should call clearAbortFlag at the beginning of each read, and poll the value of abortFlag during the read.


Spatial DataBlade
JAVA API v8.21


Licensed Materials - Property of IBM
Copyright IBM Corp. 2002, 2012 All Rights Reserved.