Package org.geotools.gml2.simple
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)
orencode(Geometry, AttributesImpl, GMLWriter, String)
, failing to do so will result in a infinite recursion and eventually in aStackOverflowError
- Author:
- Justin Deoliveira, OpenGeo, Andrea Aime - GeoSolutions
-
-
Field Summary
-
Fields inherited from class ObjectEncoder
encoder
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GeometryEncoder(Encoder encoder)
protected
GeometryEncoder(Encoder encoder, boolean encodeGmlId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addGmlId(AttributesImpl attributes, String gmlId)
Adds a gmlId to an existing and non null attribute setprotected AttributesImpl
cloneWithGmlId(AttributesImpl atts, String gmlId)
Returns a new AttributesImpl based on the provided on, with the addition of a gml:id attributevoid
encode(T geometry, AttributesImpl atts, GMLWriter handler)
Encodes a geometry valuevoid
encode(T geometry, AttributesImpl atts, GMLWriter handler, String gmlId)
Encodes a geometry value with a given gmlId (implementations might choose to use it to generate gml:id attributes, depending on the GML version.
-
-
-
Method Detail
-
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 toencode(Geometry, AttributesImpl, GMLWriter)
- Parameters:
geometry
- The Geometry to be encodedatts
- Its attributeshandler
- The handler used to write XMLgmlId
- 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 classObjectEncoder<T extends Geometry>
- Parameters:
geometry
- The Geometry to be encodedatts
- Its attributeshandler
- The handler used to write XML- Throws:
Exception
-
-