/** * Read element value. * * @param <T> the generic type * @param cls the cls * @return T * @throws Exception the exception */ public <T> T readElementValue(Class<T> cls) throws Exception { this.ensureCurrentNodeIsStartElement(); T value = null; if (!this.isEmptyElement()) { value = this.readValue(cls); } return value; }
/** * Ensures the current node is start element. * * @param xmlNamespace the xml namespace * @param localName the local name * @throws Exception the exception */ public void ensureCurrentNodeIsEndElement(XmlNamespace xmlNamespace, String localName) throws Exception { if (!this.isEndElement(xmlNamespace, localName)) { if (!(this.isStartElement(xmlNamespace, localName) && this .isEmptyElement())) { throw new ServiceXmlDeserializationException( String .format("The element '%s' in namespace '%s' wasn't found at the current position.", xmlNamespace, localName)); } } }
/** * Reads the end element if necessary. * * @param xmlNamespace the xml namespace * @param localName the local name * @throws Exception the exception */ public void readEndElementIfNecessary(XmlNamespace xmlNamespace, String localName) throws Exception { if (!(this.isStartElement(xmlNamespace, localName) && this .isEmptyElement())) { if (!this.isEndElement(xmlNamespace, localName)) { this.readEndElement(xmlNamespace, localName); } } }
/** * Reads the element value. * * @param namespacePrefix the namespace prefix * @param localName the local name * @return String * @throws Exception the exception */ public String readElementValue(String namespacePrefix, String localName) throws Exception { if (!this.isStartElement(namespacePrefix, localName)) { this.readStartElement(namespacePrefix, localName); } String value = null; if (!this.isEmptyElement()) { value = this.readValue(); } return value; }
/** * Reads the element value. * * @param <T> the generic type * @param cls the cls * @param xmlNamespace the xml namespace * @param localName the local name * @return T * @throws Exception the exception */ public <T> T readElementValue(Class<T> cls, XmlNamespace xmlNamespace, String localName) throws Exception { if (!this.isStartElement(xmlNamespace, localName)) { this.readStartElement(xmlNamespace, localName); } T value = null; if (!this.isEmptyElement()) { value = this.readValue(cls); } return value; }
/** * Parses the message xml. * * @param reader the reader * @throws Exception the exception * @throws ServiceXmlDeserializationException the service xml deserialization exception */ private void parseMessageXml(EwsXmlReader reader) throws Exception, ServiceXmlDeserializationException, Exception { // E14:172881: E12 and E14 return the MessageXml element in different // namespaces (types namespace for E12, errors namespace in E14). To // avoid this problem, the parser will match the namespace from the // start and end elements. XmlNamespace elementNS = EwsUtilities.getNamespaceFromUri(reader.getNamespaceUri()); if (!reader.isEmptyElement()) { do { reader.read(); if (reader.isStartElement() && !reader.isEmptyElement()) { String localName = reader.getLocalName(); if (localName.equals(XmlElementNames.Value)) { this.errorDetails.put(reader .readAttributeValue(XmlAttributeNames.Name), reader.readElementValue()); } } } while (!reader .isEndElement(elementNS, XmlElementNames.MessageXml)); } else { reader.read(); } }
/** * Reads the element value. * * @param xmlNamespace the xml namespace * @param localName the local name * @return String * @throws Exception the exception */ public String readElementValue(XmlNamespace xmlNamespace, String localName) throws Exception { if (!this.isStartElement(xmlNamespace, localName)) { this.readStartElement(xmlNamespace, localName); } String value = null; if (!this.isEmptyElement()) { value = this.readValue(); } else { this.read(); } return value; }
/** * Tries to read value. * * @param value the value * @return boolean * @throws XMLStreamException the XML stream exception * @throws ServiceXmlDeserializationException the service xml deserialization exception */ public boolean tryReadValue(OutParam<String> value) throws XMLStreamException, ServiceXmlDeserializationException { if (!this.isEmptyElement()) { this.read(); if (this.presentEvent.isCharacters()) { value.setParam(this.readValue()); return true; } else { return false; } } else { return false; } }
/** * Loads the domain setting errors. * * @param reader The reader. * @throws Exception the exception */ private void loadDomainSettingErrorsFromXml(EwsXmlReader reader) throws Exception { if (!reader.isEmptyElement()) { do { reader.read(); if ((reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) && (reader.getLocalName() .equals(XmlElementNames.DomainSettingError))) { DomainSettingError error = new DomainSettingError(); error.loadFromXml(reader); domainSettingErrors.add(error); } } while (!reader.isEndElement(XmlNamespace.Autodiscover, XmlElementNames.DomainSettingErrors)); } else { reader.read(); } } }
if (!reader.isEmptyElement()) { do { reader.read();
if (!reader.isEmptyElement()) { do { reader.read();
/** * Skips the element. * * @param namespacePrefix the namespace prefix * @param localName the local name * @throws Exception the exception */ public void skipElement(String namespacePrefix, String localName) throws Exception { if (!this.isEndElement(namespacePrefix, localName)) { if (!this.isStartElement(namespacePrefix, localName)) { this.readStartElement(namespacePrefix, localName); } if (!this.isEmptyElement()) { do { this.read(); } while (!this.isEndElement(namespacePrefix, localName)); } } }
/** * Skips the element. * * @param xmlNamespace the xml namespace * @param localName the local name * @throws Exception the exception */ public void skipElement(XmlNamespace xmlNamespace, String localName) throws Exception { if (!this.isEndElement(xmlNamespace, localName)) { if (!this.isStartElement(xmlNamespace, localName)) { this.readStartElement(xmlNamespace, localName); } if (!this.isEmptyElement()) { do { this.read(); } while (!this.isEndElement(xmlNamespace, localName)); } } }
/** * Loads the user setting errors. * * @param reader The reader. * @throws Exception the exception */ private void loadUserSettingErrorsFromXml(EwsXmlReader reader) throws Exception { if (!reader.isEmptyElement()) { do { reader.read(); if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && (reader.getLocalName() .equals(XmlElementNames.UserSettingError))) { UserSettingError error = new UserSettingError(); error.loadFromXml(reader); this.getUserSettingErrors().add(error); } } while (!reader.isEndElement(XmlNamespace.Autodiscover, XmlElementNames.UserSettingErrors)); } else { reader.read(); } } }
/** * Loads response from XML. * * @param reader the reader * @throws Exception the exception */ private void loadResponseCollectionFromXml(EwsXmlReader reader) throws Exception { if (!reader.isEmptyElement()) { do { reader.read(); if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && (reader.getLocalName().equals(this .getResponseInstanceXmlElementName()))) { TResponse response = this.createResponseInstance(); response.loadFromXml(reader, this .getResponseInstanceXmlElementName()); this.responses.add(response); } } while (!reader.isEndElement(XmlNamespace.Autodiscover, this .getResponseCollectionXmlElementName())); } else { reader.read(); } }
/** * Read element value. * * @param <T> the generic type * @param cls the cls * @return T * @throws Exception the exception */ public <T> T readElementValue(Class<T> cls) throws Exception { this.ensureCurrentNodeIsStartElement(); T value = null; if (!this.isEmptyElement()) { value = this.readValue(cls); } return value; }
/** * Ensures the current node is start element. * * @param xmlNamespace the xml namespace * @param localName the local name * @throws Exception the exception */ public void ensureCurrentNodeIsEndElement(XmlNamespace xmlNamespace, String localName) throws Exception { if (!this.isEndElement(xmlNamespace, localName)) { if (!(this.isStartElement(xmlNamespace, localName) && this .isEmptyElement())) { throw new ServiceXmlDeserializationException( String .format("The element '%s' in namespace '%s' wasn't found at the current position.", xmlNamespace, localName)); } } }
/** * Reads the end element if necessary. * * @param xmlNamespace the xml namespace * @param localName the local name * @throws Exception the exception */ public void readEndElementIfNecessary(XmlNamespace xmlNamespace, String localName) throws Exception { if (!(this.isStartElement(xmlNamespace, localName) && this .isEmptyElement())) { if (!this.isEndElement(xmlNamespace, localName)) { this.readEndElement(xmlNamespace, localName); } } }
/** * Reads the element value. * * @param namespacePrefix the namespace prefix * @param localName the local name * @return String * @throws Exception the exception */ public String readElementValue(String namespacePrefix, String localName) throws Exception { if (!this.isStartElement(namespacePrefix, localName)) { this.readStartElement(namespacePrefix, localName); } String value = null; if (!this.isEmptyElement()) { value = this.readValue(); } return value; }
/** * Reads the element value. * * @param <T> the generic type * @param cls the cls * @param xmlNamespace the xml namespace * @param localName the local name * @return T * @throws Exception the exception */ public <T> T readElementValue(Class<T> cls, XmlNamespace xmlNamespace, String localName) throws Exception { if (!this.isStartElement(xmlNamespace, localName)) { this.readStartElement(xmlNamespace, localName); } T value = null; if (!this.isEmptyElement()) { value = this.readValue(cls); } return value; }