com.openharbor.beck.write
Class TentativeXMLWriter
java.lang.Object
java.io.Writer
com.openharbor.beck.write.XMLWriter
com.openharbor.beck.write.TentativeXMLWriter
- public class TentativeXMLWriter
- extends XMLWriter
Optimizes empty elements out of a generated XML document.
startElement events are held in a write-behind buffer.
The buffer is flushed to a nested XMLWriter whenever text,
an attribute or an ordinary element is written.
But if no such event occurs before a matching endElement,
the startElement/endElement pair are simply discarded.
Fields inherited from class java.io.Writer |
lock |
Methods inherited from class java.io.Writer |
write, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TENTATIVE
protected static final XMLWriter.MapKey TENTATIVE
out
protected XMLWriter out
decorate
public static TentativeXMLWriter decorate(XMLWriter out)
throws java.io.IOException
- Throws:
java.io.IOException
getElementStackTop
public java.util.HashMap getElementStackTop()
- Overrides:
getElementStackTop
in class XMLWriter
- Returns:
- the HashMap at the top of the element stack, or null if the stack is empty.
startElementTentatively
public void startElementTentatively(XMLThing tag)
throws java.io.IOException
- Throws:
java.io.IOException
endElement
public void endElement()
throws java.io.IOException
- Overrides:
endElement
in class XMLWriter
- Throws:
java.io.IOException
startElement
public void startElement(XMLThing tag)
throws java.io.IOException
- Overrides:
startElement
in class XMLWriter
- Throws:
java.io.IOException
namespace
public java.lang.String namespace(java.lang.String uri)
throws java.io.IOException
- Description copied from class:
XMLWriter
- Add a namespace declaration to the current element.
- Overrides:
namespace
in class XMLWriter
- Returns:
- the prefix assigned to the given uri.
- Throws:
java.io.IOException
- if text or sub-elements have already been written in this element.
namespace
public java.lang.String namespace(java.lang.String prefix,
java.lang.String uri)
throws java.io.IOException
- Description copied from class:
XMLWriter
- Add a namespace declaration to the current element.
The given prefix will be used unless it's null or conflicts with a previous request;
in which case another prefix will be used.
- Overrides:
namespace
in class XMLWriter
- Returns:
- the prefix assigned to the given uri.
- Throws:
java.io.IOException
- if text or sub-elements have already been written in this element.
declareNamespace
protected void declareNamespace(java.lang.String prefix,
java.lang.String namespaceURI)
throws java.io.IOException
- Specified by:
declareNamespace
in class XMLWriter
- Throws:
java.io.IOException
prefixToNamespace
protected java.lang.String prefixToNamespace(java.lang.String prefix)
throws UnknownNamespaceException
- Description copied from class:
XMLWriter
- Find the namespace URI for a given XML name prefix.
- Overrides:
prefixToNamespace
in class XMLWriter
- Throws:
UnknownNamespaceException
attribute
public void attribute(XMLName name,
java.lang.String value)
throws java.io.IOException
- Description copied from class:
XMLWriter
- Add an attribute to the current element.
If it's an xsi:type attribute, set the Type of the current element accordingly.
- Overrides:
attribute
in class XMLWriter
- Throws:
java.io.IOException
- if text or sub-elements have already been written in this element.
write
public void write(java.lang.String content)
throws java.io.IOException
- Overrides:
write
in class XMLWriter
- Throws:
java.io.IOException
write
public void write(java.lang.String content,
int off,
int len)
throws java.io.IOException
- Overrides:
write
in class XMLWriter
- Throws:
java.io.IOException
write
public void write(char[] content,
int off,
int len)
throws java.io.IOException
- Description copied from class:
XMLWriter
- Add text content to the current element.
Do nothing if len <= 0.
- Specified by:
write
in class XMLWriter
- Throws:
java.io.IOException
flush
public void flush()
throws java.io.IOException
- Throws:
java.io.IOException
close
public void close()
throws java.io.IOException
- Throws:
java.io.IOException