本文整理汇总了Java中nu.xom.ParentNode类的典型用法代码示例。如果您正苦于以下问题:Java ParentNode类的具体用法?Java ParentNode怎么用?Java ParentNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParentNode类属于nu.xom包,在下文中一共展示了ParentNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prependCopy
import nu.xom.ParentNode; //导入依赖的package包/类
@Override
public void prependCopy(XomNode node) throws XmlBuilderException {
final Node wrappedNode = node.getNode();
if (!(wrappedNode instanceof Element)) {
throw new XmlBuilderException("Unable to copy non-element node " + node);
}
final ParentNode parent = wrappedNode.getParent();
if (null == parent) {
throw new XmlBuilderException("Unable to prepend - no parent found of " + node);
}
try {
final int prependIndex = parent.indexOf(wrappedNode);
final Node copiedNode = wrappedNode.copy();
parent.insertChild(copiedNode, prependIndex);
} catch (IllegalAddException iae) {
throw new XmlBuilderException("Unable to append an copied element to " + parent, iae);
}
}
示例2: moveToParentBefore
import nu.xom.ParentNode; //导入依赖的package包/类
public Node moveToParentBefore(
Node pTargetParentNode
, Node pMovingNode
, Node pPositionBeforeTargetParentsChildNode
) {
// mDocControl in context of pTargetParentNode
mDocControl.setDocumentModifiedCount();
//If this is being moved FROM another document, update the FROM document's modified count
if(pMovingNode.getDocument() != pTargetParentNode.getDocument()){
DocControl.setDocumentModified(pMovingNode);
}
// The SiblingChild should already be attached to Parent element - so this is belt & braces check
if (pPositionBeforeTargetParentsChildNode != null && pPositionBeforeTargetParentsChildNode.getParent() != pTargetParentNode) {
throw new ExInternal("insertBefore error, the sibling is not a child of this node");
}
//Detach from parent
pMovingNode.detach();
int lTargetPosition = ((ParentNode) pTargetParentNode).indexOf(pPositionBeforeTargetParentsChildNode);
((ParentNode) pTargetParentNode).insertChild(pMovingNode, lTargetPosition);
return pMovingNode;
}
示例3: get1ElementNotMatched
import nu.xom.ParentNode; //导入依赖的package包/类
/**
* This overloads ActuateReadOnly's version to create a new Element called pNav instead of throwing an exception.
* @param pParentNode The node to create the element in.
* @param pSimplePath The full path being dealt with.
* @param pNav The token of the path currently being dealt with.
* @return The new Element.
* @throws ExTooFew Never.
*/
@Override
protected Node get1ElementNotMatched(Node pParentNode, String pSimplePath, String pNav) {
mDocControl.setDocumentModifiedCount();
if(!"*".equals(pNav)){
//Create the new Element
Node lNewElement = _internalCreateElementNoChangeInc(pParentNode, pNav);
//Append to parent
((ParentNode) pParentNode).appendChild(lNewElement);
//Return a reference
return lNewElement;
}
else {
throw new ExDOMName("Cannot create a new element called '*' in path " + pSimplePath);
}
}
示例4: removeAllChildren
import nu.xom.ParentNode; //导入依赖的package包/类
public Node removeAllChildren(Node pNode)
throws ExInternal
{
mDocControl.setDocumentModifiedCount();
ParentNode lNodeAsParent = (ParentNode) pNode;
//This is a LIVE list so pop nodes off the start until it is empty.
while(lNodeAsParent.getChildCount() > 0){
Node lChild = lNodeAsParent.getChild(0);
if(lChild instanceof Element){
mDocControl.refIndexRemoveRecursive((Element) lChild);
}
lNodeAsParent.removeChild(0);
}
return pNode;
}
示例5: replaceWith
import nu.xom.ParentNode; //导入依赖的package包/类
/**
* Replaces pNode with pNewNode.
* @param pNode The Node to replace.
* @param pNewNode The Node to replace pNode with.
* @return pNewNode
*/
public Node replaceWith(Node pNode, Node pNewNode) {
mDocControl.setDocumentModifiedCount();
//If pNewNode is being moved FROM another document, update the FROM document's modified count
if(pNode.getDocument() != pNewNode.getDocument()){
DocControl.setDocumentModified(pNewNode);
}
pNewNode.detach();
ParentNode lParent = pNode.getParent();
lParent.replaceChild(pNode, pNewNode);
return pNewNode;
}
示例6: getNextSiblingOrNull
import nu.xom.ParentNode; //导入依赖的package包/类
/**
* Get the next sibling of pNode, in document order. Returns null if pNode has no following siblings.<br/>
* XPath equivalent: <code>./following-sibling::*[1]</code> or <code>./following-sibling::node()[1]</code>
* @param pNode The target Element.
* @param pElementsOnly If true, only considers Elements. If false, considers all nodes.
* @return pNode's next sibling, or null.
*/
public Node getNextSiblingOrNull(Node pNode, boolean pElementsOnly){
ParentNode lParent = pNode.getParent();
if(lParent == null){
return null;
}
int lIndex = lParent.indexOf(pNode);
while(lIndex < lParent.getChildCount() - 1){
Node lNextSibling = lParent.getChild(++lIndex);
//avoid non-Element siblings
if(lNextSibling instanceof Element || !pElementsOnly) {
return lNextSibling;
}
}
return null;
}
示例7: getPreviousSiblingOrNull
import nu.xom.ParentNode; //导入依赖的package包/类
/**
* Get the previous sibling of pNode, in document order. Returns null if pNode has no previous siblings.<br/>
* XPath equivalent: <code>./preceding-sibling::*[1]</code> or <code>./preceding-sibling::node()[1]</code>
* @param pNode The target Element.
* @param pElementsOnly If true, only considers Elements. If false, considers all nodes.
* @return pNode's previous sibling, or null.
*/
public Node getPreviousSiblingOrNull(Node pNode, boolean pElementsOnly) {
ParentNode lParent = pNode.getParent();
if(lParent == null){
return null;
}
int lIndex = lParent.indexOf(pNode);
while(lIndex > 0){
Node lNextSibling = lParent.getChild(--lIndex);
//Avoid non-Element siblings
if(lNextSibling instanceof Element || !pElementsOnly) {
return lNextSibling;
}
}
return null;
}
示例8: ChildAxisIterator
import nu.xom.ParentNode; //导入依赖的package包/类
private ChildAxisIterator(NodeWrapper start, boolean downwards, boolean forwards, NodeTest test) {
this.start = start;
this.downwards = downwards;
this.forwards = forwards;
if (test == AnyNodeTest.getInstance()) test = null;
this.nodeTest = test;
this.position = 0;
if (downwards)
commonParent = start;
else
commonParent = (NodeWrapper) start.getParent();
par = (ParentNode) commonParent.node;
if (downwards) {
ix = (forwards ? 0 : par.getChildCount());
} else {
// find the start node among the list of siblings
// ix = start.getSiblingPosition();
ix = par.indexOf(start.node);
if (forwards) ix++;
}
cursor = ix;
if (!downwards && !forwards) ix--;
}
示例9: translateNamespacePrefixToUri
import nu.xom.ParentNode; //导入依赖的package包/类
public String translateNamespacePrefixToUri(String s, Object o) {
Element element = null;
if (o instanceof Element) {
element = (Element) o;
} else if (o instanceof ParentNode) {
}
else if (o instanceof Node) {
element = (Element)((Node)o).getParent();
}
else if (o instanceof XPathNamespace)
{
element = ((XPathNamespace)o).getElement();
}
if (element != null) {
return element.getNamespaceURI(s);
}
return null;
}
示例10: getNamespaceAxisIterator
import nu.xom.ParentNode; //导入依赖的package包/类
public Iterator getNamespaceAxisIterator(Object o)
{
if (! isElement(o)) {
return JaxenConstants.EMPTY_ITERATOR;
}
Map nsMap = new HashMap();
Element elt = (Element)o;
ParentNode parent = elt;
while (parent instanceof Element) {
elt = (Element)parent;
String uri = elt.getNamespaceURI();
String prefix = elt.getNamespacePrefix();
addNamespaceForElement(elt, uri, prefix, nsMap);
int count = elt.getNamespaceDeclarationCount();
for (int i = 0; i < count; i++) {
prefix = elt.getNamespacePrefix(i);
uri = elt.getNamespaceURI(prefix);
addNamespaceForElement(elt, uri, prefix, nsMap);
}
parent = elt.getParent();
}
addNamespaceForElement(elt, "http://www.w3.org/XML/1998/namespace", "xml", nsMap);
return nsMap.values().iterator();
}
示例11: appendChildren
import nu.xom.ParentNode; //导入依赖的package包/类
@SafeVarargs
public static void appendChildren(
@Nonnull final ParentNode parent,
@Nonnull final Nodes first,
@Nonnull final Nodes... remainder) {
Preconditions.checkNotNull(parent, "parent");
Preconditions.checkNotNull(first, "first");
Preconditions.checkNotNull(remainder, "remainder");
for (int i = 0; i < first.size(); i++)
parent.appendChild(first.get(i));
for (Nodes nodes : remainder)
appendChildren(parent, nodes);
}
示例12: detachChildren
import nu.xom.ParentNode; //导入依赖的package包/类
@SafeVarargs
public static void detachChildren(@Nonnull final Nodes first,
@Nonnull final Nodes... remainder) {
Preconditions.checkNotNull(first, "first");
Preconditions.checkNotNull(remainder, "remainder");
for (int i = 0; i < first.size(); i++) {
Node child = first.get(i);
ParentNode parent = child.getParent();
if (parent == null)
continue;
parent.removeChild(child);
}
for (Nodes nodes : remainder) {
detachChildren(nodes);
}
}
示例13: getAllTags
import nu.xom.ParentNode; //导入依赖的package包/类
public static Vector<String> getAllTags(){
Document projects=FileStorage.openDocument(FileStorage.JN_DOCPATH + ".projects");
Element root= new Element("projects-list");
Elements prjs = projects.getRootElement().getChildElements("project");
int number=0;
ParentNode p=null;
Vector<String> list=new Vector<String>();
for (int i = 0; i < prjs.size(); i++) {
Elements tags =prjs.get(i).getFirstChildElement("tags").getChildElements();
for (int j = 0; j < tags.size(); j++){
list.add(tags.get(j).getAttributeValue("name"));
}
}
return list;
}
示例14: removeDefectLog
import nu.xom.ParentNode; //导入依赖的package包/类
public static void removeDefectLog(DefectLog dl) {
try {
refresh();
ParentNode parent = dl.getElement().getParent();
parent.removeChild(dl.getElement());
}
catch (Exception ex) {
new ExceptionDialog(ex);
}
}
示例15: removeEstimate
import nu.xom.ParentNode; //导入依赖的package包/类
public static void removeEstimate(Estimate tl) {
try {
refresh();
ParentNode parent = tl.getElement().getParent();
parent.removeChild(tl.getElement());
} catch (Exception ex) {
new ExceptionDialog(ex);
}
}