org.jdom2.Attribute.getParent()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(30)

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

Attribute.getParent介绍

[英]This will return the parent of this Attribute. If there is no parent, then this returns null. Use return-type covariance to override Content's getParent() method to return an Element, not just a Parent
[中]这将返回此Attribute的父项。如果没有父项,则返回null。使用返回类型协方差覆盖内容的getParent()方法以返回元素,而不仅仅是父元素

代码示例

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

@Override
public List<Namespace> getNamespacesIntroduced() {
  if (getParent() == null) {
    return Collections.singletonList(getNamespace());
  }
  return Collections.emptyList();
}

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

@Override
public List<Namespace> getNamespacesInherited() {
  if (getParent() == null) {
    return Collections.singletonList(Namespace.XML_NAMESPACE);
  }
  return orderFirst(getNamespace(), getParent().getNamespacesInScope());
}

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

final Element f = from.getParent();
if (f == null) {
  throw new IllegalArgumentException(

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

"Cannot create a path to a null target");
final Element f = from.getParent();
if (f == null) {
  throw new IllegalArgumentException(

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

"Cannot create a path to a null Attribute");
final Element t = to.getParent();
if (t == null) {
  throw new IllegalArgumentException(

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

@Override
public final Object getParentNode(Object contextNode) throws UnsupportedAxisException {
  if (contextNode instanceof Document) {
    return null;
  }
  if (contextNode instanceof NamespaceContainer) {
    return ((NamespaceContainer)contextNode).getParentElement();
  }
  if (contextNode instanceof Content) {
    return ((Content)contextNode).getParent();
  }
  if (contextNode instanceof Attribute) {
    return ((Attribute)contextNode).getParent();
  }
  return null;
}

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

if (getParent() == null) {
  ArrayList<Namespace> ret = new ArrayList<Namespace>(3);
  ret.add(getNamespace());
  return Collections.unmodifiableList(ret);
return orderFirst(getNamespace(), getParent().getNamespacesInScope());

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

final Element t = to.getParent();
if (t == null) {
  throw new IllegalArgumentException(

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

@Override
public final Iterator<?> getParentAxisIterator(Object contextNode) throws UnsupportedAxisException {
  Parent p = null;
  if (contextNode instanceof Content) {
    p = ((Content)contextNode).getParent();
  } else if (contextNode instanceof NamespaceContainer) {
    p = ((NamespaceContainer)contextNode).getParentElement();
  } else if (contextNode instanceof Attribute) {
    p = ((Attribute)contextNode).getParent();
  }
  if (p != null) {
    return new SingleObjectIterator(p);
  }
  return JaxenConstants.EMPTY_ITERATOR;
}

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

if (attribute.getParent() != null) {
  throw new IllegalAddException(
      "The attribute already has an existing parent \"" +
          attribute.getParent().getQualifiedName() + "\"");

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

" Size: " + size());
if (attribute.getParent() != null) {
  throw new IllegalAddException(
      "The attribute already has an existing parent \"" +
          attribute.getParent().getQualifiedName() + "\"");

代码示例来源:origin: org.mycore/mycore-xeditor

public MCRChangeData(String type, Attribute attribute) {
  this(type, attribute2text(attribute), 0, attribute.getParent());
}

代码示例来源:origin: org.openfuxml/ofx-util

private void filterLang(org.jdom2.Document j2Doc)
{
  XPathFactory xpfac = XPathFactory.instance();
  XPathExpression<Attribute> xp = xpfac.compile("//*/@lang", Filters.attribute());
  for (Attribute att : xp.evaluate(j2Doc))
  {
    if(!att.getValue().equals(lang))
    {
      att.getParent().detach();
    }
  }
}

代码示例来源:origin: org.openfuxml/ofx-util

private void filterLang(org.jdom2.Document j2Doc)
  {
    XPathFactory xpfac = XPathFactory.instance();
    XPathExpression<Attribute> xp = xpfac.compile("//*/@classifier", Filters.attribute());
    for (Attribute att : xp.evaluate(j2Doc))
    {
      boolean remove = true;
      for(String classifier : classifiers)
      {
        if(att.getValue().equals(classifier))
        {
          remove = false;
        }
      }
      if(remove){att.getParent().detach();}
    }
  }
}

相关文章