/** * Checks if the given key is a valid QName with a known standard namespace prefix * * @param key * the key to check * @return true if the key is valid otherwise false */ private void checkKey(String key) throws PropertyTypeException { if (key == null || key.length() == 0) { throw new PropertyTypeException( "Key must not be null" ); } String[] keyParts = splitKey( key ); if (keyParts == null) { throw new PropertyTypeException( "Key must be a QName in the form prefix:localName" ); } if (registry.getNamespaceURI( keyParts[0] ) == null) { throw new PropertyTypeException( "Key does not use a registered Namespace prefix" ); } }
/** * It will set all simple and array properties that have QName keys in registered namespaces. * * @see org.apache.tika.metadata.Metadata#setAll(java.util.Properties) */ @Override public void setAll(Properties properties) { @SuppressWarnings("unchecked") Enumeration<String> names = (Enumeration<String>) properties.propertyNames(); while (names.hasMoreElements()) { String name = names.nextElement(); Property property = Property.get( name ); if (property == null) { throw new PropertyTypeException( "Unknown property: " + name ); } String value = properties.getProperty( name ); if (property.isMultiValuePermitted()) { this.set( property, new String[] { value } ); } else { this.set( property, value ); } } }
/** * Sets the integer value of the identified metadata property. * * @since Apache Tika 0.8 * @param property simple integer property definition * @param value property value */ public void set(Property property, int value) { if(property.getPrimaryProperty().getPropertyType() != Property.PropertyType.SIMPLE) { throw new PropertyTypeException(Property.PropertyType.SIMPLE, property.getPrimaryProperty().getPropertyType()); } if(property.getPrimaryProperty().getValueType() != Property.ValueType.INTEGER) { throw new PropertyTypeException(Property.ValueType.INTEGER, property.getPrimaryProperty().getValueType()); } set(property, Integer.toString(value)); }
throw new PropertyTypeException(primaryProperty.getPropertyType()); throw new PropertyTypeException(secondaryExtractProperty.getPropertyType());
/** * Sets the real or rational value of the identified metadata property. * * @since Apache Tika 0.8 * @param property simple real or simple rational property definition * @param value property value */ public void set(Property property, double value) { if(property.getPrimaryProperty().getPropertyType() != Property.PropertyType.SIMPLE) { throw new PropertyTypeException(Property.PropertyType.SIMPLE, property.getPrimaryProperty().getPropertyType()); } if(property.getPrimaryProperty().getValueType() != Property.ValueType.REAL && property.getPrimaryProperty().getValueType() != Property.ValueType.RATIONAL) { throw new PropertyTypeException(Property.ValueType.REAL, property.getPrimaryProperty().getValueType()); } set(property, Double.toString(value)); }
/** * Sets the date value of the identified metadata property. * * @since Apache Tika 0.8 * @param property simple integer property definition * @param date property value */ public void set(Property property, Calendar date) { if(property.getPrimaryProperty().getPropertyType() != Property.PropertyType.SIMPLE) { throw new PropertyTypeException(Property.PropertyType.SIMPLE, property.getPrimaryProperty().getPropertyType()); } if(property.getPrimaryProperty().getValueType() != Property.ValueType.DATE) { throw new PropertyTypeException(Property.ValueType.DATE, property.getPrimaryProperty().getValueType()); } String dateString = null; if (date != null) { dateString = formatDate(date); } set(property, dateString); }
/** * Sets the date value of the identified metadata property. * * @since Apache Tika 0.8 * @param property simple integer property definition * @param date property value */ public void set(Property property, Date date) { if(property.getPrimaryProperty().getPropertyType() != Property.PropertyType.SIMPLE) { throw new PropertyTypeException(Property.PropertyType.SIMPLE, property.getPrimaryProperty().getPropertyType()); } if(property.getPrimaryProperty().getValueType() != Property.ValueType.DATE) { throw new PropertyTypeException(Property.ValueType.DATE, property.getPrimaryProperty().getValueType()); } String dateString = null; if (date != null) { dateString = formatDate(date); } set(property, dateString); }
set(property, appendedValues(values, value)); } else { throw new PropertyTypeException(property.getName() + " : " + property.getPropertyType());
/** * 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 } } }
/** * Checks if the given key is a valid QName with a known standard namespace prefix * * @param key * the key to check * @return true if the key is valid otherwise false */ private void checkKey(String key) throws PropertyTypeException { if (key == null || key.length() == 0) { throw new PropertyTypeException( "Key must not be null" ); } String[] keyParts = splitKey( key ); if (keyParts == null) { throw new PropertyTypeException( "Key must be a QName in the form prefix:localName" ); } if (registry.getNamespaceURI( keyParts[0] ) == null) { throw new PropertyTypeException( "Key does not use a registered Namespace prefix" ); } }
/** * Checks if the given key is a valid QName with a known standard namespace prefix * * @param key * the key to check * @return true if the key is valid otherwise false */ private void checkKey(String key) throws PropertyTypeException { if (key == null || key.length() == 0) { throw new PropertyTypeException( "Key must not be null" ); } String[] keyParts = splitKey( key ); if (keyParts == null) { throw new PropertyTypeException( "Key must be a QName in the form prefix:localName" ); } if (registry.getNamespaceURI( keyParts[0] ) == null) { throw new PropertyTypeException( "Key does not use a registered Namespace prefix" ); } }
/** * It will set all simple and array properties that have QName keys in registered namespaces. * * @see org.apache.tika.metadata.Metadata#setAll(java.util.Properties) */ @Override public void setAll(Properties properties) { @SuppressWarnings("unchecked") Enumeration<String> names = (Enumeration<String>) properties.propertyNames(); while (names.hasMoreElements()) { String name = names.nextElement(); Property property = Property.get( name ); if (property == null) { throw new PropertyTypeException( "Unknown property: " + name ); } String value = properties.getProperty( name ); if (property.isMultiValuePermitted()) { this.set( property, new String[] { value } ); } else { this.set( property, value ); } } }
/** * It will set all simple and array properties that have QName keys in registered namespaces. * * @see org.apache.tika.metadata.Metadata#setAll(java.util.Properties) */ @Override public void setAll(Properties properties) { @SuppressWarnings("unchecked") Enumeration<String> names = (Enumeration<String>) properties.propertyNames(); while (names.hasMoreElements()) { String name = names.nextElement(); Property property = Property.get( name ); if (property == null) { throw new PropertyTypeException( "Unknown property: " + name ); } String value = properties.getProperty( name ); if (property.isMultiValuePermitted()) { this.set( property, new String[] { value } ); } else { this.set( property, value ); } } }
/** * Sets the integer value of the identified metadata property. * * @since Apache Tika 0.8 * @param property simple integer property definition * @param value property value */ public void set(Property property, int value) { if(property.getPrimaryProperty().getPropertyType() != Property.PropertyType.SIMPLE) { throw new PropertyTypeException(Property.PropertyType.SIMPLE, property.getPrimaryProperty().getPropertyType()); } if(property.getPrimaryProperty().getValueType() != Property.ValueType.INTEGER) { throw new PropertyTypeException(Property.ValueType.INTEGER, property.getPrimaryProperty().getValueType()); } set(property, Integer.toString(value)); }
/** * Sets the integer value of the identified metadata property. * * @since Apache Tika 0.8 * @param property simple integer property definition * @param value property value */ public void set(Property property, int value) { if(property.getPrimaryProperty().getPropertyType() != Property.PropertyType.SIMPLE) { throw new PropertyTypeException(Property.PropertyType.SIMPLE, property.getPrimaryProperty().getPropertyType()); } if(property.getPrimaryProperty().getValueType() != Property.ValueType.INTEGER) { throw new PropertyTypeException(Property.ValueType.INTEGER, property.getPrimaryProperty().getValueType()); } set(property, Integer.toString(value)); }
throw new PropertyTypeException(primaryProperty.getPropertyType()); throw new PropertyTypeException(secondaryExtractProperty.getPropertyType());
throw new PropertyTypeException(primaryProperty.getPropertyType()); throw new PropertyTypeException(secondaryExtractProperty.getPropertyType());
/** * Sets the real or rational value of the identified metadata property. * * @since Apache Tika 0.8 * @param property simple real or simple rational property definition * @param value property value */ public void set(Property property, double value) { if(property.getPrimaryProperty().getPropertyType() != Property.PropertyType.SIMPLE) { throw new PropertyTypeException(Property.PropertyType.SIMPLE, property.getPrimaryProperty().getPropertyType()); } if(property.getPrimaryProperty().getValueType() != Property.ValueType.REAL && property.getPrimaryProperty().getValueType() != Property.ValueType.RATIONAL) { throw new PropertyTypeException(Property.ValueType.REAL, property.getPrimaryProperty().getValueType()); } set(property, Double.toString(value)); }
/** * Sets the real or rational value of the identified metadata property. * * @since Apache Tika 0.8 * @param property simple real or simple rational property definition * @param value property value */ public void set(Property property, double value) { if(property.getPrimaryProperty().getPropertyType() != Property.PropertyType.SIMPLE) { throw new PropertyTypeException(Property.PropertyType.SIMPLE, property.getPrimaryProperty().getPropertyType()); } if(property.getPrimaryProperty().getValueType() != Property.ValueType.REAL && property.getPrimaryProperty().getValueType() != Property.ValueType.RATIONAL) { throw new PropertyTypeException(Property.ValueType.REAL, property.getPrimaryProperty().getValueType()); } set(property, Double.toString(value)); }
/** * Add a metadata property/value mapping. Add the specified value to the list of * values associated to the specified metadata property. * * @param property * the metadata property. * @param value * the metadata value. */ public void add(final Property property, final String value) { String[] values = metadata.get(property.getName()); if (values == null) { set(property, value); } else { if (property.isMultiValuePermitted()) { set(property, appendedValues(values, value)); } else { throw new PropertyTypeException(property.getName() + " : " + property.getPropertyType()); } } }