com.drew.metadata.Directory.getStringArray()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(122)

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

Directory.getStringArray介绍

[英]Gets the specified tag's value as a String array, if possible. Only supported where the tag is set as StringValue[], String[], StringValue, String, int[], byte[] or Rational[].
[中]如果可能,以字符串数组的形式获取指定标记的值。仅当标记设置为StringValue[]、String[]、StringValue、String、int[]、byte[]或Rational[]时才受支持。

代码示例

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

public void handle(Directory directory, Metadata metadata)
      throws MetadataException {
    if (directory.containsTag(IptcDirectory.TAG_KEYWORDS)) {
      String[] keywords = directory.getStringArray(IptcDirectory.TAG_KEYWORDS);
      for (String k : keywords) {
        metadata.add(TikaCoreProperties.SUBJECT, k);
      }
    }
    if (directory.containsTag(IptcDirectory.TAG_HEADLINE)) {
      metadata.set(TikaCoreProperties.TITLE, directory.getString(IptcDirectory.TAG_HEADLINE));
    } else if (directory.containsTag(IptcDirectory.TAG_OBJECT_NAME)) {
      metadata.set(TikaCoreProperties.TITLE, directory.getString(IptcDirectory.TAG_OBJECT_NAME));
    }
    if (directory.containsTag(IptcDirectory.TAG_BY_LINE)) {
      metadata.set(TikaCoreProperties.CREATOR, directory.getString(IptcDirectory.TAG_BY_LINE));
      metadata.set(IPTC.CREATOR, directory.getString(IptcDirectory.TAG_BY_LINE));
    }
    if (directory.containsTag(IptcDirectory.TAG_CAPTION)) {
      metadata.set(TikaCoreProperties.DESCRIPTION,
          // Looks like metadata extractor returns IPTC newlines as a single carriage return,
          // but the exiv2 command does not so we change to line feed here because that is less surprising to users                        
          directory.getString(IptcDirectory.TAG_CAPTION).replaceAll("\r\n?", "\n"));
    }
  }
}

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

Directory directory;
// Keywords
directory = metadata.getDirectory(IptcDirectory.class);
String keywords[] = directory.getStringArray(IptcDirectory.TAG_KEYWORDS);

// Dimensions
directory = metadata.getDirectory(JpegDirectory.class);     
String height = directory.getString(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT);
String width = directory.getString(JpegDirectory.TAG_JPEG_IMAGE_WIDTH);

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

public void handle(Directory directory, Metadata metadata)
      throws MetadataException {
    if (directory.containsTag(IptcDirectory.TAG_KEYWORDS)) {
      String[] keywords = directory.getStringArray(IptcDirectory.TAG_KEYWORDS);
      for (String k : keywords) {
        metadata.add(TikaCoreProperties.KEYWORDS, k);
      }
    }
    if (directory.containsTag(IptcDirectory.TAG_HEADLINE)) {
      metadata.set(TikaCoreProperties.TITLE, directory.getString(IptcDirectory.TAG_HEADLINE));
    } else if (directory.containsTag(IptcDirectory.TAG_OBJECT_NAME)) {
      metadata.set(TikaCoreProperties.TITLE, directory.getString(IptcDirectory.TAG_OBJECT_NAME));
    }
    if (directory.containsTag(IptcDirectory.TAG_BY_LINE)) {
      metadata.set(TikaCoreProperties.CREATOR, directory.getString(IptcDirectory.TAG_BY_LINE));
      metadata.set(IPTC.CREATOR, directory.getString(IptcDirectory.TAG_BY_LINE));
    }
    if (directory.containsTag(IptcDirectory.TAG_CAPTION)) {
      metadata.set(TikaCoreProperties.DESCRIPTION,
          // Looks like metadata extractor returns IPTC newlines as a single carriage return,
          // but the exiv2 command does not so we change to line feed here because that is less surprising to users                        
          directory.getString(IptcDirectory.TAG_CAPTION).replaceAll("\r\n?", "\n"));
    }
  }
}

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

public void handle(Directory directory, Metadata metadata)
      throws MetadataException {
    if (directory.containsTag(IptcDirectory.TAG_KEYWORDS)) {
      String[] keywords = directory.getStringArray(IptcDirectory.TAG_KEYWORDS);
      for (String k : keywords) {
        metadata.add(TikaCoreProperties.KEYWORDS, k);
      }
    }
    if (directory.containsTag(IptcDirectory.TAG_HEADLINE)) {
      metadata.set(TikaCoreProperties.TITLE, directory.getString(IptcDirectory.TAG_HEADLINE));
    } else if (directory.containsTag(IptcDirectory.TAG_OBJECT_NAME)) {
      metadata.set(TikaCoreProperties.TITLE, directory.getString(IptcDirectory.TAG_OBJECT_NAME));
    }
    if (directory.containsTag(IptcDirectory.TAG_BY_LINE)) {
      metadata.set(TikaCoreProperties.CREATOR, directory.getString(IptcDirectory.TAG_BY_LINE));
      metadata.set(IPTC.CREATOR, directory.getString(IptcDirectory.TAG_BY_LINE));
    }
    if (directory.containsTag(IptcDirectory.TAG_CAPTION)) {
      metadata.set(TikaCoreProperties.DESCRIPTION,
          // Looks like metadata extractor returns IPTC newlines as a single carriage return,
          // but the exiv2 command does not so we change to line feed here because that is less surprising to users                        
          directory.getString(IptcDirectory.TAG_CAPTION).replaceAll("\r\n?", "\n"));
    }
  }
}

相关文章