/** * * Tries to read element from XML. * * @param reader the reader * @return True if element was read. * @throws Exception the exception */ @Override protected boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception { boolean result = super.tryReadElementFromXml(reader); if (!result) { if (reader.getLocalName().equals(XmlElementNames.IsContactPhoto)) { this.isContactPhoto = reader.readElementValue(Boolean.class); } else if (reader.getLocalName().equals(XmlElementNames.Content)) { if (this.loadToStream != null) { reader.readBase64ElementValue(this.loadToStream); } else { // If there's a file attachment content handler, use it. // Otherwise // load the content into a byte array. // TODO: Should we mark the attachment to indicate that // content is stored elsewhere? if (reader.getService().getFileAttachmentContentHandler() != null) { OutputStream outputStream = reader.getService().getFileAttachmentContentHandler().getOutputStream(getId()); if (outputStream != null) { reader.readBase64ElementValue(outputStream); } else { this.content = reader.readBase64ElementValue(); } } else { this.content = reader.readBase64ElementValue(); } } result = true; } } return result; }
/** * Read items from XML. * * @param reader The reader * @param propertySet The property set * @param destinationList The list in which to add the read items. * @throws javax.xml.stream.XMLStreamException the xML stream exception * @throws ServiceXmlDeserializationException the service xml deserialization exception * @throws Exception the exception */ private void internalReadItemsFromXml( EwsServiceXmlReader reader, PropertySet propertySet, List<TItem> destinationList) throws XMLStreamException, ServiceXmlDeserializationException, Exception { EwsUtilities.EwsAssert( destinationList != null, "FindItemResponse.InternalReadItemsFromXml", "destinationList is null."); reader.readStartElement(XmlNamespace.Types, XmlElementNames.Items); if (!reader.isEmptyElement()) { do { reader.read(); if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) { Item item = EwsUtilities.createEwsObjectFromXmlElementName( Item.class, reader.getService(), reader.getLocalName()); if (item == null) { reader.skipCurrentElement(); } else { item.loadFromXml( reader, true, /* clearPropertyBag */ propertySet, true /* summaryPropertiesOnly */); destinationList.add((TItem) item); } } } while (!reader.isEndElement(XmlNamespace.Types, XmlElementNames.Items)); } else { reader.read(); } }
/** * Loads from XML. * * @param reader the reader * @param propertyBag the property bag * @throws Exception the exception */ protected void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws Exception { String value = reader.readElementValue(XmlNamespace.Types, getXmlElement()); propertyBag.setObjectFromPropertyDefinition( this, reader.getService().convertUniversalDateTimeStringToDate(value)); }