本文整理匯總了Java中org.w3c.dom.Node.setUserData方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.setUserData方法的具體用法?Java Node.setUserData怎麽用?Java Node.setUserData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.w3c.dom.Node
的用法示例。
在下文中一共展示了Node.setUserData方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setOutputUserData
import org.w3c.dom.Node; //導入方法依賴的package包/類
private static Node setOutputUserData(Node node, Object value, boolean recurse) {
if (node != null) {
// set output mode as userdata (element or attribute)
node.setUserData(Step.NODE_USERDATA_OUTPUT, value, null);
// recurse on element child nodes only
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (recurse && node.hasChildNodes()) {
NodeList list = node.getChildNodes();
for (int i=0; i<list.getLength(); i++) {
setOutputUserData(list.item(i), value, recurse);
}
}
}
}
return node;
}
示例2: findLineNumbers
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* This is a CRUDE INEXACT HACK to decorate the DOM with some kind of line number
* information for elements. It's inexact because by the time we get the DOM we
* already have lost all the information about whitespace between attributes.
* <p/>
* Also we don't even try to deal with \n vs \r vs \r\n insanity. This only counts
* the \n occurring in text nodes to determine line advances, which is clearly flawed.
* <p/>
* However it's good enough for testing, and we'll replace it by a PositionXmlParser
* once it's moved into com.android.util.
*/
private static int findLineNumbers(Node node, int line) {
for (; node != null; node = node.getNextSibling()) {
node.setUserData(DATA_LINE_NUMBER, Integer.valueOf(line), null /*handler*/);
if (node.getNodeType() == Node.TEXT_NODE) {
String text = node.getNodeValue();
if (text.length() > 0) {
for (int pos = 0; (pos = text.indexOf('\n', pos)) != -1; pos++) {
++line;
}
}
}
Node child = node.getFirstChild();
if (child != null) {
line = findLineNumbers(child, line);
}
}
return line;
}
示例3: importNode
import org.w3c.dom.Node; //導入方法依賴的package包/類
@Override
public org.w3c.dom.Node importNode(Node importedNode, boolean deep)
throws DOMException {
Node domNode = getDomNode(importedNode);
final Node newNode = document.importNode(domNode, deep);
if (importedNode instanceof javax.xml.soap.Node) {
Node newSoapNode = createSoapNode(importedNode.getClass(), newNode);
newNode.setUserData(SAAJ_NODE, newSoapNode, null);
if (deep && importedNode.hasChildNodes()) {
NodeList childNodes = importedNode.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
registerChildNodes(childNodes.item(i), deep);
}
}
return newSoapNode;
}
registerChildNodes(newNode, deep);
return findIfPresent(newNode);
}
示例4: cloneNodeWithUserData
import org.w3c.dom.Node; //導入方法依賴的package包/類
private static Node cloneNodeWithUserData(Node node, boolean recurse) {
if (node != null) {
Object node_output = node.getUserData(Step.NODE_USERDATA_OUTPUT);
Node clonedNode = node.cloneNode(false);
clonedNode.setUserData(Step.NODE_USERDATA_OUTPUT, node_output, null);
if (node.getNodeType() == Node.ELEMENT_NODE) {
// attributes
NamedNodeMap attributeMap = clonedNode.getAttributes();
for (int i=0; i< attributeMap.getLength(); i++) {
Node clonedAttribute = attributeMap.item(i);
String attr_name = clonedAttribute.getNodeName();
Object attr_output = ((Element)node).getAttributeNode(attr_name).getUserData(Step.NODE_USERDATA_OUTPUT);
clonedAttribute.setUserData(Step.NODE_USERDATA_OUTPUT, attr_output, null);
}
// recurse on element child nodes only
if (recurse && node.hasChildNodes()) {
NodeList list = node.getChildNodes();
for (int i=0; i<list.getLength(); i++) {
Node clonedChild = cloneNodeWithUserData(list.item(i), recurse);
if (clonedChild != null) {
clonedNode.appendChild(clonedChild);
}
}
}
}
return clonedNode;
}
return null;
}
示例5: setSource
import org.w3c.dom.Node; //導入方法依賴的package包/類
public static void setSource(@NonNull Node node, @NonNull File source) {
//noinspection ConstantConditions
for (; node != null; node = node.getNextSibling()) {
short nodeType = node.getNodeType();
if (nodeType == Node.ELEMENT_NODE
|| nodeType == Node.COMMENT_NODE
|| nodeType == Node.DOCUMENT_NODE
|| nodeType == Node.CDATA_SECTION_NODE) {
node.setUserData(DATA_ORIGIN_FILE, source, null);
}
Node child = node.getFirstChild();
setSource(child, source);
}
}
示例6: setUserData
import org.w3c.dom.Node; //導入方法依賴的package包/類
private static void setUserData(Node node, XmlNode wrap) {
if (DOM_LEVEL_3) {
node.setUserData(USER_DATA_XMLNODE_KEY, wrap, wrap.events);
}
}
示例7: setFileFor
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Sets the file associated with the given node, if any
*/
public static void setFileFor(Node node, File file) {
node.setUserData(MergerXmlUtils.DATA_ORIGIN_FILE, file, null);
}
示例8: put
import org.w3c.dom.Node; //導入方法依賴的package包/類
public void put(@NotNull final Node node, final T value) {
node.setUserData(this.myName, value, null);
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:4,代碼來源:ValidateContextImpl.java
示例9: register
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Insert a mapping information for {@link org.w3c.dom.Node} - {@link javax.xml.soap.Node}.
*
* In SAAJ, elements in DOM are expected to be interfaces of SAAJ, on the other hand in JDKs Xerces,
* they are casted to internal impl classes. After removal of SAAJ dependency
* to JDKs internal classes elements in DOM can never be both of them.
*
* @param node SAAJ wrapper node for w3c DOM node
*/
public void register(javax.xml.soap.Node node) {
final Node domElement = getDomNode(node);
if (domElement.getUserData(SAAJ_NODE) != null) {
throw new IllegalStateException("Element " + domElement.getNodeName()
+ " is already registered");
}
domElement.setUserData(SAAJ_NODE, node, null);
}