Search in sources :

Example 1 with PropertyOptions

use of com.adobe.xmp.options.PropertyOptions in project tika by apache.

the class XMPMetadata method set.

/**
     * Sets array properties. If the property already exists, it is overwritten. Only array
     * properties that use a registered prefix are stored in the XMP.
     *
     * @see org.apache.tika.metadata.Metadata#set(org.apache.tika.metadata.Property,
     *      java.lang.String[])
     */
@Override
public void set(Property property, String[] values) {
    checkKey(property.getName());
    if (!property.isMultiValuePermitted()) {
        throw new PropertyTypeException("Property is not of an array type");
    }
    String[] keyParts = splitKey(property.getName());
    String ns = registry.getNamespaceURI(keyParts[0]);
    if (ns != null) {
        try {
            int arrayType = tikaToXMPArrayType(property.getPrimaryProperty().getPropertyType());
            xmpData.setProperty(ns, keyParts[1], null, new PropertyOptions(arrayType));
            for (String value : values) {
                xmpData.appendArrayItem(ns, keyParts[1], value);
            }
        } catch (XMPException e) {
        // Ignore
        }
    }
}
Also used : PropertyOptions(com.adobe.xmp.options.PropertyOptions) PropertyTypeException(org.apache.tika.metadata.PropertyTypeException) XMPException(com.adobe.xmp.XMPException)

Aggregations

XMPException (com.adobe.xmp.XMPException)1 PropertyOptions (com.adobe.xmp.options.PropertyOptions)1 PropertyTypeException (org.apache.tika.metadata.PropertyTypeException)1