org.apache.axiom.om.impl.util
Class OMSerializerUtil

java.lang.Object
  extended by org.apache.axiom.om.impl.util.OMSerializerUtil

public class OMSerializerUtil
extends java.lang.Object


Field Summary
private static boolean ADV_DEBUG_ENABLED
           
private static boolean DEBUG_ENABLED
           
private static java.lang.String IS_SET_PREFIX_BEFORE_PROPERTY
           
private static org.apache.commons.logging.Log log
           
(package private) static long nsCounter
           
 
Constructor Summary
OMSerializerUtil()
           
 
Method Summary
private static boolean checkForPrefixInTheCurrentContext(javax.xml.stream.XMLStreamWriter writer, java.lang.String nameSpaceName, java.lang.String prefix)
           
static java.lang.String generateSetPrefix(java.lang.String prefix, java.lang.String namespace, javax.xml.stream.XMLStreamWriter writer, boolean attr, boolean isSetPrefixFirst)
          Generate setPrefix/setDefaultNamespace if the prefix is not associated
static java.lang.String getNextNSPrefix()
          Get the next prefix name
static java.lang.String getNextNSPrefix(javax.xml.stream.XMLStreamWriter writer)
           
static boolean isAssociated(java.lang.String prefix, java.lang.String namespace, javax.xml.stream.XMLStreamWriter writer)
           
static boolean isSetPrefixBeforeStartElement(javax.xml.stream.XMLStreamWriter writer)
          Unfortunately there is disagreement in the user community about the semantics of setPrefix on the XMLStreamWriter.
static void serializeAttribute(OMAttribute attr, javax.xml.stream.XMLStreamWriter writer)
          Deprecated. use serializeStartpart instead
static void serializeAttributes(OMElement element, javax.xml.stream.XMLStreamWriter writer)
          Deprecated. Consider using serializeStartpart instead
static void serializeByPullStream(OMElement element, javax.xml.stream.XMLStreamWriter writer)
           
static void serializeByPullStream(OMElement element, javax.xml.stream.XMLStreamWriter writer, boolean cache)
           
static void serializeEndpart(javax.xml.stream.XMLStreamWriter writer)
          Method serializeEndpart.
static void serializeNamespace(OMNamespace namespace, javax.xml.stream.XMLStreamWriter writer)
          Deprecated. Use serializeStartpart instead
static void serializeNamespaces(OMElement element, javax.xml.stream.XMLStreamWriter writer)
          Deprecated. Use serializeStartpart instead
static void serializeNormal(OMElement element, javax.xml.stream.XMLStreamWriter writer, boolean cache)
          Method serializeNormal.
static void serializeStartpart(OMElement element, java.lang.String localName, javax.xml.stream.XMLStreamWriter writer)
          Method serializeStartpart.
static void serializeStartpart(OMElement element, javax.xml.stream.XMLStreamWriter writer)
          Method serializeStartpart.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

DEBUG_ENABLED

private static boolean DEBUG_ENABLED

ADV_DEBUG_ENABLED

private static boolean ADV_DEBUG_ENABLED

nsCounter

static long nsCounter

IS_SET_PREFIX_BEFORE_PROPERTY

private static final java.lang.String IS_SET_PREFIX_BEFORE_PROPERTY
See Also:
Constant Field Values
Constructor Detail

OMSerializerUtil

public OMSerializerUtil()
Method Detail

serializeEndpart

public static void serializeEndpart(javax.xml.stream.XMLStreamWriter writer)
                             throws javax.xml.stream.XMLStreamException
Method serializeEndpart.

Parameters:
writer -
Throws:
javax.xml.stream.XMLStreamException

serializeAttribute

public static void serializeAttribute(OMAttribute attr,
                                      javax.xml.stream.XMLStreamWriter writer)
                               throws javax.xml.stream.XMLStreamException
Deprecated. use serializeStartpart instead

Method serializeAttribute.

Parameters:
attr -
writer -
Throws:
javax.xml.stream.XMLStreamException

serializeNamespace

public static void serializeNamespace(OMNamespace namespace,
                                      javax.xml.stream.XMLStreamWriter writer)
                               throws javax.xml.stream.XMLStreamException
Deprecated. Use serializeStartpart instead

Method serializeNamespace.

Parameters:
namespace -
writer -
Throws:
javax.xml.stream.XMLStreamException

isSetPrefixBeforeStartElement

public static boolean isSetPrefixBeforeStartElement(javax.xml.stream.XMLStreamWriter writer)
Unfortunately there is disagreement in the user community about the semantics of setPrefix on the XMLStreamWriter. An example will explain the difference: writer.startElement("a") writer.setPrefix("pre", "urn://sample") writer.startElement("b")

Some user communities (woodstox) believe that the setPrefix is associate with the scope for "a" and thus remains in scope until the end of a. The basis for this believe is XMLStreamWriter javadoc (which some would argue is incomplete).

Some user communities believe that the setPrefix is associated with the "b" element. These communities reference an example in the specification and historical usage of SAX.

This method will return true if the setPrefix is associated with the next writeStartElement.

Parameters:
writer -
Returns:
true if setPrefix should be generated before startElement

serializeStartpart

public static void serializeStartpart(OMElement element,
                                      javax.xml.stream.XMLStreamWriter writer)
                               throws javax.xml.stream.XMLStreamException
Method serializeStartpart. Serialize the start tag of an element.

Parameters:
element -
writer -
Throws:
javax.xml.stream.XMLStreamException

serializeStartpart

public static void serializeStartpart(OMElement element,
                                      java.lang.String localName,
                                      javax.xml.stream.XMLStreamWriter writer)
                               throws javax.xml.stream.XMLStreamException
Method serializeStartpart. Serialize the start tag of an element.

Parameters:
element -
localName - (in some cases, the caller wants to force a different localName)
writer -
Throws:
javax.xml.stream.XMLStreamException

checkForPrefixInTheCurrentContext

private static boolean checkForPrefixInTheCurrentContext(javax.xml.stream.XMLStreamWriter writer,
                                                         java.lang.String nameSpaceName,
                                                         java.lang.String prefix)
                                                  throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

serializeNamespaces

public static void serializeNamespaces(OMElement element,
                                       javax.xml.stream.XMLStreamWriter writer)
                                throws javax.xml.stream.XMLStreamException
Deprecated. Use serializeStartpart instead

serializeNamespaces

Parameters:
element -
writer -
Throws:
javax.xml.stream.XMLStreamException

serializeAttributes

public static void serializeAttributes(OMElement element,
                                       javax.xml.stream.XMLStreamWriter writer)
                                throws javax.xml.stream.XMLStreamException
Deprecated. Consider using serializeStartpart instead

Serialize attributes

Parameters:
element -
writer -
Throws:
javax.xml.stream.XMLStreamException

serializeNormal

public static void serializeNormal(OMElement element,
                                   javax.xml.stream.XMLStreamWriter writer,
                                   boolean cache)
                            throws javax.xml.stream.XMLStreamException
Method serializeNormal.

Parameters:
writer -
cache -
Throws:
javax.xml.stream.XMLStreamException

serializeByPullStream

public static void serializeByPullStream(OMElement element,
                                         javax.xml.stream.XMLStreamWriter writer)
                                  throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

serializeByPullStream

public static void serializeByPullStream(OMElement element,
                                         javax.xml.stream.XMLStreamWriter writer,
                                         boolean cache)
                                  throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

getNextNSPrefix

public static java.lang.String getNextNSPrefix()
Get the next prefix name

Returns:
next prefix name

getNextNSPrefix

public static java.lang.String getNextNSPrefix(javax.xml.stream.XMLStreamWriter writer)

generateSetPrefix

public static java.lang.String generateSetPrefix(java.lang.String prefix,
                                                 java.lang.String namespace,
                                                 javax.xml.stream.XMLStreamWriter writer,
                                                 boolean attr,
                                                 boolean isSetPrefixFirst)
                                          throws javax.xml.stream.XMLStreamException
Generate setPrefix/setDefaultNamespace if the prefix is not associated

Parameters:
prefix -
namespace -
writer -
attr -
Returns:
prefix name if a setPrefix/setDefaultNamespace is performed
Throws:
javax.xml.stream.XMLStreamException

isAssociated

public static boolean isAssociated(java.lang.String prefix,
                                   java.lang.String namespace,
                                   javax.xml.stream.XMLStreamWriter writer)
                            throws javax.xml.stream.XMLStreamException
Parameters:
prefix -
namespace -
writer -
Returns:
true if the prefix is associated with the namespace in the current context
Throws:
javax.xml.stream.XMLStreamException