org.apache.tika.metadata.Property.getPropertyType()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中org.apache.tika.metadata.Property.getPropertyType()方法的一些代码示例,展示了Property.getPropertyType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property.getPropertyType()方法的具体详情如下:
包路径:org.apache.tika.metadata.Property
类名称:Property
方法名:getPropertyType

Property.getPropertyType介绍

[英]Get the type of a property
[中]获取属性的类型

代码示例

代码示例来源:origin: apache/tika

/**
 * Get the type of a property
 * @param key name of the property
 * @return the type of the property
 */
public static PropertyType getPropertyType(String key) {
  PropertyType type = null;
  Property prop = properties.get(key);
  if (prop != null) {
    type = prop.getPropertyType();
  }
  return type;
}

代码示例来源:origin: apache/tika

throw new NullPointerException("primaryProperty must not be null");
if (primaryProperty.getPropertyType() == PropertyType.COMPOSITE) {
  throw new PropertyTypeException(primaryProperty.getPropertyType());
    if (secondaryExtractProperty.getPropertyType() == PropertyType.COMPOSITE) {
      throw new PropertyTypeException(secondaryExtractProperty.getPropertyType());

代码示例来源:origin: apache/tika

/**
 * Returns the value of the identified Integer based metadata property.
 * 
 * @since Apache Tika 0.8
 * @param property simple integer property definition
 * @return property value as a Integer, or <code>null</code> if the property is not set, or not a valid Integer
 */
public Integer getInt(Property property) {
  if(property.getPrimaryProperty().getPropertyType() != Property.PropertyType.SIMPLE) {
    return null;
  }
  if(property.getPrimaryProperty().getValueType() != Property.ValueType.INTEGER) {
    return null;
  }
  
  String v = get(property);
  if(v == null) {
    return null;
  }
  try {
    return Integer.valueOf(v);
  } catch(NumberFormatException e) {
    return null;
  }
}

代码示例来源:origin: apache/tika

/**
 * 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));
}

代码示例来源:origin: apache/tika

/**
 * Sets the values of the identified metadata property.
 *
 * @since Apache Tika 1.2
 * @param property property definition
 * @param values    property values
 */
public void set(Property property, String[] values) {
  if (property == null) {
    throw new NullPointerException("property must not be null");
  }
  if (property.getPropertyType() == PropertyType.COMPOSITE) {
    set(property.getPrimaryProperty(), values);
    if (property.getSecondaryExtractProperties() != null) {
      for (Property secondaryExtractProperty : property.getSecondaryExtractProperties()) {
        set(secondaryExtractProperty, values);
      }
    }
  } else {
    metadata.put(property.getName(), values);
  }
}

代码示例来源:origin: apache/tika

/**
 * 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));
}

代码示例来源:origin: apache/tika

/**
 * 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);
}

代码示例来源:origin: apache/tika

/**
 * 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);
}

代码示例来源:origin: apache/tika

throw new NullPointerException("property must not be null");
if (property.getPropertyType() == PropertyType.COMPOSITE) {
  add(property.getPrimaryProperty(), value);
  if (property.getSecondaryExtractProperties() != null) {
    } else {
      throw new PropertyTypeException(property.getName() +
          " : " + property.getPropertyType());

代码示例来源:origin: apache/tika

/**
 * Returns the value of the identified Date based metadata property.
 * 
 * @since Apache Tika 0.8
 * @param property simple date property definition
 * @return property value as a Date, or <code>null</code> if the property is not set, or not a valid Date
 */
public Date getDate(Property property) {
  if(property.getPrimaryProperty().getPropertyType() != Property.PropertyType.SIMPLE) {
    return null;
  }
  if(property.getPrimaryProperty().getValueType() != Property.ValueType.DATE) {
    return null;
  }
  
  String v = get(property);
  if (v != null) {
    return parseDate(v);
  } else {
    return null;
  }
}

代码示例来源:origin: apache/tika

/**
 * Sets the value of the identified metadata property.
 *
 * @since Apache Tika 0.7
 * @param property property definition
 * @param value    property value
 */
public void set(Property property, String value) {
  if (property == null) {
    throw new NullPointerException("property must not be null");
  }
  if (property.getPropertyType() == PropertyType.COMPOSITE) {
    set(property.getPrimaryProperty(), value);
    if (property.getSecondaryExtractProperties() != null) {
      for (Property secondaryExtractProperty : property.getSecondaryExtractProperties()) {
        set(secondaryExtractProperty, value);
      }
    }
  } else {
    set(property.getName(), value);
  }
}

代码示例来源:origin: apache/tika

PropertyType type = Property.getPropertyType( key );
if (type != null) {
  switch (type) {

代码示例来源:origin: org.apache.tika/tika-core

/**
 * Get the type of a property
 * @param key name of the property
 * @return the type of the property
 */
public static PropertyType getPropertyType(String key) {
  PropertyType type = null;
  Property prop = properties.get(key);
  if (prop != null) {
    type = prop.getPropertyType();
  }
  return type;
}

代码示例来源:origin: com.github.lafa.tikaNoExternal/tika-core

/**
 * Get the type of a property
 * @param key name of the property
 * @return the type of the property
 */
public static PropertyType getPropertyType(String key) {
  PropertyType type = null;
  Property prop = properties.get(key);
  if (prop != null) {
    type = prop.getPropertyType();
  }
  return type;
}

代码示例来源:origin: apache/tika

/**
 * 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
    }
  }
}

代码示例来源:origin: org.apache.tika/tika-core

/**
 * 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));
}

代码示例来源:origin: com.github.lafa.tikaNoExternal/tika-core

/**
 * 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));
}

代码示例来源:origin: com.github.lafa.tikaNoExternal/tika-core

/**
 * 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));
}

代码示例来源:origin: org.apache.tika/tika-core

/**
 * 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));
}

代码示例来源:origin: com.github.lafa.tikaNoExternal/tika-core

/**
 * 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);
}

相关文章