com.caucho.xml.stream
Class StaxUtil

java.lang.Object
  extended by com.caucho.xml.stream.StaxUtil

public class StaxUtil
extends java.lang.Object

Utility class to do namespace repairs on XMLStreamWriters that don't have repair enabled. Used by JAXB.


Field Summary
static L10N L
           
 
Constructor Summary
StaxUtil()
           
 
Method Summary
static java.lang.String constantToString(int constant)
           
static void copyReaderToWriter(XMLStreamReader in, XMLStreamWriter out)
          Copys all the events from the input to the output, without going past an unmatch end element.
static java.lang.String getNamespacePrefix(XMLStreamWriter out, java.lang.String namespace)
          Ensures that a given namespace exists within the namespace context given and returns the prefix.
static java.lang.String printStreamState(XMLStreamReader in)
           
static java.lang.String qnameToString(XMLStreamWriter out, javax.xml.namespace.QName qname)
          Converts a QName to a String using the context of a XMLStreamWriter.
static void repairNamespace(XMLStreamWriter out, java.lang.String namespace)
          Ensures that a given namespace exists within the namespace context given.
static void repairNamespace(XMLStreamWriter out, java.lang.String prefix, java.lang.String namespace)
          Ensures that a given prefix->namespace mapping exists within the namespace context given.
static javax.xml.namespace.QName resolveStringToQName(java.lang.String string, javax.xml.namespace.NamespaceContext context)
           
static javax.xml.namespace.QName resolveStringToQName(java.lang.String string, XMLStreamReader in)
           
static XMLStreamWriter toRepairingXMLStreamWriter(XMLStreamWriter out)
           
static void writeAttribute(XMLStreamWriter out, javax.xml.namespace.QName name, java.lang.String value)
           
static void writeEndElement(XMLStreamWriter out, javax.xml.namespace.QName name)
           
static void writeStartElement(XMLStreamWriter out, javax.xml.namespace.QName name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

L

public static final L10N L
Constructor Detail

StaxUtil

public StaxUtil()
Method Detail

resolveStringToQName

public static javax.xml.namespace.QName resolveStringToQName(java.lang.String string,
                                                             XMLStreamReader in)
                                                      throws XMLStreamException
Throws:
XMLStreamException

resolveStringToQName

public static javax.xml.namespace.QName resolveStringToQName(java.lang.String string,
                                                             javax.xml.namespace.NamespaceContext context)
                                                      throws XMLStreamException
Throws:
XMLStreamException

repairNamespace

public static void repairNamespace(XMLStreamWriter out,
                                   java.lang.String namespace)
                            throws XMLStreamException
Ensures that a given namespace exists within the namespace context given.

Throws:
XMLStreamException

getNamespacePrefix

public static java.lang.String getNamespacePrefix(XMLStreamWriter out,
                                                  java.lang.String namespace)
                                           throws XMLStreamException
Ensures that a given namespace exists within the namespace context given and returns the prefix.

Throws:
XMLStreamException

repairNamespace

public static void repairNamespace(XMLStreamWriter out,
                                   java.lang.String prefix,
                                   java.lang.String namespace)
                            throws XMLStreamException
Ensures that a given prefix->namespace mapping exists within the namespace context given.

Throws:
XMLStreamException

toRepairingXMLStreamWriter

public static XMLStreamWriter toRepairingXMLStreamWriter(XMLStreamWriter out)

copyReaderToWriter

public static void copyReaderToWriter(XMLStreamReader in,
                                      XMLStreamWriter out)
                               throws XMLStreamException
Copys all the events from the input to the output, without going past an unmatch end element. E.g.: if the input is at the start of , it will only read just past

Throws:
XMLStreamException

constantToString

public static java.lang.String constantToString(int constant)
                                         throws XMLStreamException
Throws:
XMLStreamException

printStreamState

public static java.lang.String printStreamState(XMLStreamReader in)
                                         throws XMLStreamException
Throws:
XMLStreamException

qnameToString

public static java.lang.String qnameToString(XMLStreamWriter out,
                                             javax.xml.namespace.QName qname)
                                      throws XMLStreamException
Converts a QName to a String using the context of a XMLStreamWriter. Intended for writing QNames as attributes or text in a XMLStreamWriter that's passed in.

Throws:
XMLStreamException

writeStartElement

public static void writeStartElement(XMLStreamWriter out,
                                     javax.xml.namespace.QName name)
                              throws XMLStreamException
Throws:
XMLStreamException

writeEndElement

public static void writeEndElement(XMLStreamWriter out,
                                   javax.xml.namespace.QName name)
                            throws XMLStreamException
Throws:
XMLStreamException

writeAttribute

public static void writeAttribute(XMLStreamWriter out,
                                  javax.xml.namespace.QName name,
                                  java.lang.String value)
                           throws XMLStreamException
Throws:
XMLStreamException