org.dom4j.Element.attributeCount()方法的使用及代码示例

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

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

Element.attributeCount介绍

[英]DOCUMENT ME!
[中]

代码示例

代码示例来源:origin: com.thoughtworks.xstream/xstream

public int getAttributeCount() {
  return currentElement.attributeCount();
}

代码示例来源:origin: igniterealtime/Openfire

for ( int i = 0, size = element.attributeCount(); i < size; i++ ) {
  Attribute attribute = element.attribute(i);
  Namespace ns = attribute.getNamespace();

代码示例来源:origin: org.dom4j/dom4j

public static boolean hasAttributes(Node node) {
  if ((node != null) && node instanceof Element) {
    return ((Element) node).attributeCount() > 0;
  } else {
    return false;
  }
}

代码示例来源:origin: org.dom4j/dom4j

public int getAttributeCount() {
  return (element != null) ? element.attributeCount() : 0;
}

代码示例来源:origin: org.dom4j/dom4j

public void applyTemplates(Element element) throws Exception {
  for (int i = 0, size = element.attributeCount(); i < size; i++) {
    Attribute attribute = element.attribute(i);
    fireRule(attribute);
  }
  for (int i = 0, size = element.nodeCount(); i < size; i++) {
    Node node = element.node(i);
    fireRule(node);
  }
}

代码示例来源:origin: org.dom4j/dom4j

public int compare(Element n1, Element n2) {
  int answer = compare(n1.getQName(), n2.getQName());
  if (answer == 0) {
    // lets compare attributes
    int c1 = n1.attributeCount();
    int c2 = n2.attributeCount();
    answer = c1 - c2;
    if (answer == 0) {
      for (int i = 0; i < c1; i++) {
        Attribute a1 = n1.attribute(i);
        Attribute a2 = n2.attribute(a1.getQName());
        answer = compare(a1, a2);
        if (answer != 0) {
          return answer;
        }
      }
      answer = compareContent(n1, n2);
    }
  }
  return answer;
}

代码示例来源:origin: org.dom4j/dom4j

public void appendAttributes(Element element) {
  for (int i = 0, size = element.attributeCount(); i < size; i++) {
    Attribute attribute = element.attribute(i);
    if (attribute.supportsParent()) {
      addAttribute(attribute.getQName(), attribute.getValue());
    } else {
      add(attribute);
    }
  }
}

代码示例来源:origin: org.dom4j/dom4j

for (int i = 0, size = element.attributeCount(); i < size; i++) {
  Attribute attribute = element.attribute(i);
  Namespace ns = attribute.getNamespace();

代码示例来源:origin: dom4j/dom4j

public static boolean hasAttributes(Node node) {
  if ((node != null) && node instanceof Element) {
    return ((Element) node).attributeCount() > 0;
  } else {
    return false;
  }
}

代码示例来源:origin: org.dom4j/com.springsource.org.dom4j

public static boolean hasAttributes(Node node) {
  if ((node != null) && node instanceof Element) {
    return ((Element) node).attributeCount() > 0;
  } else {
    return false;
  }
}

代码示例来源:origin: dom4j/dom4j

public void applyTemplates(Element element) throws Exception {
  for (int i = 0, size = element.attributeCount(); i < size; i++) {
    Attribute attribute = element.attribute(i);
    fireRule(attribute);
  }
  for (int i = 0, size = element.nodeCount(); i < size; i++) {
    Node node = element.node(i);
    fireRule(node);
  }
}

代码示例来源:origin: maven/dom4j

public void applyTemplates(Element element) throws Exception {
  for (int i = 0, size = element.attributeCount(); i < size; i++) {
    Attribute attribute = element.attribute(i);
    fireRule(attribute);
  }
  for (int i = 0, size = element.nodeCount(); i < size; i++) {
    Node node = element.node(i);
    fireRule(node);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j

public void appendAttributes(Element element) {
  for (int i = 0, size = element.attributeCount(); i < size; i++) {
    Attribute attribute = element.attribute(i);
    if (attribute.supportsParent()) {
      addAttribute(attribute.getQName(), attribute.getValue());
    } else {
      add(attribute);
    }
  }
}

代码示例来源:origin: dom4j/dom4j

public void appendAttributes(Element element) {
  for (int i = 0, size = element.attributeCount(); i < size; i++) {
    Attribute attribute = element.attribute(i);
    if (attribute.supportsParent()) {
      addAttribute(attribute.getQName(), attribute.getValue());
    } else {
      add(attribute);
    }
  }
}

代码示例来源:origin: org.jenkins-ci.dom4j/dom4j

public void appendAttributes(Element element) {
  for (int i = 0, size = element.attributeCount(); i < size; i++) {
    Attribute attribute = element.attribute(i);
    if (attribute.supportsParent()) {
      addAttribute(attribute.getQName(), attribute.getValue());
    } else {
      add(attribute);
    }
  }
}

代码示例来源:origin: org.dom4j/com.springsource.org.dom4j

public void appendAttributes(Element element) {
  for (int i = 0, size = element.attributeCount(); i < size; i++) {
    Attribute attribute = element.attribute(i);
    if (attribute.supportsParent()) {
      addAttribute(attribute.getQName(), attribute.getValue());
    } else {
      add(attribute);
    }
  }
}

代码示例来源:origin: org.dom4j/org.motechproject.org.dom4j

public void appendAttributes(Element element) {
  for (int i = 0, size = element.attributeCount(); i < size; i++) {
    Attribute attribute = element.attribute(i);
    if (attribute.supportsParent()) {
      addAttribute(attribute.getQName(), attribute.getValue());
    } else {
      add(attribute);
    }
  }
}

代码示例来源:origin: dom4j/dom4j

protected void assertNodesEqual(Element n1, Element n2) {
  assertNodesEqual(n1.getQName(), n2.getQName());
  int c1 = n1.attributeCount();
  int c2 = n2.attributeCount();
  Assert.assertEquals(c1, c2, String.format("Elements have same number of attributes (%d, %d for: %s and %s", c1, c2, n1, n2));
  for (int i = 0; i < c1; i++) {
    Attribute a1 = n1.attribute(i);
    Attribute a2 = n2.attribute(a1.getQName());
    assertNodesEqual(a1, a2);
  }
  assertNodesEqualContent(n1, n2);
}

代码示例来源:origin: dom4j/dom4j

public void testAddAttributeNormalValue() throws Exception {
  String testAttributeName = "testAtt";
  String testAttributeValue = "testValue";
  Node authorNode = document.selectSingleNode("//root/author[1]");
  assertTrue(authorNode instanceof Element);
  Element authorEl = (Element) authorNode;
  authorEl.addAttribute(testAttributeName, testAttributeValue);
  assertEquals(3, authorEl.attributeCount());
  assertEquals(testAttributeValue, authorEl
      .attributeValue(testAttributeName));
}

代码示例来源:origin: dom4j/dom4j

public void testAddAttributeNullValue() throws Exception {
    String testAttributeName = "location";
    String testAttributeValue = null;

    Node authorNode = document.selectSingleNode("//root/author[1]");

    assertTrue(authorNode instanceof Element);

    Element authorEl = (Element) authorNode;
    authorEl.addAttribute(testAttributeName, testAttributeValue);

    assertEquals(1, authorEl.attributeCount());
    assertNull(authorEl.attributeValue(testAttributeName));
  }
}

相关文章

Element类方法