本文整理汇总了Java中nu.xom.Node.getDocument方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getDocument方法的具体用法?Java Node.getDocument怎么用?Java Node.getDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nu.xom.Node
的用法示例。
在下文中一共展示了Node.getDocument方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveToParentBefore
import nu.xom.Node; //导入方法依赖的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;
}
示例2: replaceWith
import nu.xom.Node; //导入方法依赖的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;
}
示例3: getDocControl
import nu.xom.Node; //导入方法依赖的package包/类
public static final DocControl getDocControl(Node pNode) {
DocControl lDocControl;
if(pNode.getDocument() == null){
//Special case for unattached nodes
return gUnattachedNodeDocControl;
}
synchronized(gDocumentToDocControl_SyncMe) {
lDocControl = DocControl.gDocumentToDocControl_SyncMe.get(pNode.getDocument());
}
if(lDocControl==null) {
throw new ExInternal("DocControl should always be in gDocumentToDocControl_SyncMe map for node " + pNode.toString());
}
return lDocControl;
}
示例4: moveToParent
import nu.xom.Node; //导入方法依赖的package包/类
public Node moveToParent(Node pNode, Node pNewParent) {
mDocControl.setDocumentModifiedCount();
//If this is being moved FROM another document, update the FROM document's modified count
if(pNode.getDocument() != pNewParent.getDocument()){
DocControl.setDocumentModified(pNode);
}
//Detach from parent
pNode.detach();
//Attach to new parent
((ParentNode) pNewParent).appendChild(pNode);
return pNode;
}
示例5: setDocType
import nu.xom.Node; //导入方法依赖的package包/类
@Override
public void setDocType(Node pNode, String pRootElementName, String pPublicID, String pSystemID){
if(pNode.getDocument() == null){
throw new ExInternal("Node does not have a Document.");
}
mDocControl.setDocumentModifiedCount();
pNode.getDocument().setDocType(new DocType(pRootElementName, pPublicID, pSystemID));
}
示例6: throwAccessViolation
import nu.xom.Node; //导入方法依赖的package包/类
public void throwAccessViolation(Node pNode)
throws ExInternal
{
throw new ExInternal("Access violation DOM: "+mAccessViolationInfo + " for root element " + (pNode != null && pNode.getDocument() != null ? pNode.getDocument().getRootElement().getLocalName() : "UNKNOWN"));
}
示例7: getCreateXPathUL
import nu.xom.Node; //导入方法依赖的package包/类
public DOMList getCreateXPathUL(Node fromNode, String simpleXPathExpr, ContextUElem pContextUElem)
throws ExInternal, ExBadPath
{
// Check for recurse expression - not yet supported
if(simpleXPathExpr.length() > 0 && simpleXPathExpr.indexOf("//") >= 0)
{
throw new ExInternal(getClass().getName()+"::getCreateXPathUL() does not support // as yet: \""+simpleXPathExpr+"\"", new DOM(fromNode));
}
DocControl.setDocumentModified(fromNode);
StringBuffer currentPath = new StringBuffer(simpleXPathExpr);
// Catch document root XPATH
if(simpleXPathExpr.equals("/")) {
DOMList root = new DOMList();
root.add(new DOM(fromNode.getDocument()));
return root;
}
// Test for root
if (simpleXPathExpr.startsWith("/"))
{
fromNode = fromNode.getDocument();
}
String headPathElement = XFUtil.pathPopHead(currentPath, true);
if (headPathElement.length() == 0)
return new DOMList();
DOMList foundNodes = xpathUL(fromNode, headPathElement, pContextUElem);
if (foundNodes.getLength() == 0)
{
foundNodes.add(new DOM(addElement(fromNode, headPathElement)));
}
//------------------------------------------------------------------------
// Now we have a starting point(s), attempt to step down the path
// one element at a time, finding or creating the node(s) as we go.
//------------------------------------------------------------------------
DOMList foundDescendantNodes = new DOMList();
while(currentPath.length() != 0)
{
headPathElement = XFUtil.pathPopHead(currentPath, true);
foundDescendantNodes.clear();
for (int n=0; n < foundNodes.getLength(); n++)
{
DOMList fromNodeMatches = xpathUL(foundNodes.item(n).getNode(), headPathElement, pContextUElem);
if (fromNodeMatches.getLength() > 0)
{
foundDescendantNodes.addAll(fromNodeMatches);
}
else
{
// Node doesn't exist under this fromNode - so let's create one.
try {
foundDescendantNodes.add(new DOM(addElement(foundNodes.item(n).getNode(), headPathElement)));
}
catch(ExDOMName x) {
throw new ExDOMName("Error initialising element name '"+headPathElement
+" at path "+getAbsolute(foundNodes.item(n).getNode())
);
}
}
}
foundNodes.clear();
foundNodes.addAll(foundDescendantNodes);
}
return foundNodes;
}
示例8: isAttached
import nu.xom.Node; //导入方法依赖的package包/类
/**
* Checks that pNode is still attached to a document. If it is not this indicates the node has been removed from its
* original tree, or was never attached to one.
* @param pNode
* @return True if still attached, false if not.
*/
@Override
public boolean isAttached(Node pNode){
return pNode.getDocument() != null;
}