microsoft.exchange.webservices.data.core
Class EwsXmlReader

java.lang.Object
  extended by microsoft.exchange.webservices.data.core.EwsXmlReader
Direct Known Subclasses:
EwsServiceXmlReader

public class EwsXmlReader
extends Object

Defines the EwsXmlReader class.


Constructor Summary
EwsXmlReader(InputStream stream)
          Initializes a new instance of the EwsXmlReader class.
 
Method Summary
static boolean checkEndElement(XMLEvent startEvent, XMLEvent endEvent)
          Check end element.
 void ensureCurrentNodeIsEndElement(XmlNamespace xmlNamespace, String localName)
          Ensures the current node is start element.
 void ensureCurrentNodeIsStartElement()
          Ensures the current node is start element.
 void ensureCurrentNodeIsStartElement(XmlNamespace xmlNamespace, String localName)
          Ensures the current node is start element.
 String getLocalName()
          Gets the local name of the current element.
protected  Object getName()
          Gets the name of the current element.
protected  String getNamespacePrefix()
          Gets the namespace prefix.
 String getNamespaceUri()
          Gets the namespace URI.
 XmlNodeType getNodeType()
          Gets the type of the node.
 XMLEventReader getXmlReaderForNode()
          Gets the XML reader for node.
 boolean hasAttributes()
          Gets a value indicating whether this instance has attribute.
protected  XMLEventReader initializeXmlReader(InputStream stream)
          Initializes the XML reader.
 boolean isEmptyElement()
          Gets a value indicating whether current element is empty.
 boolean isEndElement(String namespacePrefix, String localName)
          Determines whether current element is a end element.
 boolean isEndElement(XmlNamespace xmlNamespace, String localName)
          Determines whether current element is a end element.
 boolean isStartElement()
          Determines whether current element is a start element.
 boolean isStartElement(String namespacePrefix, String localName)
          Determines whether current element is a start element.
 boolean isStartElement(XmlNamespace xmlNamespace, String localName)
          Determines whether current element is a start element.
 void read()
          Reads the specified node type.
 void read(XmlNodeType nodeType)
          Reads the specified node type.
<T> T
readAttributeValue(Class<T> cls, String attributeName)
          Reads the attribute value.
 String readAttributeValue(String attributeName)
          Reads the attribute value.
 String readAttributeValue(XmlNamespace xmlNamespace, String attributeName)
          Reads the attribute value.
 byte[] readBase64ElementValue()
          Reads the base64 element value.
 void readBase64ElementValue(OutputStream outputStream)
          Reads the base64 element value.
 String readElementValue()
          Read element value.
<T> T
readElementValue(Class<T> cls)
          Read element value.
<T> T
readElementValue(Class<T> cls, XmlNamespace xmlNamespace, String localName)
          Reads the element value.
 String readElementValue(String namespacePrefix, String localName)
          Reads the element value.
 String readElementValue(XmlNamespace xmlNamespace, String localName)
          Reads the element value.
 void readEndElement(String namespacePrefix, String elementName)
          Reads the end element.
 void readEndElement(XmlNamespace xmlNamespace, String localName)
          Reads the end element.
 void readEndElementIfNecessary(XmlNamespace xmlNamespace, String localName)
          Reads the end element if necessary.
 String readInnerXml()
          Reads the Inner XML at the given location.
<T> T
readNullableAttributeValue(Class<T> cls, String attributeName)
          Reads a nullable attribute value.
 String readOuterXml()
          Outer XML as string.
 void readStartElement(String namespacePrefix, String localName)
          Reads the start element.
 void readStartElement(XmlNamespace xmlNamespace, String localName)
          Reads the start element.
 XMLEventReader readSubtree()
           
 boolean readToDescendant(String localName, String namespaceURI)
           
 void readToDescendant(XmlNamespace xmlNamespace, String localName)
          Reads to the next descendant element with the specified local name and namespace.
 String readValue()
          Reads the value.
 String readValue(boolean keepWhiteSpace)
          Reads the value.
<T> T
readValue(Class<T> cls)
          Reads the value.
 void skipCurrentElement()
          Skips the current element.
 void skipElement(String namespacePrefix, String localName)
          Skips the element.
 void skipElement(XmlNamespace xmlNamespace, String localName)
          Skips the element.
 boolean tryReadValue(OutParam<String> value)
          Tries to read value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EwsXmlReader

public EwsXmlReader(InputStream stream)
             throws Exception
Initializes a new instance of the EwsXmlReader class.

Parameters:
stream - the stream
Throws:
Exception - on error
Method Detail

initializeXmlReader

protected XMLEventReader initializeXmlReader(InputStream stream)
                                      throws Exception
Initializes the XML reader.

Parameters:
stream - the stream
Returns:
An XML reader to use.
Throws:
Exception - on error

read

public void read()
          throws ServiceXmlDeserializationException,
                 XMLStreamException
Reads the specified node type.

Throws:
ServiceXmlDeserializationException - the service xml deserialization exception
XMLStreamException - the XML stream exception

read

public void read(XmlNodeType nodeType)
          throws Exception
Reads the specified node type.

Parameters:
nodeType - Type of the node.
Throws:
Exception - the exception

readAttributeValue

public String readAttributeValue(XmlNamespace xmlNamespace,
                                 String attributeName)
                          throws Exception
Reads the attribute value.

Parameters:
xmlNamespace - The XML namespace.
attributeName - Name of the attribute
Returns:
Attribute Value
Throws:
Exception - the exception

readAttributeValue

public String readAttributeValue(String attributeName)
                          throws Exception
Reads the attribute value.

Parameters:
attributeName - Name of the attribute
Returns:
Attribute value.
Throws:
Exception - the exception

readAttributeValue

public <T> T readAttributeValue(Class<T> cls,
                                String attributeName)
                     throws Exception
Reads the attribute value.

Type Parameters:
T - the generic type
Parameters:
cls - the cls
attributeName - the attribute name
Returns:
T
Throws:
Exception - the exception

readNullableAttributeValue

public <T> T readNullableAttributeValue(Class<T> cls,
                                        String attributeName)
                             throws Exception
Reads a nullable attribute value.

Type Parameters:
T - the generic type
Parameters:
cls - the cls
attributeName - the attribute name
Returns:
T
Throws:
Exception - the exception

readElementValue

public String readElementValue(String namespacePrefix,
                               String localName)
                        throws Exception
Reads the element value.

Parameters:
namespacePrefix - the namespace prefix
localName - the local name
Returns:
String
Throws:
Exception - the exception

readElementValue

public String readElementValue(XmlNamespace xmlNamespace,
                               String localName)
                        throws Exception
Reads the element value.

Parameters:
xmlNamespace - the xml namespace
localName - the local name
Returns:
String
Throws:
Exception - the exception

readElementValue

public String readElementValue()
                        throws Exception
Read element value.

Returns:
String
Throws:
Exception - the exception

readElementValue

public <T> T readElementValue(Class<T> cls,
                              XmlNamespace xmlNamespace,
                              String localName)
                   throws Exception
Reads the element value.

Type Parameters:
T - the generic type
Parameters:
cls - the cls
xmlNamespace - the xml namespace
localName - the local name
Returns:
T
Throws:
Exception - the exception

readElementValue

public <T> T readElementValue(Class<T> cls)
                   throws Exception
Read element value.

Type Parameters:
T - the generic type
Parameters:
cls - the cls
Returns:
T
Throws:
Exception - the exception

readValue

public String readValue()
                 throws XMLStreamException,
                        ServiceXmlDeserializationException
Reads the value. Should return content element or text node as string Present event must be START ELEMENT. After executing this function Present event will be set on END ELEMENT

Returns:
String
Throws:
XMLStreamException - the XML stream exception
ServiceXmlDeserializationException - the service xml deserialization exception

readValue

public String readValue(boolean keepWhiteSpace)
                 throws XMLStreamException,
                        ServiceXmlDeserializationException
Reads the value. Should return content element or text node as string Present event must be START ELEMENT. After executing this function Present event will be set on END ELEMENT

Parameters:
keepWhiteSpace - Do not remove whitespace characters if true
Returns:
String
Throws:
XMLStreamException - the XML stream exception
ServiceXmlDeserializationException - the service xml deserialization exception

tryReadValue

public boolean tryReadValue(OutParam<String> value)
                     throws XMLStreamException,
                            ServiceXmlDeserializationException
Tries to read value.

Parameters:
value - the value
Returns:
boolean
Throws:
XMLStreamException - the XML stream exception
ServiceXmlDeserializationException - the service xml deserialization exception

readValue

public <T> T readValue(Class<T> cls)
            throws Exception
Reads the value.

Type Parameters:
T - the generic type
Parameters:
cls - the cls
Returns:
T
Throws:
Exception - the exception

readBase64ElementValue

public byte[] readBase64ElementValue()
                              throws ServiceXmlDeserializationException,
                                     XMLStreamException,
                                     IOException
Reads the base64 element value.

Returns:
byte[]
Throws:
ServiceXmlDeserializationException - the service xml deserialization exception
XMLStreamException - the XML stream exception
IOException - signals that an I/O exception has occurred

readBase64ElementValue

public void readBase64ElementValue(OutputStream outputStream)
                            throws Exception
Reads the base64 element value.

Parameters:
outputStream - the output stream
Throws:
Exception - the exception

readStartElement

public void readStartElement(String namespacePrefix,
                             String localName)
                      throws Exception
Reads the start element.

Parameters:
namespacePrefix - the namespace prefix
localName - the local name
Throws:
Exception - the exception

readStartElement

public void readStartElement(XmlNamespace xmlNamespace,
                             String localName)
                      throws Exception
Reads the start element.

Parameters:
xmlNamespace - the xml namespace
localName - the local name
Throws:
Exception - the exception

readEndElement

public void readEndElement(String namespacePrefix,
                           String elementName)
                    throws Exception
Reads the end element.

Parameters:
namespacePrefix - the namespace prefix
elementName - the element name
Throws:
Exception - the exception

readEndElement

public void readEndElement(XmlNamespace xmlNamespace,
                           String localName)
                    throws Exception
Reads the end element.

Parameters:
xmlNamespace - the xml namespace
localName - the local name
Throws:
Exception - the exception

readEndElementIfNecessary

public void readEndElementIfNecessary(XmlNamespace xmlNamespace,
                                      String localName)
                               throws Exception
Reads the end element if necessary.

Parameters:
xmlNamespace - the xml namespace
localName - the local name
Throws:
Exception - the exception

isStartElement

public boolean isStartElement()
Determines whether current element is a start element.

Returns:
boolean

isStartElement

public boolean isStartElement(String namespacePrefix,
                              String localName)
Determines whether current element is a start element.

Parameters:
namespacePrefix - the namespace prefix
localName - the local name
Returns:
boolean

isStartElement

public boolean isStartElement(XmlNamespace xmlNamespace,
                              String localName)
Determines whether current element is a start element.

Parameters:
xmlNamespace - the xml namespace
localName - the local name
Returns:
true for matching start element; false otherwise.

isEndElement

public boolean isEndElement(String namespacePrefix,
                            String localName)
Determines whether current element is a end element.

Parameters:
namespacePrefix - the namespace prefix
localName - the local name
Returns:
boolean

isEndElement

public boolean isEndElement(XmlNamespace xmlNamespace,
                            String localName)
Determines whether current element is a end element.

Parameters:
xmlNamespace - the xml namespace
localName - the local name
Returns:
boolean

skipElement

public void skipElement(String namespacePrefix,
                        String localName)
                 throws Exception
Skips the element.

Parameters:
namespacePrefix - the namespace prefix
localName - the local name
Throws:
Exception - the exception

skipElement

public void skipElement(XmlNamespace xmlNamespace,
                        String localName)
                 throws Exception
Skips the element.

Parameters:
xmlNamespace - the xml namespace
localName - the local name
Throws:
Exception - the exception

skipCurrentElement

public void skipCurrentElement()
                        throws Exception
Skips the current element.

Throws:
Exception - the exception

ensureCurrentNodeIsStartElement

public void ensureCurrentNodeIsStartElement(XmlNamespace xmlNamespace,
                                            String localName)
                                     throws ServiceXmlDeserializationException
Ensures the current node is start element.

Parameters:
xmlNamespace - the xml namespace
localName - the local name
Throws:
ServiceXmlDeserializationException - the service xml deserialization exception

ensureCurrentNodeIsStartElement

public void ensureCurrentNodeIsStartElement()
                                     throws ServiceXmlDeserializationException
Ensures the current node is start element.

Throws:
ServiceXmlDeserializationException - the service xml deserialization exception

ensureCurrentNodeIsEndElement

public void ensureCurrentNodeIsEndElement(XmlNamespace xmlNamespace,
                                          String localName)
                                   throws Exception
Ensures the current node is start element.

Parameters:
xmlNamespace - the xml namespace
localName - the local name
Throws:
Exception - the exception

readOuterXml

public String readOuterXml()
                    throws ServiceXmlDeserializationException,
                           XMLStreamException
Outer XML as string.

Returns:
String
Throws:
ServiceXmlDeserializationException - the service xml deserialization exception
XMLStreamException - the XML stream exception

readInnerXml

public String readInnerXml()
                    throws ServiceXmlDeserializationException,
                           XMLStreamException
Reads the Inner XML at the given location.

Returns:
String
Throws:
ServiceXmlDeserializationException - the service xml deserialization exception
XMLStreamException - the XML stream exception

checkEndElement

public static boolean checkEndElement(XMLEvent startEvent,
                                      XMLEvent endEvent)
Check end element.

Parameters:
startEvent - the start event
endEvent - the end event
Returns:
true, if successful

getXmlReaderForNode

public XMLEventReader getXmlReaderForNode()
                                   throws FileNotFoundException,
                                          ServiceXmlDeserializationException,
                                          XMLStreamException
Gets the XML reader for node.

Returns:
null
Throws:
XMLStreamException - the XML stream exception
ServiceXmlDeserializationException - the service xml deserialization exception
FileNotFoundException - the file not found exception

readSubtree

public XMLEventReader readSubtree()
                           throws XMLStreamException,
                                  FileNotFoundException,
                                  ServiceXmlDeserializationException
Throws:
XMLStreamException
FileNotFoundException
ServiceXmlDeserializationException

readToDescendant

public void readToDescendant(XmlNamespace xmlNamespace,
                             String localName)
                      throws XMLStreamException
Reads to the next descendant element with the specified local name and namespace.

Parameters:
xmlNamespace - The namespace of the element you with to move to.
localName - The local name of the element you wish to move to.
Throws:
XMLStreamException - the XML stream exception

readToDescendant

public boolean readToDescendant(String localName,
                                String namespaceURI)
                         throws XMLStreamException
Throws:
XMLStreamException

hasAttributes

public boolean hasAttributes()
Gets a value indicating whether this instance has attribute.

Returns:
boolean

isEmptyElement

public boolean isEmptyElement()
                       throws XMLStreamException
Gets a value indicating whether current element is empty.

Returns:
boolean
Throws:
XMLStreamException - the XML stream exception

getLocalName

public String getLocalName()
Gets the local name of the current element.

Returns:
String

getNamespacePrefix

protected String getNamespacePrefix()
Gets the namespace prefix.

Returns:
String

getNamespaceUri

public String getNamespaceUri()
Gets the namespace URI.

Returns:
String

getNodeType

public XmlNodeType getNodeType()
                        throws XMLStreamException
Gets the type of the node.

Returns:
XmlNodeType
Throws:
XMLStreamException - the XML stream exception

getName

protected Object getName()
Gets the name of the current element.

Returns:
Object


Copyright © 2012–2015 Microsoft. All rights reserved.