gpt4 book ai didi

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

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

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

XMPMeta.iterator介绍

[英]Constructs an iterator for the properties within this XMP object.
[中]为这个XMP对象中的属性构造一个迭代器。

代码示例

代码示例来源:origin: drewnoakes/metadata-extractor

/**
 * Gets a map of all XMP properties in this directory.
 * <p>
 * This is required because XMP properties are represented as strings, whereas the rest of this library
 * uses integers for keys.
 */
@NotNull
public Map<String, String> getXmpProperties()
{
  Map<String, String> propertyValueByPath = new HashMap<String, String>();
  if (_xmpMeta != null)
  {
    try {
      IteratorOptions options = new IteratorOptions().setJustLeafnodes(true);
      for (Iterator i = _xmpMeta.iterator(options); i.hasNext(); ) {
        XMPPropertyInfo prop = (XMPPropertyInfo)i.next();
        String path = prop.getPath();
        String value = prop.getValue();
        if (path != null && value != null) {
          propertyValueByPath.put(path, value);
        }
      }
    } catch (XMPException ignored) {
    }
  }
  return Collections.unmodifiableMap(propertyValueByPath);
}

代码示例来源:origin: drewnoakes/metadata-extractor

public void setXMPMeta(@NotNull XMPMeta xmpMeta)
{
  _xmpMeta = xmpMeta;
  try {
    int valueCount = 0;
    IteratorOptions options = new IteratorOptions().setJustLeafnodes(true);
    for (Iterator i = _xmpMeta.iterator(options); i.hasNext(); ) {
      XMPPropertyInfo prop = (XMPPropertyInfo)i.next();
      if (prop.getPath() != null) {
        valueCount++;
      }
    }
    setInt(TAG_XMP_VALUE_COUNT, valueCount);
  } catch (XMPException ignored) {
  }
}

代码示例来源:origin: drewnoakes/metadata-extractor

/**
 * Determine if there is an extended XMP section based on the standard XMP part.
 * The xmpNote:HasExtendedXMP attribute contains the GUID of the Extended XMP chunks.
 */
@Nullable
private static String getExtendedXMPGUID(@NotNull Metadata metadata)
{
  final Collection<XmpDirectory> xmpDirectories = metadata.getDirectoriesOfType(XmpDirectory.class);
  for (XmpDirectory directory : xmpDirectories) {
    final XMPMeta xmpMeta = directory.getXMPMeta();
    try {
      final XMPIterator itr = xmpMeta.iterator(SCHEMA_XMP_NOTES, null, null);
      if (itr == null)
        continue;
      while (itr.hasNext()) {
        final XMPPropertyInfo pi = (XMPPropertyInfo) itr.next();
        if (ATTRIBUTE_EXTENDED_XMP.equals(pi.getPath())) {
          return pi.getValue();
        }
      }
    } catch (XMPException e) {
      // Fail silently here: we had a reading issue, not a decoding issue.
    }
  }
  return null;
}

代码示例来源:origin: drewnoakes/metadata-extractor

try {
  IteratorOptions options = new IteratorOptions().setJustLeafnodes(true);
  XMPIterator iterator = xmpMeta.iterator(options);
  while (iterator.hasNext()) {
    XMPPropertyInfo prop = (XMPPropertyInfo)iterator.next();

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

/**
 * Returns the number of top-level namespaces
 */
@Override
public int size() {
  int size = 0;
  try {
    // Get an iterator for the XMP packet, starting at the top level schema nodes
    XMPIterator nsIter = xmpData.iterator( new IteratorOptions().setJustChildren( true )
        .setOmitQualifiers( true ) );
    // iterate all top level namespaces
    while (nsIter.hasNext()) {
      nsIter.next();
      size++;
    }
  }
  catch (XMPException e) {
    // ignore
  }
  return size;
}

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

@Test
public void convert_wrongGenericMetadata_notConverted() throws XMPException, TikaException {
  // unknown prefix
  tikaMetadata.set( "unknown:key", "unknownPrefixValue" );
  // not qualified key
  tikaMetadata.set( "wrongKey", "wrongKeyValue" );
  XMPMeta xmp = TikaToXMP.convert( tikaMetadata, null );
  // XMP is empty
  XMPIterator iter = xmp.iterator();
  assertFalse( iter.hasNext() );
}

代码示例来源:origin: com.drewnoakes/metadata-extractor

public void setXMPMeta(@NotNull XMPMeta xmpMeta)
{
  _xmpMeta = xmpMeta;
  try {
    int valueCount = 0;
    for (Iterator i = _xmpMeta.iterator(); i.hasNext(); ) {
      XMPPropertyInfo prop = (XMPPropertyInfo)i.next();
      if (prop.getPath() != null) {
        valueCount++;
      }
    }
    setInt(TAG_XMP_VALUE_COUNT, valueCount);
  } catch (XMPException ignored) {
  }
}

代码示例来源:origin: com.drewnoakes/metadata-extractor

/**
 * Gets a map of all XMP properties in this directory.
 * <p>
 * This is required because XMP properties are represented as strings, whereas the rest of this library
 * uses integers for keys.
 */
@NotNull
public Map<String, String> getXmpProperties()
{
  Map<String, String> propertyValueByPath = new HashMap<String, String>();
  if (_xmpMeta != null)
  {
    try {
      for (Iterator i = _xmpMeta.iterator(); i.hasNext(); ) {
        XMPPropertyInfo prop = (XMPPropertyInfo)i.next();
        String path = prop.getPath();
        String value = prop.getValue();
        if (path != null && value != null) {
          propertyValueByPath.put(path, value);
        }
      }
    } catch (XMPException ignored) {
    }
  }
  return Collections.unmodifiableMap(propertyValueByPath);
}

代码示例来源:origin: stackoverflow.com

// Extract metadata from the image
Metadata metadata = ImageMetadataReader.readMetadata(image);

// Iterate through any XMP directories we may have received
for (XmpDirectory xmpDirectory : metadata.getDirectoriesOfType(XmpDirectory.class)) {

  // Usually with metadata-extractor, you iterate a directory's tags. However XMP has
  // a complex structure with many potentially unknown properties. This doesn't map
  // well to metadata-extractor's directory-and-tag model.
  //
  // If you need to use XMP data, access the XMPMeta object directly.
  XMPMeta xmpMeta = xmpDirectory.getXMPMeta();

  // Iterate XMP properties
  XMPIterator itr = xmpMeta.iterator();
  while (itr.hasNext()) {
    XMPPropertyInfo property = (XMPPropertyInfo) itr.next();

    // Print details of the property
    System.out.println(property.getPath() + ": " + property.getValue());
  }
}

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

/**
 * Returns the number of top-level namespaces
 */
@Override
public int size() {
  int size = 0;
  try {
    // Get an iterator for the XMP packet, starting at the top level schema nodes
    XMPIterator nsIter = xmpData.iterator( new IteratorOptions().setJustChildren( true )
        .setOmitQualifiers( true ) );
    // iterate all top level namespaces
    while (nsIter.hasNext()) {
      nsIter.next();
      size++;
    }
  }
  catch (XMPException e) {
    // ignore
  }
  return size;
}

代码示例来源:origin: org.apache.drill.exec/drill-java-exec

try {
 IteratorOptions iteratorOptions = new IteratorOptions().setJustLeafnodes(true);
 for (final Iterator i = xmpMeta.iterator(iteratorOptions); i.hasNext(); ) {
  try {
   XMPPropertyInfo prop = (XMPPropertyInfo) i.next();

代码示例来源:origin: stackoverflow.com

try {
  Metadata metadata = ImageMetadataReader.readMetadata(imageFile);
  XmpDirectory xmpDirectory = metadata.getDirectory(XmpDirectory.class);
  XMPMeta xmpMeta = xmpDirectory.getXMPMeta();
  XMPIterator itr = xmpMeta.iterator();
  while (itr.hasNext()) {
    XMPPropertyInfo pi = (XMPPropertyInfo) itr.next();
    if (pi != null && pi.getPath() != null) {
      if ((pi.getPath().endsWith("stArea:w")) || (pi.getPath().endsWith("mwg-rs:Name")) || (pi.getPath().endsWith("stArea:h")))
        System.out.println(pi.getValue().toString());
    }
  }
} catch (final NullPointerException npe) {
 // ignore
}

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

/**
 * Returns the number of top-level namespaces
 */
@Override
public int size() {
  int size = 0;
  try {
    // Get an iterator for the XMP packet, starting at the top level schema nodes
    XMPIterator nsIter = xmpData.iterator( new IteratorOptions().setJustChildren( true )
        .setOmitQualifiers( true ) );
    // iterate all top level namespaces
    while (nsIter.hasNext()) {
      nsIter.next();
      size++;
    }
  }
  catch (XMPException e) {
    // ignore
  }
  return size;
}

代码示例来源:origin: stackoverflow.com

try {
  Metadata metadata = ImageMetadataReader.readMetadata(imageFile);
  XmpDirectory xmpDirectory = metadata.getDirectory(XmpDirectory.class);
  XMPMeta xmpMeta = xmpDirectory.getXMPMeta();
  XMPIterator itr = xmpMeta.iterator();
  while (itr.hasNext()) {
    XMPPropertyInfo pi = (XMPPropertyInfo) itr.next();
    if (pi != null && pi.getPath() != null) {
      if ((pi.getPath().endsWith("stArea:w")) || (pi.getPath().endsWith("mwg-rs:Name")) || (pi.getPath().endsWith("stArea:h")))
        System.out.println(pi.getValue().toString());
    }
  }
} catch (final NullPointerException npe) {
 // ignore
}

代码示例来源:origin: com.drewnoakes/metadata-extractor

/**
 * Determine if there is an extended XMP section based on the standard XMP part.
 * The xmpNote:HasExtendedXMP attribute contains the GUID of the Extended XMP chunks.
 */
@Nullable
private static String getExtendedXMPGUID(@NotNull Metadata metadata)
{
  final Collection<XmpDirectory> xmpDirectories = metadata.getDirectoriesOfType(XmpDirectory.class);
  for (XmpDirectory directory : xmpDirectories) {
    final XMPMeta xmpMeta = directory.getXMPMeta();
    try {
      final XMPIterator itr = xmpMeta.iterator(SCHEMA_XMP_NOTES, null, null);
      if (itr == null)
        continue;
      while (itr.hasNext()) {
        final XMPPropertyInfo pi = (XMPPropertyInfo) itr.next();
        if (ATTRIBUTE_EXTENDED_XMP.equals(pi.getPath())) {
          return pi.getValue();
        }
      }
    } catch (XMPException e) {
      // Fail silently here: we had a reading issue, not a decoding issue.
    }
  }
  return null;
}

代码示例来源:origin: com.drewnoakes/metadata-extractor

XMPMeta xmpMeta = xmpDirectory.getXMPMeta();
try {
  XMPIterator iterator = xmpMeta.iterator();
  while (iterator.hasNext()) {
    XMPPropertyInfo prop = (XMPPropertyInfo)iterator.next();

26 4 0