Class GeometryEncoder<T extends Geometry>

Object
ObjectEncoder<T>
GeometryEncoder<T>
Type Parameters:
T -
Direct Known Subclasses:
GenericGeometryEncoder, GenericGeometryEncoder, GeometryCollectionEncoder, RingEncoder

public abstract class GeometryEncoder<T extends Geometry> extends ObjectEncoder<T>
Base class for all encoders writing a Geometry. Implementations should provide one of the two "encode" methods, encode(Geometry, AttributesImpl, GMLWriter) or encode(Geometry, AttributesImpl, GMLWriter, String), failing to do so will result in a infinite recursion and eventually in a StackOverflowError
Author:
Justin Deoliveira, OpenGeo, Andrea Aime - GeoSolutions
  • Constructor Details

    • GeometryEncoder

      protected GeometryEncoder(Encoder encoder)
    • GeometryEncoder

      protected GeometryEncoder(Encoder encoder, boolean encodeGmlId)
  • Method Details

    • encode

      public void encode(T geometry, AttributesImpl atts, GMLWriter handler, String gmlId) throws Exception
      Encodes a geometry value with a given gmlId (implementations might choose to use it to generate gml:id attributes, depending on the GML version. The default implementation does not use gmlId and simply delegates to encode(Geometry, AttributesImpl, GMLWriter)
      Parameters:
      geometry - The Geometry to be encoded
      atts - Its attributes
      handler - The handler used to write XML
      gmlId - If not null, some implementation will use to as the gml:id (and to build ids for the nested features)
      Throws:
      Exception
    • cloneWithGmlId

      protected AttributesImpl cloneWithGmlId(AttributesImpl atts, String gmlId)
      Returns a new AttributesImpl based on the provided on, with the addition of a gml:id attribute
      Parameters:
      atts - The base attributes (can be null)
      gmlId - The desired gml:id value
      Returns:
      The provided atts object if gmlId is null, a clone of the provided one plus the gml:id attribute otherwise
    • addGmlId

      protected void addGmlId(AttributesImpl attributes, String gmlId)
      Adds a gmlId to an existing and non null attribute set
    • encode

      public void encode(T geometry, AttributesImpl atts, GMLWriter handler) throws Exception
      Encodes a geometry value
      Specified by:
      encode in class ObjectEncoder<T extends Geometry>
      Parameters:
      geometry - The Geometry to be encoded
      atts - Its attributes
      handler - The handler used to write XML
      Throws:
      Exception