/** * Generic method to remove a field from an array with an Elementable Object * * @param arrayName * the name of the property concerned * @param fieldValue * the elementable field value */ public void removeUnqualifiedArrayValue(String arrayName, AbstractField fieldValue) { ArrayProperty array = (ArrayProperty) getAbstractProperty(arrayName); if (array != null) { List<AbstractField> toDelete = new ArrayList<>(); for (AbstractField abstractField : array.getContainer().getAllProperties()) { AbstractSimpleProperty tmp = (AbstractSimpleProperty) abstractField; if (tmp.equals(fieldValue)) { toDelete.add(tmp); } } for (AbstractField aToDelete : toDelete) { array.getContainer().removeProperty(aToDelete); } } }
public AbstractComplexProperty(XMPMetadata metadata, String propertyName) { super(metadata, propertyName); container = new ComplexPropertyContainer(); this.namespaceToPrefix = new HashMap<>(); }
Iterator<AbstractField> it = alt.getAllProperties().iterator(); AbstractField xdefault = null; boolean xdefaultFound = false; if (xdefault.getAttribute(XmpConstants.LANG_NAME).getValue().equals(XmpConstants.X_DEFAULT)) alt.removeProperty(xdefault); xdefaultFound = true; it = alt.getAllProperties().iterator(); List<AbstractField> reordered = new ArrayList<>(); List<AbstractField> toDelete = new ArrayList<>(); alt.removeProperty(aToDelete); alt.addProperty(it.next());
/** * Add a property to the current structure * * @param obj * the property to add */ public void addProperty(AbstractField obj) { if (containsProperty(obj)) { removeProperty(obj); } properties.add(obj); }
/** * Check if a XMPFieldObject is in the complex property * * @param property * The property to check * @return True if property is present in this container */ public boolean containsProperty(AbstractField property) { Iterator<AbstractField> it = getAllProperties().iterator(); AbstractField tmp; while (it.hasNext()) { tmp = it.next(); if (isSameProperty(tmp, property)) { return true; } } return false; }
/** * Add a property to the current structure * * @param obj * the property to add */ public final void addProperty(AbstractField obj) { // https://www.adobe.com/content/dam/Adobe/en/devnet/xmp/pdfs/cs6/XMPSpecificationPart1.pdf // "Each property name in an XMP packet shall be unique within that packet" // "Multiple values are represented using an XMP array value" // "The nested element's element content shall consist of zero or more rdf:li elements, // one for each item in the array" // thus delete existing elements of a property, except for arrays ("li") if (!(this instanceof ArrayProperty)) { container.removePropertiesByName(obj.getPropertyName()); } container.addProperty(obj); }
public final List<AbstractField> getAllProperties() { return container.getAllProperties(); }
private boolean mergeComplexProperty(Iterator<AbstractField> itNewValues, ArrayProperty arrayProperty) { while (itNewValues.hasNext()) { TextType tmpNewValue = (TextType) itNewValues.next(); for (AbstractField abstractField : arrayProperty.getContainer().getAllProperties()) { TextType tmpOldValue = (TextType) abstractField; if (tmpOldValue.getStringValue().equals(tmpNewValue.getStringValue())) { return true; } } arrayProperty.getContainer().addProperty(tmpNewValue); } return false; }
private void manageSimpleType(XMPMetadata xmp, Element property, Types type, ComplexPropertyContainer container) throws XmpParsingException { TypeMapping tm = xmp.getTypeMapping(); String prefix = property.getPrefix(); String name = property.getLocalName(); String namespace = property.getNamespaceURI(); AbstractSimpleProperty sp = tm.instanciateSimpleProperty(namespace, prefix, name, property.getTextContent(), type); loadAttributes(sp, property); container.addProperty(sp); }
public final AbstractField getProperty(String fieldName) { List<AbstractField> list = container.getPropertiesByLocalName(fieldName); // return null if no property if (list == null) { return null; } // return the first element of the list return list.get(0); }
/** * Remove a property * * @param property * The property to remove */ public final void removeProperty(AbstractField property) { container.removeProperty(property); }
protected final AbstractField getFirstEquivalentProperty(String localName, Class<? extends AbstractField> type) { return container.getFirstEquivalentProperty(localName, type); }
/** * Remove a property * * @param property * The property to remove */ public void removeProperty(AbstractField property) { if (containsProperty(property)) { properties.remove(property); } }
public List<String> getElementsAsString() { List<String> retval; retval = new ArrayList<>(); Iterator<AbstractField> it = getContainer().getAllProperties().iterator(); AbstractSimpleProperty tmp; while (it.hasNext()) { tmp = (AbstractSimpleProperty) it.next(); retval.add(tmp.getStringValue()); } retval = Collections.unmodifiableList(retval); return retval; }
private boolean mergeComplexProperty(Iterator<AbstractField> itNewValues, ArrayProperty arrayProperty) { while (itNewValues.hasNext()) { TextType tmpNewValue = (TextType) itNewValues.next(); for (AbstractField abstractField : arrayProperty.getContainer().getAllProperties()) { TextType tmpOldValue = (TextType) abstractField; if (tmpOldValue.getStringValue().equals(tmpNewValue.getStringValue())) { return true; } } arrayProperty.getContainer().addProperty(tmpNewValue); } return false; }
/** * Check if a XMPFieldObject is in the complex property * * @param property * The property to check * @return True if property is present in this container */ public boolean containsProperty(AbstractField property) { Iterator<AbstractField> it = getAllProperties().iterator(); AbstractField tmp; while (it.hasNext()) { tmp = it.next(); if (isSameProperty(tmp, property)) { return true; } } return false; }
private void internalAddBagValue(String qualifiedBagName, String bagValue) { ArrayProperty bag = (ArrayProperty) getAbstractProperty(qualifiedBagName); TextType li = createTextType(XmpConstants.LIST_NAME, bagValue); if (bag != null) { bag.getContainer().addProperty(li); } else { ArrayProperty newBag = createArrayProperty(qualifiedBagName, Cardinality.Bag); newBag.getContainer().addProperty(li); addProperty(newBag); } }
public final ArrayProperty getArrayProperty(String fieldName) { List<AbstractField> list = container.getPropertiesByLocalName(fieldName); // return null if no property if (list == null) { return null; } // return the first element of the list return (ArrayProperty) list.get(0); }
/** * Add a property to the current structure * * @param obj * the property to add */ public void addProperty(AbstractField obj) { if (containsProperty(obj)) { removeProperty(obj); } properties.add(obj); }
/** * Add a property to the current structure * * @param obj * the property to add */ public final void addProperty(AbstractField obj) { // https://www.adobe.com/content/dam/Adobe/en/devnet/xmp/pdfs/cs6/XMPSpecificationPart1.pdf // "Each property name in an XMP packet shall be unique within that packet" // "Multiple values are represented using an XMP array value" // "The nested element's element content shall consist of zero or more rdf:li elements, // one for each item in the array" // thus delete existing elements of a property, except for arrays ("li") if (!(this instanceof ArrayProperty)) { container.removePropertiesByName(obj.getPropertyName()); } container.addProperty(obj); }