gpt4 book ai didi

com.adobe.xmp.XMPMeta.getProperty()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 05:35:05 25 4
gpt4 key购买 nike

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

XMPMeta.getProperty介绍

[英]The property value getter-methods all take a property specification: the first two parameters are always the top level namespace URI (the "schema" namespace) and the basic name of the property being referenced. See the introductory discussion of path expression usage for more information.

All of the functions return an object inherited from PropertyBase or null if the property does not exists. The result object contains the value of the property and option flags describing the property. Arrays and the non-leaf levels of nodes do not have values.

See PropertyOptions for detailed information about the options.

This is the simplest property getter, mainly for top level simple properties or after using the path composition functions in XMPPathFactory.
[中]属性值getter方法都采用属性规范:前两个参数始终是顶级名称空间URI(“schema”名称空间)和被引用属性的基本名称。有关更多信息,请参阅路径表达式用法的介绍性讨论。
如果属性不存在,所有函数都会返回从PropertyBasenull继承的对象。结果对象包含属性值和描述属性的选项标志。数组和节点的非叶级别没有值。
有关选项的详细信息,请参见PropertyOptions。
这是最简单的属性getter,主要用于顶级简单属性或在XMPPathFactory中使用路径组合函数之后。

代码示例

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

/**
 * Checks if the named property is an array.
 *
 * @see org.apache.tika.metadata.Metadata#isMultiValued(java.lang.String)
 */
@Override
public boolean isMultiValued(String name) {
  checkKey( name );
  String[] keyParts = splitKey( name );
  String ns = registry.getNamespaceURI( keyParts[0] );
  if (ns != null) {
    try {
      XMPProperty prop = xmpData.getProperty( ns, keyParts[1] );
      return prop.getOptions().isArray();
    }
    catch (XMPException e) {
      // Ignore
    }
  }
  return false;
}

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

/**
 * Returns the value of a simple property or the first one of an array. The given name must
 * contain a namespace prefix of a registered namespace.
 *
 * @see org.apache.tika.metadata.Metadata#get(java.lang.String)
 */
@Override
public String get(String name) {
  checkKey( name );
  String value = null;
  String[] keyParts = splitKey( name );
  String ns = registry.getNamespaceURI( keyParts[0] );
  if (ns != null) {
    try {
      XMPProperty prop = xmpData.getProperty( ns, keyParts[1] );
      if (prop != null && prop.getOptions().isSimple()) {
        value = prop.getValue();
      }
      else if (prop != null && prop.getOptions().isArray()) {
        prop = xmpData.getArrayItem( ns, keyParts[1], 1 );
        value = prop.getValue();
      }
      // in all other cases, null is returned
    }
    catch (XMPException e) {
      // Ignore
    }
  }
  return value;
}

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

@Test
public void convert_OOXMLMetadataWithoutMimetype_onlyGeneralMetadataconverted()
    throws XMPException, TikaException {
  setupOOXMLMetadata( tikaMetadata );
  XMPMeta xmp = TikaToXMP.convert( tikaMetadata, null );
  // general metadata is converted
  // check simple property
  XMPProperty prop = xmp.getProperty( XMPConst.NS_DC, "language" );
  assertNotNull( prop );
  assertEquals( "language", prop.getValue() );
  // check lang alt
  prop = xmp.getLocalizedText( XMPConst.NS_DC, "title", null, XMPConst.X_DEFAULT );
  assertNotNull( prop );
  assertEquals( "title", prop.getValue() );
  // OOXML one is not, the namespace has also not been registiered as the converter has not
  // been used
  XMPMetaFactory.getSchemaRegistry().registerNamespace( OfficeOpenXMLCore.NAMESPACE_URI,
      OfficeOpenXMLCore.PREFIX );
  prop = xmp.getProperty( OfficeOpenXMLCore.NAMESPACE_URI, "lastModifiedBy" );
  assertNull( prop );
}

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

if (ns != null) {
  try {
    XMPProperty prop = xmpData.getProperty( ns, keyParts[1] );

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

private void checkOOXMLMetadata(XMPMeta xmp) throws XMPException {
  // check simple property
  XMPProperty prop = xmp.getProperty( XMPConst.NS_DC, "language" );
  assertNotNull( prop );
  assertEquals( "language", prop.getValue() );
  // check lang alt
  prop = xmp.getLocalizedText( XMPConst.NS_DC, "title", null, XMPConst.X_DEFAULT );
  assertNotNull( prop );
  assertEquals( "title", prop.getValue() );
  // check array
  prop = xmp.getArrayItem( XMPConst.NS_DC, "subject", 1 );
  assertNotNull( prop );
  assertEquals( "keyword1", prop.getValue() );
  prop = xmp.getArrayItem( XMPConst.NS_DC, "subject", 2 );
  assertNotNull( prop );
  assertEquals( "keyword2", prop.getValue() );
  // check OOXML specific simple property
  prop = xmp.getProperty( OfficeOpenXMLCore.NAMESPACE_URI, "lastModifiedBy" );
  assertNotNull( prop );
  assertEquals( "lastModifiedBy", prop.getValue() );
}

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

@Test
public void process_genericConversion_ok() throws TikaException, XMPException {
  xmpMeta.process( tikaMetadata, GENERIC_MIMETYPE );
  XMPMeta xmp = xmpMeta.getXMPData();
  // check simple property
  XMPProperty prop = xmp.getProperty( XMPConst.NS_DC, "format" );
  assertNotNull( prop );
  assertEquals( GENERIC_MIMETYPE, prop.getValue() );
  // check lang alt
  prop = xmp.getLocalizedText( XMPConst.NS_DC, "title", null, XMPConst.X_DEFAULT );
  assertNotNull( prop );
  assertEquals( "title", prop.getValue() );
  // check array
  prop = xmp.getArrayItem( XMPConst.NS_DC, "subject", 1 );
  assertNotNull( prop );
  assertEquals( "keyword1", prop.getValue() );
  prop = xmp.getArrayItem( XMPConst.NS_DC, "subject", 2 );
  assertNotNull( prop );
  assertEquals( "keyword2", prop.getValue() );
}

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

@Test
public void convert_genericMetadataAllQualified_allConverted() throws XMPException,
    TikaException {
  // simple property
  tikaMetadata.set( TikaCoreProperties.FORMAT, GENERIC_MIMETYPE );
  // language alternative
  tikaMetadata.set( TikaCoreProperties.TITLE, "title" );
  // array
  tikaMetadata.set( TikaCoreProperties.SUBJECT, new String[] { "keyword1", "keyword2" } );
  XMPMeta xmp = TikaToXMP.convert( tikaMetadata, null );
  // check simple property
  XMPProperty prop = xmp.getProperty( XMPConst.NS_DC, "format" );
  assertNotNull( prop );
  assertEquals( GENERIC_MIMETYPE, prop.getValue() );
  // check lang alt
  prop = xmp.getLocalizedText( XMPConst.NS_DC, "title", null, XMPConst.X_DEFAULT );
  assertNotNull( prop );
  assertEquals( "title", prop.getValue() );
  // check array
  prop = xmp.getArrayItem( XMPConst.NS_DC, "subject", 1 );
  assertNotNull( prop );
  assertEquals( "keyword1", prop.getValue() );
  prop = xmp.getArrayItem( XMPConst.NS_DC, "subject", 2 );
  assertNotNull( prop );
  assertEquals( "keyword2", prop.getValue() );
}

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

/**
 * Checks if the named property is an array.
 *
 * @see org.apache.tika.metadata.Metadata#isMultiValued(java.lang.String)
 */
@Override
public boolean isMultiValued(String name) {
  checkKey( name );
  String[] keyParts = splitKey( name );
  String ns = registry.getNamespaceURI( keyParts[0] );
  if (ns != null) {
    try {
      XMPProperty prop = xmpData.getProperty( ns, keyParts[1] );
      return prop.getOptions().isArray();
    }
    catch (XMPException e) {
      // Ignore
    }
  }
  return false;
}

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

/**
 * Checks if the named property is an array.
 *
 * @see org.apache.tika.metadata.Metadata#isMultiValued(java.lang.String)
 */
@Override
public boolean isMultiValued(String name) {
  checkKey( name );
  String[] keyParts = splitKey( name );
  String ns = registry.getNamespaceURI( keyParts[0] );
  if (ns != null) {
    try {
      XMPProperty prop = xmpData.getProperty( ns, keyParts[1] );
      return prop.getOptions().isArray();
    }
    catch (XMPException e) {
      // Ignore
    }
  }
  return false;
}

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

/**
 * Returns the value of a simple property or the first one of an array. The given name must
 * contain a namespace prefix of a registered namespace.
 *
 * @see org.apache.tika.metadata.Metadata#get(java.lang.String)
 */
@Override
public String get(String name) {
  checkKey( name );
  String value = null;
  String[] keyParts = splitKey( name );
  String ns = registry.getNamespaceURI( keyParts[0] );
  if (ns != null) {
    try {
      XMPProperty prop = xmpData.getProperty( ns, keyParts[1] );
      if (prop != null && prop.getOptions().isSimple()) {
        value = prop.getValue();
      }
      else if (prop != null && prop.getOptions().isArray()) {
        prop = xmpData.getArrayItem( ns, keyParts[1], 1 );
        value = prop.getValue();
      }
      // in all other cases, null is returned
    }
    catch (XMPException e) {
      // Ignore
    }
  }
  return value;
}

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

/**
 * Returns the value of a simple property or the first one of an array. The given name must
 * contain a namespace prefix of a registered namespace.
 *
 * @see org.apache.tika.metadata.Metadata#get(java.lang.String)
 */
@Override
public String get(String name) {
  checkKey( name );
  String value = null;
  String[] keyParts = splitKey( name );
  String ns = registry.getNamespaceURI( keyParts[0] );
  if (ns != null) {
    try {
      XMPProperty prop = xmpData.getProperty( ns, keyParts[1] );
      if (prop != null && prop.getOptions().isSimple()) {
        value = prop.getValue();
      }
      else if (prop != null && prop.getOptions().isArray()) {
        prop = xmpData.getArrayItem( ns, keyParts[1], 1 );
        value = prop.getValue();
      }
      // in all other cases, null is returned
    }
    catch (XMPException e) {
      // Ignore
    }
  }
  return value;
}

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

if (ns != null) {
  try {
    XMPProperty prop = xmpData.getProperty( ns, keyParts[1] );

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

if (ns != null) {
  try {
    XMPProperty prop = xmpData.getProperty( ns, keyParts[1] );

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com