groovy.util.Node.setParent()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(112)

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

Node.setParent介绍

[英]Adds or replaces the parent of the node.
[中]添加或替换节点的父节点。

代码示例

代码示例来源:origin: org.codehaus.groovy/groovy

/**
 * Appends a child to the current node.
 *
 * @param child the child to append
 * @return <code>true</code>
 */
public boolean append(Node child) {
  child.setParent(this);
  return getParentList(this).add(child);
}

代码示例来源:origin: org.codehaus.groovy/groovy

/**
 * Removes a child of the current node.
 *
 * @param child the child to remove
 * @return <code>true</code> if the param was a child of the current node
 */
public boolean remove(Node child) {
  child.setParent(null);
  return getParentList(this).remove(child);
}

代码示例来源:origin: org.codehaus.groovy/groovy

/**
 * Replaces the current node with nodes defined using builder-style notation via a Closure.
 *
 * @param c A Closure defining the new nodes using builder-style notation.
 * @return the original now replaced node
 */
public Node replaceNode(Closure c) {
  if (parent() == null) {
    throw new UnsupportedOperationException("Replacing the root node is not supported");
  }
  appendNodes(c);
  getParentList(parent()).remove(this);
  this.setParent(null);
  return this;
}

代码示例来源:origin: org.codehaus.groovy/groovy

/**
 * Replaces the current node with the supplied node.
 *
 * @param n the new Node
 * @return the original now replaced node
 */
public Node replaceNode(Node n) {
  if (parent() == null) {
    throw new UnsupportedOperationException("Replacing the root node is not supported");
  }
  List tail = getTail();
  parent().appendNode(n.name(), n.attributes(), n.value());
  parent().children().addAll(tail);
  getParentList(parent()).remove(this);
  this.setParent(null);
  return this;
}

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

/**
 * Appends a child to the current node.
 *
 * @param child the child to append
 * @return <code>true</code>
 */
public boolean append(Node child) {
  child.setParent(this);
  return getParentList(this).add(child);
}

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

/**
 * Removes a child of the current node.
 *
 * @param child the child to remove
 * @return <code>true</code> if the param was a child of the current node
 */
public boolean remove(Node child) {
  child.setParent(null);
  return getParentList(this).remove(child);
}

相关文章