Package org.geotools.xml.transform
Class TransformerBase.TranslatorSupport
- Object
- 
- TranslatorSupport
 
- 
- All Implemented Interfaces:
- Translator
 - Direct Known Subclasses:
- FeatureTransformer.FeatureTranslator,- FeatureTypeTransformer.FeatureTypeTranslator,- FilterTransformer.FilterTranslator,- GeometryTransformer.GeometryTranslator
 - Enclosing class:
- TransformerBase
 
 protected abstract static class TransformerBase.TranslatorSupport extends Object implements Translator Support for writing Translators.
- 
- 
Field SummaryFields Modifier and Type Field Description protected ContentHandlercontentHandlerprotected NamespaceSupportnsSupportprotected AttributesNULL_ATTSprotected booleanrunningSubclasses should check this flag in case an abort message was sent and stop any internal iteration if false.protected TransformerBase.SchemaLocationSupportschemaLocation
 - 
Constructor SummaryConstructors Constructor Description TranslatorSupport(ContentHandler contentHandler, String prefix, String nsURI)TranslatorSupport(ContentHandler contentHandler, String prefix, String nsURI, TransformerBase.SchemaLocationSupport schemaLocation)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()Abort any translating activity.protected voidaddNamespaceDeclarations(TransformerBase.TranslatorSupport trans)Utility method to copy namespace declarations from "sub" translators into this ns support...protected voidcdata(String cdata)protected voidchars(String text)protected voidcomment(String comment)protected voidcommit()Commit pending write operations.protected AttributesImplcreateAttributes(String[] nameValuePairs)Utility method for creating attributes from an array of name value pairs.protected voidelement(String element, String content)protected voidelement(String element, String content, Attributes atts)protected voidelementSafe(String element, String content)Will only issue the provided element if content is non emptyprotected voidend(String element)StringgetDefaultNamespace()Get the default URI used by this Translator for encoding.StringgetDefaultPrefix()Get the default prefix used by this Translator for encoding.NamespaceSupportgetNamespaceSupport()Obtain the namespace prefixes and URIs to be included in the output document.TransformerBase.SchemaLocationSupportgetSchemaLocationSupport()Gets the location of the schemas used in this translator.protected voidmark()Set a mark() to which we can later "roll back" writes.protected voidreset()Discard pending write operations after a mark() has been set.protected voidstart(String element)protected voidstart(String element, Attributes atts)- 
Methods inherited from class Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface Translatorencode
 
- 
 
- 
- 
- 
Field Detail- 
contentHandlerprotected final ContentHandler contentHandler 
 - 
NULL_ATTSprotected final Attributes NULL_ATTS 
 - 
nsSupportprotected NamespaceSupport nsSupport 
 - 
schemaLocationprotected TransformerBase.SchemaLocationSupport schemaLocation 
 - 
runningprotected volatile boolean running Subclasses should check this flag in case an abort message was sent and stop any internal iteration if false.
 
- 
 - 
Constructor Detail- 
TranslatorSupportpublic TranslatorSupport(ContentHandler contentHandler, String prefix, String nsURI) 
 - 
TranslatorSupportpublic TranslatorSupport(ContentHandler contentHandler, String prefix, String nsURI, TransformerBase.SchemaLocationSupport schemaLocation) 
 
- 
 - 
Method Detail- 
abortpublic void abort() Description copied from interface:TranslatorAbort any translating activity. This is needed as some translators iterate internally on a data structure. The abort method should silently fail or succeed based upon the state of a translation.- Specified by:
- abortin interface- Translator
 
 - 
markprotected void mark() Set a mark() to which we can later "roll back" writes. After a call to mark(), the Translator stores pending write operations in memory until commit() is called. The pending writes can be discarded with the reset() method.Typically, one would use marks in conjunction with an exception handler: void encodeFoo(Foo f) { try { mark(); element(foo.riskyMethod()); element(foo.dangerousMethod()); commit(); } catch (BadThingHappened disaster) { mitigate(disaster); reset(); } }- Throws:
- IllegalStateException- if a mark is already set
 
 - 
resetprotected void reset() Discard pending write operations after a mark() has been set.This method is safe to call even if no mark is set - so it returns to a "known good" state as far as marks are concerned. - See Also:
- mark()
 
 - 
commitprotected void commit() Commit pending write operations. After setting a mark, this method will commit the pending writes.- Throws:
- IllegalStateException- if no mark is set
- See Also:
- mark()
 
 - 
addNamespaceDeclarationsprotected void addNamespaceDeclarations(TransformerBase.TranslatorSupport trans) Utility method to copy namespace declarations from "sub" translators into this ns support...
 - 
createAttributesprotected AttributesImpl createAttributes(String[] nameValuePairs) Utility method for creating attributes from an array of name value pairs.The nameValuePairs array should be of the form: {name1,value1,name2,value2,...,nameN,valueN}- Parameters:
- nameValuePairs- The attribute names/values.
 
 - 
elementSafeprotected void elementSafe(String element, String content) Will only issue the provided element if content is non empty
 - 
elementprotected void element(String element, String content, Attributes atts) 
 - 
startprotected void start(String element) 
 - 
startprotected void start(String element, Attributes atts) 
 - 
charsprotected void chars(String text) 
 - 
endprotected void end(String element) 
 - 
cdataprotected void cdata(String cdata) 
 - 
commentprotected void comment(String comment) 
 - 
getDefaultNamespacepublic String getDefaultNamespace() Description copied from interface:TranslatorGet the default URI used by this Translator for encoding. Optional.- Specified by:
- getDefaultNamespacein interface- Translator
 
 - 
getDefaultPrefixpublic String getDefaultPrefix() Description copied from interface:TranslatorGet the default prefix used by this Translator for encoding. Optional.- Specified by:
- getDefaultPrefixin interface- Translator
 
 - 
getNamespaceSupportpublic NamespaceSupport getNamespaceSupport() Description copied from interface:TranslatorObtain the namespace prefixes and URIs to be included in the output document.- Specified by:
- getNamespaceSupportin interface- Translator
- Returns:
- An instance of NamespaceSupport.
 
 - 
getSchemaLocationSupportpublic TransformerBase.SchemaLocationSupport getSchemaLocationSupport() Description copied from interface:TranslatorGets the location of the schemas used in this translator. Optional.- Specified by:
- getSchemaLocationSupportin interface- Translator
 
 
- 
 
-