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); }
/** * 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); }
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 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); } }
while (it.hasNext()) alt.addProperty(it.next());
/** * 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); } }
/** * 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); } }
container.addProperty(array); List<Element> lis = DomHelper.getElementChildren(bagOrSeq);
container.addProperty(sp);
private void manageDefinedType(XMPMetadata xmp, Element property, String prefix, ComplexPropertyContainer container) throws XmpParsingException { if (DomHelper.isParseTypeResource(property)) { AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), property); ast.setPrefix(prefix); container.addProperty(ast); } else { Element inner = DomHelper.getFirstChildElement(property); if (inner == null) { throw new XmpParsingException(ErrorType.Format, "property should contain child element : " + property); } AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), inner); ast.setPrefix(prefix); container.addProperty(ast); } }
private void manageStructuredType(XMPMetadata xmp, Element property, String prefix, ComplexPropertyContainer container) throws XmpParsingException { if (DomHelper.isParseTypeResource(property)) { AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), property); if (ast != null) { ast.setPrefix(prefix); container.addProperty(ast); } } else { Element inner = DomHelper.getFirstChildElement(property); if (inner != null) { nsFinder.push(inner); AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), inner); ast.setPrefix(prefix); container.addProperty(ast); } } }
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); }
ast.getContainer().addProperty(array); Element bagOrSeq = DomHelper.getUniqueElementChild(element); List<Element> lis = DomHelper.getElementChildren(bagOrSeq); element.getTextContent(), type.type()); loadAttributes(sp, element); ast.getContainer().addProperty(sp); inner.setNamespace(namespace); inner.setPrefix(prefix); ast.getContainer().addProperty(inner); ComplexPropertyContainer cpc = inner.getContainer(); if (DomHelper.isParseTypeResource(element))
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); }
langValue.setAttribute(new Attribute(XMLConstants.XML_NS_URI, XmpConstants.LANG_NAME, language)); arrayProp.getContainer().addProperty(langValue); 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);
/** * 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); }
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); }
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 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); }