microsoft.exchange.webservices.data.core
Class EwsServiceXmlWriter

java.lang.Object
  extended by microsoft.exchange.webservices.data.core.EwsServiceXmlWriter
All Implemented Interfaces:
IDisposable

public class EwsServiceXmlWriter
extends Object
implements IDisposable

Stax based XML Writer implementation.


Field Summary
protected  boolean requireWSSecurityUtilityNamespace
          The requireWSSecurityUtilityNamespace *
 
Constructor Summary
EwsServiceXmlWriter(ExchangeServiceBase service, OutputStream stream)
          Initializes a new instance.
 
Method Summary
static void addElement(Element element, XMLStreamWriter writer)
           
 void dispose()
          Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 void flush()
          Flushes this instance.
 XMLStreamWriter getInternalWriter()
          Gets the internal XML writer.
 ExchangeServiceBase getService()
          Gets the service.
 boolean isRequireWSSecurityUtilityNamespace()
          Gets a value indicating whether the SOAP message need WSSecurity Utility namespace.
 boolean isTimeZoneHeaderEmitted()
          Gets a value indicating whether the time zone SOAP header was emitted through this writer.
 void setRequireWSSecurityUtilityNamespace(boolean requireWSSecurityUtilityNamespace)
          Sets a value indicating whether the SOAP message need WSSecurity Utility namespace.
 void setTimeZoneHeaderEmitted(boolean isTimeZoneHeaderEmitted)
          Sets a value indicating whether the time zone SOAP header was emitted through this writer.
protected  boolean tryConvertObjectToString(Object value, OutParam<String> str)
          Try to convert object to a string.
protected  void writeAttributeString(String localName, String stringValue)
          Writes the attribute value.
protected  void writeAttributeString(String namespacePrefix, String localName, String stringValue)
          Writes the attribute value.
 void writeAttributeValue(String localName, boolean alwaysWriteEmptyString, Object value)
          Writes the attribute value.
 void writeAttributeValue(String localName, Object value)
          Writes the attribute value.
 void writeAttributeValue(String namespacePrefix, String localName, Object value)
          Writes the attribute value.
 void writeBase64ElementValue(byte[] buffer)
          Writes the base64-encoded element value.
 void writeBase64ElementValue(InputStream stream)
          Writes the base64-encoded element value.
 void writeElementValue(XmlNamespace xmlNamespace, String localName, Object value)
          Writes the element value.
 void writeElementValue(XmlNamespace xmlNamespace, String localName, String displayName, Object value)
          Writes the element value.
 void writeEndElement()
          Writes the end element.
 void writeNode(Node xmlNode)
           
static void writeNode(Node xmlNode, XMLStreamWriter xmlStreamWriter)
           
 void writeStartDocument()
          Write start document.
 void writeStartElement(XmlNamespace xmlNamespace, String localName)
          Writes the start element.
static void writeToDocument(Document document, XMLStreamWriter xmlStreamWriter)
           
 void writeValue(String value, String name)
          Writes string value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requireWSSecurityUtilityNamespace

protected boolean requireWSSecurityUtilityNamespace
The requireWSSecurityUtilityNamespace *

Constructor Detail

EwsServiceXmlWriter

public EwsServiceXmlWriter(ExchangeServiceBase service,
                           OutputStream stream)
                    throws XMLStreamException
Initializes a new instance.

Parameters:
service - the service
stream - the stream
Throws:
XMLStreamException - the XML stream exception
Method Detail

tryConvertObjectToString

protected boolean tryConvertObjectToString(Object value,
                                           OutParam<String> str)
Try to convert object to a string.

Parameters:
value - The value.
str - the str
Returns:
True if object was converted, false otherwise. A null object will be "successfully" converted to a null string.

dispose

public void dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Specified by:
dispose in interface IDisposable

flush

public void flush()
           throws XMLStreamException
Flushes this instance.

Throws:
XMLStreamException - the XML stream exception

writeStartElement

public void writeStartElement(XmlNamespace xmlNamespace,
                              String localName)
                       throws XMLStreamException
Writes the start element.

Parameters:
xmlNamespace - the XML namespace
localName - the local name of the element
Throws:
XMLStreamException - the XML stream exception

writeEndElement

public void writeEndElement()
                     throws XMLStreamException
Writes the end element.

Throws:
XMLStreamException - the XML stream exception

writeAttributeValue

public void writeAttributeValue(String localName,
                                Object value)
                         throws ServiceXmlSerializationException
Writes the attribute value.

Parameters:
localName - the local name of the attribute
value - the value
Throws:
ServiceXmlSerializationException - the service xml serialization exception

writeAttributeValue

public void writeAttributeValue(String localName,
                                boolean alwaysWriteEmptyString,
                                Object value)
                         throws ServiceXmlSerializationException
Writes the attribute value. Optionally emits empty string values.

Parameters:
localName - the local name of the attribute.
alwaysWriteEmptyString - always emit the empty string as the value.
value - the value
Throws:
ServiceXmlSerializationException - the service xml serialization exception

writeAttributeValue

public void writeAttributeValue(String namespacePrefix,
                                String localName,
                                Object value)
                         throws ServiceXmlSerializationException
Writes the attribute value.

Parameters:
namespacePrefix - the namespace prefix
localName - the local name of the attribute
value - the value
Throws:
ServiceXmlSerializationException - the service xml serialization exception

writeAttributeString

protected void writeAttributeString(String localName,
                                    String stringValue)
                             throws ServiceXmlSerializationException
Writes the attribute value.

Parameters:
localName - The local name of the attribute.
stringValue - The string value.
Throws:
ServiceXmlSerializationException - Thrown if string value isn't valid for XML

writeAttributeString

protected void writeAttributeString(String namespacePrefix,
                                    String localName,
                                    String stringValue)
                             throws ServiceXmlSerializationException
Writes the attribute value.

Parameters:
namespacePrefix - The namespace prefix.
localName - The local name of the attribute.
stringValue - The string value.
Throws:
ServiceXmlSerializationException - Thrown if string value isn't valid for XML.

writeValue

public void writeValue(String value,
                       String name)
                throws ServiceXmlSerializationException
Writes string value.

Parameters:
value - The value.
name - Element name (used for error handling)
Throws:
ServiceXmlSerializationException - Thrown if string value isn't valid for XML.

writeElementValue

public void writeElementValue(XmlNamespace xmlNamespace,
                              String localName,
                              String displayName,
                              Object value)
                       throws XMLStreamException,
                              ServiceXmlSerializationException
Writes the element value.

Parameters:
xmlNamespace - the XML namespace
localName - the local name of the element
displayName - the name that should appear in the exception message when the value can not be serialized
value - the value
Throws:
XMLStreamException - the XML stream exception
ServiceXmlSerializationException - the service xml serialization exception

writeNode

public void writeNode(Node xmlNode)
               throws XMLStreamException
Throws:
XMLStreamException

writeNode

public static void writeNode(Node xmlNode,
                             XMLStreamWriter xmlStreamWriter)
                      throws XMLStreamException
Parameters:
xmlNode - XML node
xmlStreamWriter - XML stream writer
Throws:
XMLStreamException - the XML stream exception

writeToDocument

public static void writeToDocument(Document document,
                                   XMLStreamWriter xmlStreamWriter)
                            throws XMLStreamException
Parameters:
document - XML document
xmlStreamWriter - XML stream writer
Throws:
XMLStreamException - the XML stream exception

addElement

public static void addElement(Element element,
                              XMLStreamWriter writer)
                       throws XMLStreamException
Parameters:
element - DOM element
writer - XML stream writer
Throws:
XMLStreamException - the XML stream exception

writeElementValue

public void writeElementValue(XmlNamespace xmlNamespace,
                              String localName,
                              Object value)
                       throws XMLStreamException,
                              ServiceXmlSerializationException
Writes the element value.

Parameters:
xmlNamespace - the XML namespace
localName - the local name of the element
value - the value
Throws:
XMLStreamException - the XML stream exception
ServiceXmlSerializationException - the service xml serialization exception

writeBase64ElementValue

public void writeBase64ElementValue(byte[] buffer)
                             throws XMLStreamException
Writes the base64-encoded element value.

Parameters:
buffer - the buffer
Throws:
XMLStreamException - the XML stream exception

writeBase64ElementValue

public void writeBase64ElementValue(InputStream stream)
                             throws IOException,
                                    XMLStreamException
Writes the base64-encoded element value.

Parameters:
stream - the stream
Throws:
IOException - signals that an I/O exception has occurred
XMLStreamException - the XML stream exception

getInternalWriter

public XMLStreamWriter getInternalWriter()
Gets the internal XML writer.

Returns:
the internal writer

getService

public ExchangeServiceBase getService()
Gets the service.

Returns:
The service.

isRequireWSSecurityUtilityNamespace

public boolean isRequireWSSecurityUtilityNamespace()
Gets a value indicating whether the SOAP message need WSSecurity Utility namespace.


setRequireWSSecurityUtilityNamespace

public void setRequireWSSecurityUtilityNamespace(boolean requireWSSecurityUtilityNamespace)
Sets a value indicating whether the SOAP message need WSSecurity Utility namespace.


isTimeZoneHeaderEmitted

public boolean isTimeZoneHeaderEmitted()
Gets a value indicating whether the time zone SOAP header was emitted through this writer.

Returns:
true if the time zone SOAP header was emitted; otherwise false.

setTimeZoneHeaderEmitted

public void setTimeZoneHeaderEmitted(boolean isTimeZoneHeaderEmitted)
Sets a value indicating whether the time zone SOAP header was emitted through this writer.

Parameters:
isTimeZoneHeaderEmitted - true if the time zone SOAP header was emitted; otherwise false.

writeStartDocument

public void writeStartDocument()
                        throws XMLStreamException
Write start document.

Throws:
XMLStreamException - the XML stream exception


Copyright © 2012–2015 Microsoft. All rights reserved.