protected abstract static class TransformerBase.TranslatorSupport extends Object implements Translator
Modifier and Type | Field and Description |
---|---|
protected ContentHandler |
contentHandler |
protected NamespaceSupport |
nsSupport |
protected Attributes |
NULL_ATTS |
protected boolean |
running
Subclasses should check this flag in case an abort message was sent and stop any internal
iteration if false.
|
protected TransformerBase.SchemaLocationSupport |
schemaLocation |
Constructor and Description |
---|
TranslatorSupport(ContentHandler contentHandler,
String prefix,
String nsURI) |
TranslatorSupport(ContentHandler contentHandler,
String prefix,
String nsURI,
TransformerBase.SchemaLocationSupport schemaLocation) |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort any translating activity.
|
protected void |
addNamespaceDeclarations(TransformerBase.TranslatorSupport trans)
Utility method to copy namespace declarations from "sub" translators into this ns
support...
|
protected void |
cdata(String cdata) |
protected void |
chars(String text) |
protected void |
comment(String comment) |
protected void |
commit()
Commit pending write operations.
|
protected AttributesImpl |
createAttributes(String[] nameValuePairs)
Utility method for creating attributes from an array of name value pairs.
|
protected void |
element(String element,
String content) |
protected void |
element(String element,
String content,
Attributes atts) |
protected void |
elementSafe(String element,
String content)
Will only issue the provided element if content is non empty
|
protected void |
end(String element) |
String |
getDefaultNamespace()
Get the default URI used by this Translator for encoding.
|
String |
getDefaultPrefix()
Get the default prefix used by this Translator for encoding.
|
NamespaceSupport |
getNamespaceSupport()
Obtain the namespace prefixes and URIs to be included in the output document.
|
TransformerBase.SchemaLocationSupport |
getSchemaLocationSupport()
Gets the location of the schemas used in this translator.
|
protected void |
mark()
Set a mark() to which we can later "roll back" writes.
|
protected void |
reset()
Discard pending write operations after a mark() has been set.
|
protected void |
start(String element) |
protected void |
start(String element,
Attributes atts) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
encode
protected final ContentHandler contentHandler
protected final Attributes NULL_ATTS
protected NamespaceSupport nsSupport
protected TransformerBase.SchemaLocationSupport schemaLocation
protected volatile boolean running
public TranslatorSupport(ContentHandler contentHandler, String prefix, String nsURI)
public TranslatorSupport(ContentHandler contentHandler, String prefix, String nsURI, TransformerBase.SchemaLocationSupport schemaLocation)
public void abort()
Translator
abort
in interface Translator
protected void mark()
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(); } }
IllegalStateException
- if a mark is already setprotected void reset()
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.
mark()
protected void commit()
IllegalStateException
- if no mark is setmark()
protected void addNamespaceDeclarations(TransformerBase.TranslatorSupport trans)
protected AttributesImpl createAttributes(String[] nameValuePairs)
The nameValuePairs array should be of the form:
{name1,value1,name2,value2,...,nameN,valueN}
nameValuePairs
- The attribute names/values.protected void elementSafe(String element, String content)
element
- content
- protected void element(String element, String content, Attributes atts)
protected void start(String element)
protected void start(String element, Attributes atts)
protected void chars(String text)
protected void end(String element)
protected void cdata(String cdata)
protected void comment(String comment)
public String getDefaultNamespace()
Translator
getDefaultNamespace
in interface Translator
public String getDefaultPrefix()
Translator
getDefaultPrefix
in interface Translator
public NamespaceSupport getNamespaceSupport()
Translator
getNamespaceSupport
in interface Translator
public TransformerBase.SchemaLocationSupport getSchemaLocationSupport()
Translator
getSchemaLocationSupport
in interface Translator
Copyright © 1996–2019 Geotools. All rights reserved.