org.h2gis.functions.io.shp.internal

## Interface ShapeHandler

All Known Implementing Classes:
  MultiLineHandler, MultiPointHandler, PointHandler, PolygonHandler

    public interface ShapeHandler

A ShapeHandler defines what is needed to construct and persist geometries based upon the shapefile specification.

Author:
  aaime, Ian Schneider

### Method Summary

All Methods Instance Methods Abstract Methods
`int` `getLength(Object geometry)` Get the length of the given geometry Object in bytes not 16-bit words.
`ShapeType` `getShapeType()` Get the ShapeType of this handler.
`org.locationtech.jts.geom.Geometry` `read(ReadBufferManager buffer, ShapeType type)` Read a geometry from the ByteBuffer.
`void` `write(WriteBufferManager shapeBuffer, Object geometry)` Write the geometry into the ByteBuffer.

### Method Detail

#### getShapeType

    ShapeType getShapeType()

Get the ShapeType of this handler.

Returns:
  The ShapeType.

#### read

    org.locationtech.jts.geom.Geometry read(ReadBufferManager buffer,
                                            ShapeType type)
                                     throws IOException

Read a geometry from the ByteBuffer. The buffer's position, byteOrder, and limit are set to that which is needed. The record has been read as well as the shape type integer. The handler need not worry about reading unused information as the ShapefileReader will correctly adjust the buffer position after this call.

Parameters:
  `buffer` - The ByteBuffer to read from.
Returns:
  A geometry object.
Throws:
  `IOException`

#### write

    void write(WriteBufferManager shapeBuffer,
               Object geometry)
        throws IOException

Write the geometry into the ByteBuffer. The position, byteOrder, and limit are all set. The handler is not responsible for writing the record or shape type integer.

Parameters:
  `shapeBuffer` - The ByteBuffer to write to.
  `geometry` - The geometry to write.
Throws:
  `IOException`

#### getLength

    int getLength(Object geometry)

Get the length of the given geometry Object in bytes not 16-bit words. This is easier to keep track of, since the ByteBuffer deals with bytes. Do not include the 8 bytes of record.

Parameters:
  `geometry` - The geometry to analyze.
Returns:
  The number of bytes the shape will take up.