|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavanet.staxutils.BaseXMLEventWriter
public abstract class BaseXMLEventWriter
Base class for XMLEventWriter
implementations. This implemenation
buffers Attribute and Namespace events as specified in the specification,
maintains a stack of NamespaceContext instances based on the events it
receives, and repairs any missing namespaces. Subclasses should implement the
sendEvent(XMLEvent)
method to receive the processed events and
perform additional processing.
Field Summary | |
---|---|
protected java.util.Map |
attrBuff
LinkedHashMap of attribute events sent surrounding the last StartElement. |
protected boolean |
closed
Whether this writer has been closed or not. |
protected XMLEventFactory |
factory
XMLEventFactory used to construct XMLEvent instances. |
protected StartElement |
lastStart
Reference to the last StartElement sent. |
protected java.util.Map |
nsBuff
LinkedHashMap of namespace events sent surrounding the last StartElement. |
protected java.util.List |
nsStack
list of SimpleNamespaceContext s. |
Constructor Summary | |
---|---|
protected |
BaseXMLEventWriter()
|
protected |
BaseXMLEventWriter(XMLEventFactory eventFactory,
NamespaceContext nsCtx)
|
Method Summary | |
---|---|
void |
add(XMLEvent event)
|
void |
add(XMLEventReader reader)
|
protected void |
cacheAttribute(Attribute attr)
Adds the specified Attribute to the attribute cache. |
protected void |
cacheNamespace(Namespace ns)
Adds the provided Namespace event to the namespace cache. |
void |
close()
|
void |
flush()
|
NamespaceContext |
getNamespaceContext()
|
java.lang.String |
getPrefix(java.lang.String nsURI)
|
protected SimpleNamespaceContext |
peekNamespaceStack()
Returns the active SimpleNamespaceContext from the top of the
stack. |
protected SimpleNamespaceContext |
popNamespaceStack()
Removes the active SimpleNamespaceContext from the top of the
stack. |
protected SimpleNamespaceContext |
pushNamespaceStack()
Creates a new SimpleNamespaceContext and adds it to the top of
the stack. |
protected abstract void |
sendEvent(XMLEvent event)
Called by the methods of this class to write the event to the stream. |
void |
setDefaultNamespace(java.lang.String nsURI)
|
void |
setNamespaceContext(NamespaceContext root)
|
void |
setPrefix(java.lang.String prefix,
java.lang.String nsURI)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected XMLEventFactory factory
protected java.util.List nsStack
SimpleNamespaceContext
s.
protected StartElement lastStart
protected java.util.Map attrBuff
protected java.util.Map nsBuff
protected boolean closed
Constructor Detail |
---|
protected BaseXMLEventWriter()
protected BaseXMLEventWriter(XMLEventFactory eventFactory, NamespaceContext nsCtx)
Method Detail |
---|
public void flush() throws XMLStreamException
flush
in interface XMLEventWriter
XMLStreamException
public void close() throws XMLStreamException
close
in interface XMLEventWriter
XMLStreamException
public void add(XMLEvent event) throws XMLStreamException
add
in interface XMLEventConsumer
add
in interface XMLEventWriter
XMLStreamException
public void add(XMLEventReader reader) throws XMLStreamException
add
in interface XMLEventWriter
XMLStreamException
public java.lang.String getPrefix(java.lang.String nsURI) throws XMLStreamException
getPrefix
in interface XMLEventWriter
XMLStreamException
public void setPrefix(java.lang.String prefix, java.lang.String nsURI) throws XMLStreamException
setPrefix
in interface XMLEventWriter
XMLStreamException
public void setDefaultNamespace(java.lang.String nsURI) throws XMLStreamException
setDefaultNamespace
in interface XMLEventWriter
XMLStreamException
public void setNamespaceContext(NamespaceContext root) throws XMLStreamException
setNamespaceContext
in interface XMLEventWriter
XMLStreamException
public NamespaceContext getNamespaceContext()
getNamespaceContext
in interface XMLEventWriter
protected SimpleNamespaceContext popNamespaceStack()
SimpleNamespaceContext
from the top of the
stack.
SimpleNamespaceContext
removed from the namespace
stack.protected SimpleNamespaceContext peekNamespaceStack()
SimpleNamespaceContext
from the top of the
stack.
SimpleNamespaceContext
from the top of the
stack.protected SimpleNamespaceContext pushNamespaceStack()
SimpleNamespaceContext
and adds it to the top of
the stack.
SimpleNamespaceContext
.protected void cacheAttribute(Attribute attr)
Attribute
to the attribute cache.
attr
- The attribute to cache.protected void cacheNamespace(Namespace ns)
Namespace
event to the namespace cache. The
current namespace context will not be affected.
ns
- The namespace to add to the cache.protected abstract void sendEvent(XMLEvent event) throws XMLStreamException
event
- The event to write.
XMLStreamException
- If an error occurs processing the event.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |