gpt4 book ai didi

com.twelvemonkeys.imageio.metadata.xmp.XMPReader类的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 20:29:05 27 4
gpt4 key购买 nike

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

XMPReader介绍

[英]XMPReader
[中]

代码示例

代码示例来源:origin: haraldk/TwelveMonkeys

Directory parseDirectory() throws IOException {
    // Chop off potential trailing null-termination/padding that SAX parsers don't like...
    int len = data.length;
    for (; len > 0; len--) {
      if (data[len - 1] != 0) {
        break;
      }
    }

    return new XMPReader().read(new ByteArrayImageInputStream(data, 0, len));
  }
}

代码示例来源:origin: haraldk/TwelveMonkeys

private Object getChildTextValue(final Node node) {
  for (Node child : asIterable(node.getChildNodes())) {
    if (XMP.NS_RDF.equals(child.getNamespaceURI()) && "Alt".equals(child.getLocalName())) {
      for (Node alternative : asIterable(child.getChildNodes())) {
        if (XMP.NS_RDF.equals(alternative.getNamespaceURI()) && "li".equals(alternative.getLocalName())) {
          NamedNodeMap attributes = alternative.getAttributes();
          Node key = attributes.getNamedItem("xml:lang");
          alternatives.put(key == null ? null : key.getTextContent(), getChildTextValue(alternative));
      for (Node sequence : asIterable(child.getChildNodes())) {
        if (XMP.NS_RDF.equals(sequence.getNamespaceURI()) && "li".equals(sequence.getLocalName())) {
          Object value = getChildTextValue(sequence);
          seq.add(value);
  if (isResourceType(node)) {
    return parseAsResource(node);

代码示例来源:origin: haraldk/TwelveMonkeys

String toolkit = getToolkit(document);
Node rdfRoot = document.getElementsByTagNameNS(XMP.NS_RDF, "RDF").item(0);
NodeList descriptions = document.getElementsByTagNameNS(XMP.NS_RDF, "Description");
return parseDirectories(rdfRoot, descriptions, toolkit);

代码示例来源:origin: haraldk/TwelveMonkeys

private RDFDescription parseAsResource(Node node) {
  // See: http://www.w3.org/TR/REC-rdf-syntax/#section-Syntax-parsetype-resource
  List<Entry> entries = new ArrayList<Entry>();
  for (Node child : asIterable(node.getChildNodes())) {
    if (child.getNodeType() != Node.ELEMENT_NODE) {
      continue;
    }
    entries.add(new XMPEntry(child.getNamespaceURI() + child.getLocalName(), child.getLocalName(), getChildTextValue(child)));
  }
  return new RDFDescription(entries);
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFSeq() throws IOException {
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-seq-example.xml"));
  assertEquals(1, directory.size());
  assertThat(directory.getEntryById("http://purl.org/dc/elements/1.1/subject"), hasValue(Arrays.asList("XMP", "metadata", "ISO standard")));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Override
protected XMPReader createReader() {
  return new XMPReader();
}

代码示例来源:origin: haraldk/TwelveMonkeys

private void parseAttributesForKnownElements(Map<String, List<Entry>> subdirs, Node desc) {
  // NOTE: NamedNodeMap does not have any particular order...
  NamedNodeMap attributes = desc.getAttributes();
  for (Node attr : asIterable(attributes)) {
    if (!XMP.ELEMENTS.contains(attr.getNamespaceURI())) {
      continue;
    }
    List<Entry> dir = subdirs.get(attr.getNamespaceURI());
    if (dir == null) {
      dir = new ArrayList<Entry>();
      subdirs.put(attr.getNamespaceURI(), dir);
    }
    dir.add(new XMPEntry(attr.getNamespaceURI() + attr.getLocalName(), attr.getLocalName(), attr.getNodeValue()));
  }
}

代码示例来源:origin: com.twelvemonkeys.imageio/twelvemonkeys-imageio-metadata

NodeList descriptions = document.getElementsByTagNameNS(XMP.NS_RDF, "Description");
return parseDirectories(rdfRoot, descriptions);

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFBag() throws IOException {
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-bag-example.xml"));
  assertEquals(1, directory.size());
  assertThat(directory.getEntryById("http://purl.org/dc/elements/1.1/subject"), hasValue(Arrays.asList("XMP", "metadata", "ISO standard"))); // Order does not matter
}

代码示例来源:origin: com.github.lafa.twelvemonkeyspurejava.imageio/imageio-metadata

private RDFDescription parseAsResource(Node node) {
  // See: http://www.w3.org/TR/REC-rdf-syntax/#section-Syntax-parsetype-resource
  List<Entry> entries = new ArrayList<Entry>();
  for (Node child : asIterable(node.getChildNodes())) {
    if (child.getNodeType() != Node.ELEMENT_NODE) {
      continue;
    }
    entries.add(new XMPEntry(child.getNamespaceURI() + child.getLocalName(), child.getLocalName(), getChildTextValue(child)));
  }
  return new RDFDescription(entries);
}

代码示例来源:origin: com.twelvemonkeys.imageio/imageio-metadata

@Override
protected XMPReader createReader() {
  return new XMPReader();
}

代码示例来源:origin: com.twelvemonkeys.imageio/imageio-metadata

private void parseAttributesForKnownElements(Map<String, List<Entry>> subdirs, Node desc) {
  // NOTE: NamedNodeMap does not have any particular order...
  NamedNodeMap attributes = desc.getAttributes();
  for (Node attr : asIterable(attributes)) {
    if (!XMP.ELEMENTS.contains(attr.getNamespaceURI())) {
      continue;
    }
    List<Entry> dir = subdirs.get(attr.getNamespaceURI());
    if (dir == null) {
      dir = new ArrayList<Entry>();
      subdirs.put(attr.getNamespaceURI(), dir);
    }
    dir.add(new XMPEntry(attr.getNamespaceURI() + attr.getLocalName(), attr.getLocalName(), attr.getNodeValue()));
  }
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testCompoundDirectoryContentDC() throws IOException {
  Directory directory = createReader().read(getDataAsIIS());
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // dc|http://purl.org/dc/elements/1.1/
  Directory dc = compound.getDirectory(2);
  assertEquals(2, dc.size());
  assertThat(dc.getEntryById("http://purl.org/dc/elements/1.1/description"), hasValue(Collections.singletonMap("x-default", "Picture 71146")));
  assertThat(dc.getEntryById("http://purl.org/dc/elements/1.1/format"), hasValue("image/jpeg"));
}

代码示例来源:origin: haraldk/TwelveMonkeys

Directory xmp = new XMPReader().read(new ByteArrayImageInputStream(segment.data, segment.offset(), segment.length()));
System.err.println("XMP: " + xmp);
System.err.println(TIFFReader.HexDump.dump(segment.data));

代码示例来源:origin: haraldk/TwelveMonkeys

private XMPDirectory parseDirectories(final Node pParentNode, NodeList pNodes, String toolkit) {
  Map<String, List<Entry>> subdirs = new LinkedHashMap<String, List<Entry>>();
  for (Node desc : asIterable(pNodes)) {
    if (desc.getParentNode() != pParentNode) {
      continue;
    parseAttributesForKnownElements(subdirs, desc);
    for (Node node : asIterable(desc.getChildNodes())) {
      if (node.getNodeType() != Node.ELEMENT_NODE) {
        continue;
      if (isResourceType(node)) {
        value = parseAsResource(node);
        parseAttributesForKnownElements(subsubdirs, node);
          value = getChildTextValue(node);

代码示例来源:origin: com.twelvemonkeys.imageio/imageio-metadata

private RDFDescription parseAsResource(Node node) {
  // See: http://www.w3.org/TR/REC-rdf-syntax/#section-Syntax-parsetype-resource
  List<Entry> entries = new ArrayList<Entry>();
  for (Node child : asIterable(node.getChildNodes())) {
    if (child.getNodeType() != Node.ELEMENT_NODE) {
      continue;
    }
    entries.add(new XMPEntry(child.getNamespaceURI() + child.getLocalName(), child.getLocalName(), getChildTextValue(child)));
  }
  return new RDFDescription(entries);
}

代码示例来源:origin: com.github.lafa.twelvemonkeyspurejava.imageio/imageio-metadata

String toolkit = getToolkit(document);
Node rdfRoot = document.getElementsByTagNameNS(XMP.NS_RDF, "RDF").item(0);
NodeList descriptions = document.getElementsByTagNameNS(XMP.NS_RDF, "Description");
return parseDirectories(rdfRoot, descriptions, toolkit);

代码示例来源:origin: com.github.lafa.twelvemonkeyspurejava.imageio/imageio-metadata

private void parseAttributesForKnownElements(Map<String, List<Entry>> subdirs, Node desc) {
  // NOTE: NamedNodeMap does not have any particular order...
  NamedNodeMap attributes = desc.getAttributes();
  for (Node attr : asIterable(attributes)) {
    if (!XMP.ELEMENTS.contains(attr.getNamespaceURI())) {
      continue;
    }
    List<Entry> dir = subdirs.get(attr.getNamespaceURI());
    if (dir == null) {
      dir = new ArrayList<Entry>();
      subdirs.put(attr.getNamespaceURI(), dir);
    }
    dir.add(new XMPEntry(attr.getNamespaceURI() + attr.getLocalName(), attr.getLocalName(), attr.getNodeValue()));
  }
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFAttributeSyntaxCompoundDirectoryContentDC() throws IOException {
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml"));
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // dc|http://purl.org/dc/elements/1.1/
  Directory dc = getDirectoryByNS(compound, XMP.NS_DC);
  assertEquals(1, dc.size());
  assertThat(dc.getEntryById("http://purl.org/dc/elements/1.1/format"), hasValue("image/jpeg"));
}

代码示例来源:origin: haraldk/TwelveMonkeys

Directory xmp = new XMPReader().read(new ByteArrayImageInputStream(value, 0, len));
System.err.println("-----------------------------------------------------------------------------");
System.err.println("xmp: " + xmp);

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