Class EwsServiceXmlWriter
- java.lang.Object
-
- microsoft.exchange.webservices.data.core.EwsServiceXmlWriter
-
- All Implemented Interfaces:
IDisposable
public class EwsServiceXmlWriter extends Object implements IDisposable
Stax based XML Writer implementation.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanrequireWSSecurityUtilityNamespaceThe requireWSSecurityUtilityNamespace *
-
Constructor Summary
Constructors Constructor Description EwsServiceXmlWriter(ExchangeServiceBase service, OutputStream stream)Initializes a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddElement(Element element, XMLStreamWriter writer)voiddispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.voidflush()Flushes this instance.XMLStreamWritergetInternalWriter()Gets the internal XML writer.ExchangeServiceBasegetService()Gets the service.booleanisRequireWSSecurityUtilityNamespace()Gets a value indicating whether the SOAP message need WSSecurity Utility namespace.booleanisTimeZoneHeaderEmitted()Gets a value indicating whether the time zone SOAP header was emitted through this writer.voidsetRequireWSSecurityUtilityNamespace(boolean requireWSSecurityUtilityNamespace)Sets a value indicating whether the SOAP message need WSSecurity Utility namespace.voidsetTimeZoneHeaderEmitted(boolean isTimeZoneHeaderEmitted)Sets a value indicating whether the time zone SOAP header was emitted through this writer.protected booleantryConvertObjectToString(Object value, OutParam<String> str)Try to convert object to a string.protected voidwriteAttributeString(String localName, String stringValue)Writes the attribute value.protected voidwriteAttributeString(String namespacePrefix, String localName, String stringValue)Writes the attribute value.voidwriteAttributeValue(String localName, boolean alwaysWriteEmptyString, Object value)Writes the attribute value.voidwriteAttributeValue(String localName, Object value)Writes the attribute value.voidwriteAttributeValue(String namespacePrefix, String localName, Object value)Writes the attribute value.voidwriteBase64ElementValue(byte[] buffer)Writes the base64-encoded element value.voidwriteBase64ElementValue(InputStream stream)Writes the base64-encoded element value.voidwriteElementValue(XmlNamespace xmlNamespace, String localName, Object value)Writes the element value.voidwriteElementValue(XmlNamespace xmlNamespace, String localName, String displayName, Object value)Writes the element value.voidwriteEndElement()Writes the end element.voidwriteNode(Node xmlNode)static voidwriteNode(Node xmlNode, XMLStreamWriter xmlStreamWriter)voidwriteStartDocument()Write start document.voidwriteStartElement(XmlNamespace xmlNamespace, String localName)Writes the start element.static voidwriteToDocument(Document document, XMLStreamWriter xmlStreamWriter)voidwriteValue(String value, String name)Writes string value.
-
-
-
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 servicestream- 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:
disposein interfaceIDisposable
-
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 namespacelocalName- 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 attributevalue- 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 prefixlocalName- the local name of the attributevalue- 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 namespacelocalName- the local name of the elementdisplayName- the name that should appear in the exception message when the value can not be serializedvalue- the value- Throws:
XMLStreamException- the XML stream exceptionServiceXmlSerializationException- 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 nodexmlStreamWriter- XML stream writer- Throws:
XMLStreamException- the XML stream exception
-
writeToDocument
public static void writeToDocument(Document document, XMLStreamWriter xmlStreamWriter) throws XMLStreamException
- Parameters:
document- XML documentxmlStreamWriter- XML stream writer- Throws:
XMLStreamException- the XML stream exception
-
addElement
public static void addElement(Element element, XMLStreamWriter writer) throws XMLStreamException
- Parameters:
element- DOM elementwriter- 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 namespacelocalName- the local name of the elementvalue- the value- Throws:
XMLStreamException- the XML stream exceptionServiceXmlSerializationException- 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 occurredXMLStreamException- 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
-
-