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; }
/** * 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); } } }
/** * Generic array property removing * * @param fieldValue * the field value */ private void removeUnqualifiedArrayValue(String arrayName, String 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.getStringValue().equals(fieldValue)) { toDelete.add(tmp); } } for (AbstractField aToDelete : toDelete) { array.getContainer().removeProperty(aToDelete); } } }
/** * Remove a date sequence value from the list. * * @param seqName * The name of the sequence property, it must include the namespace prefix, e.g. "pdf:Keywords" * @param date * The date to remove from the sequence property. */ public void removeUnqualifiedSequenceDateValue(String seqName, Calendar date) { ArrayProperty seq = (ArrayProperty) getAbstractProperty(seqName); if (seq != null) { List<AbstractField> toDelete = new ArrayList<>(); for (AbstractField tmp : seq.getContainer().getAllProperties()) { if (tmp instanceof DateType && ((DateType) tmp).getValue().equals(date)) { toDelete.add(tmp); } } for (AbstractField aToDelete : toDelete) { seq.getContainer().removeProperty(aToDelete); } } }
/** * Get all the date values in a sequence property. * * @param seqName * The name of the sequence property, it must include the namespace prefix, e.g. "pdf:Keywords". * * @return A read-only list of java.util.Calendar objects or null if the property does not exist. * */ public List<Calendar> getUnqualifiedSequenceDateValueList(String seqName) { List<Calendar> retval = null; ArrayProperty seq = (ArrayProperty) getAbstractProperty(seqName); if (seq != null) { retval = new ArrayList<>(); for (AbstractField child : seq.getContainer().getAllProperties()) { if (child instanceof DateType) { retval.add(((DateType) child).getValue()); } } } return retval; }
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); } }
/** * Add a new value to a bag property. * * @param qualifiedSeqName * The name of the sequence property, it must include the namespace prefix, e.g. "pdf:Keywords" * @param seqValue * The value to add to the bag. */ public void addBagValue(String qualifiedSeqName, AbstractField seqValue) { ArrayProperty bag = (ArrayProperty) getAbstractProperty(qualifiedSeqName); if (bag != null) { bag.getContainer().addProperty(seqValue); } else { ArrayProperty newBag = createArrayProperty(qualifiedSeqName, Cardinality.Bag); newBag.getContainer().addProperty(seqValue); addProperty(newBag); } }
/** * Add a new value to a sequence property. * * @param seqName * The name of the sequence property, it must include the namespace prefix, e.g. "pdf:Keywords" * @param seqValue * The value to add to the sequence. */ public void addUnqualifiedSequenceValue(String seqName, AbstractField seqValue) { ArrayProperty seq = (ArrayProperty) getAbstractProperty(seqName); if (seq != null) { seq.getContainer().addProperty(seqValue); } else { ArrayProperty newSeq = createArrayProperty(seqName, Cardinality.Seq); newSeq.getContainer().addProperty(seqValue); addProperty(newSeq); } }
for (AbstractField child : arrayProp.getContainer().getAllProperties())
/** * Get an AbstractField list corresponding to the content of an array * property. * * @param name The property name whitout namespace. * @return List of properties contained in the array property. * @throws BadFieldValueException If the property with the requested name isn't an array. */ public List<AbstractField> getUnqualifiedArrayList(String name) throws BadFieldValueException { ArrayProperty array = null; for (AbstractField child : getAllProperties()) { if (child.getPropertyName().equals(name)) { if (child instanceof ArrayProperty) { array = (ArrayProperty) child; break; } throw new BadFieldValueException("Property asked is not an array"); } } if (array != null) { return new ArrayList<>(array.getContainer().getAllProperties()); } return null; }
/** * Add a new value to a sequence property. * * @param simpleSeqName * The name of the sequence property without the namespace prefix * @param seqValue * The value to add to the sequence. */ public void addUnqualifiedSequenceValue(String simpleSeqName, String seqValue) { ArrayProperty seq = (ArrayProperty) getAbstractProperty(simpleSeqName); TextType li = createTextType(XmpConstants.LIST_NAME, seqValue); if (seq != null) { seq.getContainer().addProperty(li); } else { ArrayProperty newSeq = createArrayProperty(simpleSeqName, Cardinality.Seq); newSeq.getContainer().addProperty(li); addProperty(newSeq); } }
for (AbstractField child : arrayProp.getContainer().getAllProperties())
if (copyrights == null || copyrights.getContainer() == null || copyrights.getContainer().getAllProperties().isEmpty())
for (AbstractField child : arrayProp.getContainer().getAllProperties()) arrayProp.getContainer().removeProperty(child); if (value != null) langValue.setAttribute(new Attribute(XMLConstants.XML_NS_URI, XmpConstants.LANG_NAME, language)); arrayProp.getContainer().addProperty(langValue); reorganizeAltOrder(arrayProp.getContainer()); return; arrayProp.getContainer().addProperty(langValue); reorganizeAltOrder(arrayProp.getContainer()); TextType langValue = createTextType(XmpConstants.LIST_NAME, value); langValue.setAttribute(new Attribute(XMLConstants.XML_NS_URI, XmpConstants.LANG_NAME, language)); arrayProp.getContainer().addProperty(langValue); addProperty(arrayProp);
Iterator<AbstractField> it = dc.getTitleProperty().getContainer().getAllProperties().iterator(); if (it.hasNext())
tmpEmbeddedProperty.getPropertyName().equals(analyzedPropQualifiedName)) Iterator<AbstractField> itNewValues = ((ArrayProperty) child).getContainer().getAllProperties().iterator(); if (mergeComplexProperty(itNewValues, (ArrayProperty) tmpEmbeddedProperty))
public void addTextLayers(String layerName, String layerText) { if (seqLayer == null) { seqLayer = createArrayProperty(TEXT_LAYERS, Cardinality.Seq); addProperty(seqLayer); } LayerType layer = new LayerType(getMetadata()); layer.setLayerName(layerName); layer.setLayerText(layerText); seqLayer.getContainer().addProperty(layer); }
public void addJob(JobType job) { String prefix = getNamespacePrefix(job.getNamespace()); if (prefix != null) { // use same prefix for all jobs job.setPrefix(prefix); } else { // add prefix addNamespace(job.getNamespace(), job.getPrefix()); } // create bag if not existing if (bagJobs == null) { bagJobs = createArrayProperty(JOB_REF, Cardinality.Bag); addProperty(bagJobs); } // add job bagJobs.getContainer().addProperty(job); }
/** * Add thumbnail to thumbnails list * * @param height * height format * @param width * width format * @param format * thumbnail format * @param img * Image data */ public void addThumbnails(Integer height, Integer width, String format, String img) { if (altThumbs == null) { altThumbs = createArrayProperty(THUMBNAILS, Cardinality.Alt); addProperty(altThumbs); } ThumbnailType thumb = new ThumbnailType(getMetadata()); thumb.setHeight(height); thumb.setWidth(width); thumb.setFormat(format); thumb.setImage(img); altThumbs.getContainer().addProperty(thumb); }