/** {@inheritDoc} */ public boolean parseXMP( ImageMetaTagInfo tagInfo, Element element, ElementPrefixFilter dirPrefixFilter) { if (tagInfo.getID() != IPTC_CREATOR_CONTACT_INFO) return false; final Node[] children = XMLUtil.getChildrenOf(element, dirPrefixFilter); XMPMetadataReader.parseElements(children, dirPrefixFilter, this); return true; }
/** {@inheritDoc} */ protected Collection<Element> toXMP(Document xmpDoc, String nsURI, String prefix) { Element rdfDescElement = null; // // First we have to scan through all the metadata values to see if at // least one of them is one of the Creator Contact Info values because // they need special handling. // Element cciElement = null; for (Iterator<Map.Entry<Integer, ImageMetaValue>> i = iterator(); i.hasNext(); ) { final Map.Entry<Integer, ImageMetaValue> me = i.next(); final int tagID = me.getKey(); if (tagIsCreatorContactInfo(tagID)) { rdfDescElement = XMPUtil.createRDFDescription(xmpDoc, nsURI, prefix); cciElement = XMLUtil.addElementChildTo(rdfDescElement, nsURI, prefix + ':' + "CreatorContactInfo"); cciElement.setAttribute(XMP_RDF_PREFIX + ":parseType", "Resource"); rdfDescElement.appendChild(cciElement); break; } } // // Now go through the metadata values for real and convert them to XMP. // If a given metadata value is one of the Creator Contact Info values, // make its parent the Creator Contact Info element rather than the // given parent. // for (Iterator<Map.Entry<Integer, ImageMetaValue>> i = iterator(); i.hasNext(); ) { final Map.Entry<Integer, ImageMetaValue> me = i.next(); final int tagID = me.getKey(); ImageMetaValue value = me.getValue(); // // Only these tags are encoded as part of IPTC for XMP Core. // switch (tagID) { case IPTC_COUNTRY_CODE: case IPTC_INTELLECTUAL_GENRE: case IPTC_LOCATION: case IPTC_SCENE: case IPTC_SUBJECT_CODE: break; default: if (!tagIsCreatorContactInfo(tagID)) continue; } /* // // In XMP, IPTC time fields are merged into the corresponding date // field. // switch ( tagID ) { case IPTC_DATE_CREATED: value = mergeDateTime( value, IPTC_TIME_CREATED ); break; case IPTC_DATE_SENT: value = mergeDateTime( value, IPTC_TIME_SENT ); break; case IPTC_DIGITAL_CREATION_DATE: value = mergeDateTime( value, IPTC_DIGITAL_CREATION_TIME ); break; case IPTC_EXPIRATION_DATE: value = mergeDateTime( value, IPTC_EXPIRATION_TIME ); break; case IPTC_RELEASE_DATE: value = mergeDateTime( value, IPTC_RELEASE_TIME ); break; case IPTC_DIGITAL_CREATION_TIME: case IPTC_EXPIRATION_TIME: case IPTC_RELEASE_TIME: case IPTC_TIME_CREATED: case IPTC_TIME_SENT: continue; } */ final Element valueElement = value.toXMP(xmpDoc, nsURI, prefix); if (valueElement != null) { final Element parent; if (tagIsCreatorContactInfo(tagID)) parent = cciElement; else { if (rdfDescElement == null) rdfDescElement = XMPUtil.createRDFDescription(xmpDoc, nsURI, prefix); parent = rdfDescElement; } //noinspection ConstantConditions parent.appendChild(valueElement); } } if (rdfDescElement != null) { final Collection<Element> elements = new ArrayList<Element>(1); elements.add(rdfDescElement); return elements; } return null; }