Class EwsXmlReader
- java.lang.Object
-
- microsoft.exchange.webservices.data.core.EwsXmlReader
-
- Direct Known Subclasses:
EwsServiceXmlReader
public class EwsXmlReader extends Object
Defines the EwsXmlReader class.
-
-
Constructor Summary
Constructors Constructor Description EwsXmlReader(InputStream stream)Initializes a new instance of the EwsXmlReader class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancheckEndElement(XMLEvent startEvent, XMLEvent endEvent)Check end element.voidensureCurrentNodeIsEndElement(XmlNamespace xmlNamespace, String localName)Ensures the current node is start element.voidensureCurrentNodeIsStartElement()Ensures the current node is start element.voidensureCurrentNodeIsStartElement(XmlNamespace xmlNamespace, String localName)Ensures the current node is start element.StringgetLocalName()Gets the local name of the current element.protected ObjectgetName()Gets the name of the current element.protected StringgetNamespacePrefix()Gets the namespace prefix.StringgetNamespaceUri()Gets the namespace URI.XmlNodeTypegetNodeType()Gets the type of the node.XMLEventReadergetXmlReaderForNode()Gets the XML reader for node.booleanhasAttributes()Gets a value indicating whether this instance has attribute.protected XMLEventReaderinitializeXmlReader(InputStream stream)Initializes the XML reader.booleanisEmptyElement()Gets a value indicating whether current element is empty.booleanisEndElement(String namespacePrefix, String localName)Determines whether current element is a end element.booleanisEndElement(XmlNamespace xmlNamespace, String localName)Determines whether current element is a end element.booleanisStartElement()Determines whether current element is a start element.booleanisStartElement(String namespacePrefix, String localName)Determines whether current element is a start element.booleanisStartElement(XmlNamespace xmlNamespace, String localName)Determines whether current element is a start element.voidread()Reads the specified node type.voidread(XmlNodeType nodeType)Reads the specified node type.<T> TreadAttributeValue(Class<T> cls, String attributeName)Reads the attribute value.StringreadAttributeValue(String attributeName)Reads the attribute value.StringreadAttributeValue(XmlNamespace xmlNamespace, String attributeName)Reads the attribute value.byte[]readBase64ElementValue()Reads the base64 element value.voidreadBase64ElementValue(OutputStream outputStream)Reads the base64 element value.StringreadElementValue()Read element value.<T> TreadElementValue(Class<T> cls)Read element value.<T> TreadElementValue(Class<T> cls, XmlNamespace xmlNamespace, String localName)Reads the element value.StringreadElementValue(String namespacePrefix, String localName)Reads the element value.StringreadElementValue(XmlNamespace xmlNamespace, String localName)Reads the element value.voidreadEndElement(String namespacePrefix, String elementName)Reads the end element.voidreadEndElement(XmlNamespace xmlNamespace, String localName)Reads the end element.voidreadEndElementIfNecessary(XmlNamespace xmlNamespace, String localName)Reads the end element if necessary.StringreadInnerXml()Reads the Inner XML at the given location.<T> TreadNullableAttributeValue(Class<T> cls, String attributeName)Reads a nullable attribute value.StringreadOuterXml()Outer XML as string.voidreadStartElement(String namespacePrefix, String localName)Reads the start element.voidreadStartElement(XmlNamespace xmlNamespace, String localName)Reads the start element.XMLEventReaderreadSubtree()booleanreadToDescendant(String localName, String namespaceURI)voidreadToDescendant(XmlNamespace xmlNamespace, String localName)Reads to the next descendant element with the specified local name and namespace.StringreadValue()Reads the value.StringreadValue(boolean keepWhiteSpace)Reads the value.<T> TreadValue(Class<T> cls)Reads the value.voidskipCurrentElement()Skips the current element.voidskipElement(String namespacePrefix, String localName)Skips the element.voidskipElement(XmlNamespace xmlNamespace, String localName)Skips the element.booleantryReadValue(OutParam<String> value)Tries to read value.
-
-
-
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 exceptionXMLStreamException- 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 clsattributeName- 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 clsattributeName- 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 prefixlocalName- 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 namespacelocalName- 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 clsxmlNamespace- the xml namespacelocalName- 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 exceptionServiceXmlDeserializationException- 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 exceptionServiceXmlDeserializationException- 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 exceptionServiceXmlDeserializationException- 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 exceptionXMLStreamException- the XML stream exceptionIOException- 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 prefixlocalName- 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 namespacelocalName- 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 prefixelementName- 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 namespacelocalName- 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 namespacelocalName- 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 prefixlocalName- 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 namespacelocalName- 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 prefixlocalName- 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 namespacelocalName- the local name- Returns:
- boolean
-
skipElement
public void skipElement(String namespacePrefix, String localName) throws Exception
Skips the element.- Parameters:
namespacePrefix- the namespace prefixlocalName- the local name- Throws:
Exception- the exception
-
skipElement
public void skipElement(XmlNamespace xmlNamespace, String localName) throws Exception
Skips the element.- Parameters:
xmlNamespace- the xml namespacelocalName- 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 namespacelocalName- 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 namespacelocalName- 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 exceptionXMLStreamException- 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 exceptionXMLStreamException- the XML stream exception
-
checkEndElement
public static boolean checkEndElement(XMLEvent startEvent, XMLEvent endEvent)
Check end element.- Parameters:
startEvent- the start eventendEvent- 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 exceptionServiceXmlDeserializationException- the service xml deserialization exceptionFileNotFoundException- the file not found exception
-
readSubtree
public XMLEventReader readSubtree() 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
-
-