|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.xml.transform.TransformerBase org.geotools.gml.producer.FeatureTransformer
FeatureTransformer provides a mechanism for converting Feature objects into (hopefully) valid gml. This is a work in progress, so please be patient. A simple example of how to use this class follows:
FeatureCollection collection; // can also use FeatureReader!! OutputStream out; FeatureTransformer ft = new FeatureTransformer(); // set the indentation to 4 spaces ft.setIndentation(4); // this will allow Features with the FeatureType which has the namespace // "http://somewhere.org" to be prefixed with xxx... ft.getFeatureNamespaces().declarePrefix("xxx","http://somewhere.org"); // transform ft.transform(collection,out);The above example assumes a homogenous collection of Features whose FeatureType has the namespace "http://somewhere.org" but note that not all DataSources currently provide FeatureTypes with a namespace... There are two other mechanisms for prefixing your Features.
FeatureType fc; FeatureTransformer ft = new FeatureTransformer(); ft.getFeatureTypeNamespaces().declareNamespace(fc,"xxx","http://somewhere.org");2) Provide a default namespace for any Features whose FeatureType either has an empty namespace, OR, has not been mapped using the previous method. This is basically a catch-all mechanism.
FeatureTransformer ft = new FeatureTransformer(); ft.getFeatureTypeNamespaces().declareDefaultNamespace("xxx","http://somewhere.org");
Nested Class Summary | |
static class |
FeatureTransformer.FeatureTranslator
Outputs gml without any fancy indents or newlines. |
static class |
FeatureTransformer.FeatureTypeNamespaces
|
Nested classes inherited from class org.geotools.xml.transform.TransformerBase |
TransformerBase.SchemaLocationSupport, TransformerBase.Task, TransformerBase.TranslatorSupport, TransformerBase.XMLReaderSupport |
Constructor Summary | |
FeatureTransformer()
|
Method Summary | |
void |
addSchemaLocation(java.lang.String nsURI,
java.lang.String uri)
|
Translator |
createTranslator(org.xml.sax.ContentHandler handler)
Create a Translator to issue SAXEvents to a ContentHandler. |
java.lang.String |
getCollectionNamespace()
|
java.lang.String |
getCollectionPrefix()
|
org.xml.sax.helpers.NamespaceSupport |
getFeatureNamespaces()
|
FeatureTransformer.FeatureTypeNamespaces |
getFeatureTypeNamespaces()
|
void |
setCollectionNamespace(java.lang.String nsURI)
|
void |
setCollectionPrefix(java.lang.String prefix)
|
void |
setFeatureBounding(boolean featureBounding)
Sets whether a gml:boundedBy element should automatically be generated and included. |
void |
setGmlPrefixing(boolean prefixGml)
If Gml Prefixing is enabled then attributes with names that could be prefixed with gml, such as description, pointProperty, and name, will be. |
void |
setLockId(java.lang.String lockId)
Used to set a lockId attribute after a getFeatureWithLock. |
void |
setNumDecimals(int numDecimals)
Sets the number of decimals to be used in the geometry coordinates of the response. |
void |
setSrsName(java.lang.String srsName)
Used to set the srsName attribute of the Geometries to be turned to xml. |
Methods inherited from class org.geotools.xml.transform.TransformerBase |
createTransformer, createTransformTask, createXMLReader, getEncoding, getIndentation, isNamespaceDeclartionEnabled, isOmitXMLDeclaration, setEncoding, setIndentation, setNamespaceDeclarationEnabled, setOmitXMLDeclaration, transform, transform, transform, transform |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FeatureTransformer()
Method Detail |
public void setCollectionNamespace(java.lang.String nsURI)
public java.lang.String getCollectionNamespace()
public void setCollectionPrefix(java.lang.String prefix)
public java.lang.String getCollectionPrefix()
public void setNumDecimals(int numDecimals)
numDecimals
- the number of significant digits past the decimal to
include in the response.public org.xml.sax.helpers.NamespaceSupport getFeatureNamespaces()
public FeatureTransformer.FeatureTypeNamespaces getFeatureTypeNamespaces()
public void addSchemaLocation(java.lang.String nsURI, java.lang.String uri)
public void setSrsName(java.lang.String srsName)
srsName
- DOCUMENT ME!public void setLockId(java.lang.String lockId)
lockId
- The lockId of the lock on the WFS.public void setGmlPrefixing(boolean prefixGml)
prefixGml
- true if prefixing gml should be enabled.
Default is disabled, no gml prefixing.public void setFeatureBounding(boolean featureBounding)
Note that the setGmlPrefixing() interacts with this occasionally, since it will hack in a gml prefix to a boundedBy attribute included in the featureType. If gml prefixing is on, and featureBounding is on, then the bounds from the attribute will be used. If gml prefixing is off, then that boundedBy attribute will presumably be in its own namespace, and so the automatic gml boundedBy will not conflict, so both will be printed, with the automatic one deriving its bounds from the boundedBy attribute and any other geometries in the feature
featureBounding
- true if the bounds of the feature should
be automatically calculated and included as a gml:boundedBy in
the gml output. Note this puts a good bit of bandwidth overhead
on the output. Default is falsepublic Translator createTranslator(org.xml.sax.ContentHandler handler)
TransformerBase
createTranslator
in class TransformerBase
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |