本文整理匯總了Java中org.w3c.dom.Node.getUserData方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.getUserData方法的具體用法?Java Node.getUserData怎麽用?Java Node.getUserData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.w3c.dom.Node
的用法示例。
在下文中一共展示了Node.getUserData方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: extractXmlFilename
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Extracts the origin {@link File} that {@link #parseDocument(File, IMergerLog,
* ManifestMerger)} added to the XML document or the string added by
*
* @param xmlNode Any node from a document returned by {@link #parseDocument(File, IMergerLog,
* ManifestMerger)}.
* @return The {@link File} object used to create the document or null.
*/
@Nullable
static String extractXmlFilename(@Nullable Node xmlNode) {
if (xmlNode != null && xmlNode.getNodeType() != Node.DOCUMENT_NODE) {
xmlNode = xmlNode.getOwnerDocument();
}
if (xmlNode != null) {
Object data = xmlNode.getUserData(DATA_ORIGIN_FILE);
if (data instanceof File) {
return ((File) data).getPath();
}
data = xmlNode.getUserData(DATA_FILE_NAME);
if (data instanceof String) {
return (String) data;
}
}
return null;
}
示例2: findElementAtLine
import org.w3c.dom.Node; //導入方法依賴的package包/類
private Node findElementAtLine(int line, Node node) {
if(CAMEL_NODES_TAG.contains(node.getNodeName())) {
return node;
}
NodeList childNodes = node.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node childNode = childNodes.item(i);
String nodeLineStart = (String)childNode.getUserData(XmlLineNumberParser.LINE_NUMBER);
String nodeLineEnd = (String)childNode.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
// -1 is due to Camel XMLLineParser which is starting index at 1 although LSP is starting at 0
if (nodeLineStart != null && nodeLineEnd != null && isBetween(line, Integer.parseInt(nodeLineStart) - 1, Integer.parseInt(nodeLineEnd) - 1)) {
return findElementAtLine(line, childNode);
}
}
return null;
}
示例3: registerChildNodes
import org.w3c.dom.Node; //導入方法依賴的package包/類
public void registerChildNodes(Node parentNode, boolean deep) {
if (parentNode.getUserData(SAAJ_NODE) == null) {
if (parentNode instanceof Element) {
ElementFactory.createElement(this, (Element) parentNode);
} else if (parentNode instanceof CharacterData) {
switch (parentNode.getNodeType()) {
case CDATA_SECTION_NODE:
new CDATAImpl(this, (CharacterData) parentNode);
break;
case COMMENT_NODE:
new SOAPCommentImpl(this, (CharacterData) parentNode);
break;
case TEXT_NODE:
new SOAPTextImpl(this, (CharacterData) parentNode);
break;
}
}
}
if (deep) {
NodeList nodeList = parentNode.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node nextChild = nodeList.item(i);
registerChildNodes(nextChild, true);
}
}
}
示例4: getElement
import org.w3c.dom.Node; //導入方法依賴的package包/類
private static final Element getElement(Node node) {
for (Node n = node; n != null; n = n.getParentNode()) {
Object result = node.getUserData(ELEMENT_USER_DATA);
if (result != null) {
return (Element) result;
}
}
return null;
}
示例5: getElement
import org.w3c.dom.Node; //導入方法依賴的package包/類
private static final Element getElement(Node node) {
for (Node n = node; n != null; n = n.getParentNode()) {
Object result = node.getUserData(ELEMENT_USER_DATA);
if (result != null)
return (Element) result;
}
return null;
}
示例6: 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;
}
示例7: extractLineNumber
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Extracts the line number that {@link #findLineNumbers} added to the XML nodes.
*
* @param xmlNode Any node from a document returned by {@link #parseDocument(File, IMergerLog,
* ManifestMerger)}.
* @return The line number if found or 0.
*/
static int extractLineNumber(@Nullable Node xmlNode) {
if (xmlNode != null) {
Object data = xmlNode.getUserData(DATA_LINE_NUMBER);
if (data instanceof Integer) {
return ((Integer) data).intValue();
}
}
return 0;
}
示例8: find
import org.w3c.dom.Node; //導入方法依賴的package包/類
private javax.xml.soap.Node find(Node node, boolean required) {
if (node == null) {
return null;
}
if (node instanceof javax.xml.soap.Node) {
return (javax.xml.soap.Node) node;
}
final javax.xml.soap.Node found = (javax.xml.soap.Node) node.getUserData(SAAJ_NODE);
if (found == null && required) {
throw new IllegalArgumentException(MessageFormat.format("Cannot find SOAP wrapper for element {0}", node));
}
return found;
}
示例9: getUserData
import org.w3c.dom.Node; //導入方法依賴的package包/類
private static XmlNode getUserData(Node node) {
if (DOM_LEVEL_3) {
return (XmlNode)node.getUserData(USER_DATA_XMLNODE_KEY);
}
return null;
}
示例10: get
import org.w3c.dom.Node; //導入方法依賴的package包/類
public T get(@NotNull final Node node) {
//noinspection unchecked
return (T) node.getUserData(this.myName);
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:5,代碼來源:ValidateContextImpl.java
示例11: 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);
}
示例12: getFileFor
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Returns the file associated with the given specific node, if any.
* Note that this will not search upwards for parent nodes; it returns a
* file associated with this specific node, if any.
*/
@Nullable
public static File getFileFor(@NonNull Node node) {
return (File) node.getUserData(DATA_ORIGIN_FILE);
}