org.w3c.dom.Node.getUserData()方法的使用及代码示例

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

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

Node.getUserData介绍

[英]Retrieves the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key.
[中]检索与此节点上的密钥关联的对象。必须先通过使用相同的键调用setUserData将对象设置到此节点。

代码示例

代码示例来源:origin: pmd/pmd

  1. @Override
  2. public Object getUserData(String key) {
  3. return node.getUserData(key);
  4. }

代码示例来源:origin: stackoverflow.com

  1. // XmlTest.java
  2. import java.io.ByteArrayInputStream;
  3. import java.io.InputStream;
  4. import org.w3c.dom.Document;
  5. import org.w3c.dom.Node;
  6. public class XmlTest {
  7. public static void main(final String[] args) throws Exception {
  8. String xmlString = "<foo>\n"
  9. + " <bar>\n"
  10. + " <moo>Hello World!</moo>\n"
  11. + " </bar>\n"
  12. + "</foo>";
  13. InputStream is = new ByteArrayInputStream(xmlString.getBytes());
  14. Document doc = PositionalXMLReader.readXML(is);
  15. is.close();
  16. Node node = doc.getElementsByTagName("moo").item(0);
  17. System.out.println("Line number: " + node.getUserData("lineNumber"));
  18. }
  19. }

代码示例来源:origin: jamesagnew/hapi-fhir

  1. @Override
  2. public void handle(short operation, String key, Object data,
  3. Node src, Node dst) {
  4. if (src != null && dst != null) {
  5. XmlLocationData locatonData = (XmlLocationData)
  6. src.getUserData(XmlLocationData.LOCATION_DATA_KEY);
  7. if (locatonData != null) {
  8. dst.setUserData(XmlLocationData.LOCATION_DATA_KEY,
  9. locatonData, dataHandler);
  10. }
  11. }
  12. }
  13. }

代码示例来源:origin: jamesagnew/hapi-fhir

  1. private int line(Node node) {
  2. XmlLocationData loc = (XmlLocationData) node.getUserData(XmlLocationData.LOCATION_DATA_KEY);
  3. return loc == null ? 0 : loc.getStartLine();
  4. }

代码示例来源:origin: jamesagnew/hapi-fhir

  1. @Override
  2. public void handle(short operation, String key, Object data,
  3. Node src, Node dst) {
  4. if (src != null && dst != null) {
  5. XmlLocationData locatonData = (XmlLocationData)
  6. src.getUserData(XmlLocationData.LOCATION_DATA_KEY);
  7. if (locatonData != null) {
  8. dst.setUserData(XmlLocationData.LOCATION_DATA_KEY,
  9. locatonData, dataHandler);
  10. }
  11. }
  12. }
  13. }

代码示例来源:origin: jamesagnew/hapi-fhir

  1. private int line(Node node) {
  2. XmlLocationData loc = (XmlLocationData) node.getUserData(XmlLocationData.LOCATION_DATA_KEY);
  3. return loc == null ? 0 : loc.getStartLine();
  4. }

代码示例来源:origin: jamesagnew/hapi-fhir

  1. private int col(Node node) {
  2. XmlLocationData loc = (XmlLocationData) node.getUserData(XmlLocationData.LOCATION_DATA_KEY);
  3. return loc == null ? 0 : loc.getStartColumn();
  4. }

代码示例来源:origin: jamesagnew/hapi-fhir

  1. @Override
  2. public void handle(short operation, String key, Object data,
  3. Node src, Node dst) {
  4. if (src != null && dst != null) {
  5. XmlLocationData locatonData = (XmlLocationData)
  6. src.getUserData(XmlLocationData.LOCATION_DATA_KEY);
  7. if (locatonData != null) {
  8. dst.setUserData(XmlLocationData.LOCATION_DATA_KEY,
  9. locatonData, dataHandler);
  10. }
  11. }
  12. }
  13. }

代码示例来源:origin: jamesagnew/hapi-fhir

  1. private int col(Node node) {
  2. XmlLocationData loc = (XmlLocationData) node.getUserData(XmlLocationData.LOCATION_DATA_KEY);
  3. return loc == null ? 0 : loc.getStartColumn();
  4. }

代码示例来源:origin: net.sf.jmatchparser/jMatchParser-util

  1. /**
  2. * Get the column number embedded in a node.
  3. *
  4. * @param node
  5. * the node
  6. * @return the column number, or -1 if none was embedded
  7. */
  8. public static int getColumnNumber(Node node) {
  9. Integer col = (Integer) node.getUserData(LocationAwareDOMParser.COLUMN_NUMBER);
  10. return col == null ? -1 : col;
  11. }
  12. }

代码示例来源:origin: ru.d-shap/form-model

  1. @Override
  2. public Object getElementUserData(final Element element, final String key) {
  3. Node currentNode = element;
  4. while (currentNode != null) {
  5. Object userData = currentNode.getUserData(key);
  6. if (userData != null) {
  7. return userData;
  8. }
  9. currentNode = currentNode.getParentNode();
  10. }
  11. return null;
  12. }

代码示例来源:origin: org.mule.modules/mule-module-spring-config

  1. @Override
  2. public void handle(short operation, String key, Object data, Node src, Node dst)
  3. {
  4. if (operation == NODE_IMPORTED || operation == NODE_CLONED)
  5. {
  6. dst.setUserData(METADATA_ANNOTATIONS_KEY, src.getUserData(METADATA_ANNOTATIONS_KEY), this);
  7. }
  8. }
  9. };

代码示例来源:origin: org.mule.runtime/mule-module-spring-config

  1. @Override
  2. public void handle(short operation, String key, Object data, Node src, Node dst) {
  3. if (operation == NODE_IMPORTED || operation == NODE_CLONED) {
  4. dst.setUserData(METADATA_ANNOTATIONS_KEY, src.getUserData(METADATA_ANNOTATIONS_KEY), this);
  5. }
  6. }
  7. };

代码示例来源:origin: org.apache.xalan/com.springsource.org.apache.xalan

  1. /**
  2. * Retrieves the object associated to a key on a this node. The object
  3. * must first have been set to this node by calling
  4. * <code>setUserData</code> with the same key.
  5. * @param key The key the object is associated to.
  6. * @return Returns the <code>DOMObject</code> associated to the given key
  7. * on this node, or <code>null</code> if there was none.
  8. * @since DOM Level 3
  9. */
  10. public Object getUserData(String key) {
  11. return getOwnerDocument().getUserData( key);
  12. }

代码示例来源:origin: org.apache.xalan/com.springsource.org.apache.xalan

  1. /**
  2. * Retrieves the object associated to a key on a this node. The object
  3. * must first have been set to this node by calling
  4. * <code>setUserData</code> with the same key.
  5. * @param key The key the object is associated to.
  6. * @return Returns the <code>DOMObject</code> associated to the given key
  7. * on this node, or <code>null</code> if there was none.
  8. * @since DOM Level 3
  9. */
  10. public Object getUserData(String key) {
  11. return getOwnerDocument().getUserData( key);
  12. }

代码示例来源:origin: org.apache.xalan/com.springsource.org.apache.xalan

  1. /**
  2. * Retrieves the object associated to a key on a this node. The object
  3. * must first have been set to this node by calling
  4. * <code>setUserData</code> with the same key.
  5. * @param key The key the object is associated to.
  6. * @return Returns the <code>DOMObject</code> associated to the given key
  7. * on this node, or <code>null</code> if there was none.
  8. * @since DOM Level 3
  9. */
  10. public Object getUserData(String key) {
  11. return getOwnerDocument().getUserData( key);
  12. }

代码示例来源:origin: apache/cxf

  1. public Location getLocation() {
  2. try {
  3. Object o = getCurrentNode().getUserData("location");
  4. if (o instanceof Location) {
  5. return (Location)o;
  6. }
  7. } catch (Throwable ex) {
  8. //ignore, probably not DOM level 3
  9. }
  10. return super.getLocation();
  11. }

代码示例来源:origin: org.apache.cxf/cxf-core

  1. public Location getLocation() {
  2. try {
  3. Object o = getCurrentNode().getUserData("location");
  4. if (o instanceof Location) {
  5. return (Location)o;
  6. }
  7. } catch (Throwable ex) {
  8. //ignore, probably not DOM level 3
  9. }
  10. return super.getLocation();
  11. }

代码示例来源:origin: org.apache.cxf/cxf-api

  1. public Location getLocation() {
  2. try {
  3. Object o = getCurrentNode().getUserData("location");
  4. if (o instanceof Location) {
  5. return (Location)o;
  6. }
  7. } catch (Throwable ex) {
  8. //ignore, probably not DOM level 3
  9. }
  10. return super.getLocation();
  11. }

代码示例来源:origin: org.apache.cxf/cxf-common-utilities

  1. public Location getLocation() {
  2. try {
  3. Object o = getCurrentNode().getUserData("location");
  4. if (o instanceof Location) {
  5. return (Location)o;
  6. }
  7. } catch (Throwable ex) {
  8. //ignore, probably not DOM level 3
  9. }
  10. return super.getLocation();
  11. }

相关文章