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

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

本文整理了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

@Override
public Object getUserData(String key) {
  return node.getUserData(key);
}

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

// XmlTest.java

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import org.w3c.dom.Document;
import org.w3c.dom.Node;

public class XmlTest {
  public static void main(final String[] args) throws Exception {

    String xmlString = "<foo>\n"
             + "    <bar>\n"
             + "        <moo>Hello World!</moo>\n"
             + "    </bar>\n"
             + "</foo>";

    InputStream is = new ByteArrayInputStream(xmlString.getBytes());
    Document doc = PositionalXMLReader.readXML(is);
    is.close();

    Node node = doc.getElementsByTagName("moo").item(0);

    System.out.println("Line number: " + node.getUserData("lineNumber"));
  }
}

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

@Override
  public void handle(short operation, String key, Object data,
      Node src, Node dst) {
        if (src != null && dst != null) {
      XmlLocationData locatonData = (XmlLocationData)
          src.getUserData(XmlLocationData.LOCATION_DATA_KEY);
            if (locatonData != null) {
        dst.setUserData(XmlLocationData.LOCATION_DATA_KEY,
            locatonData, dataHandler);
      }
    }
  }
}

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

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

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

@Override
  public void handle(short operation, String key, Object data,
      Node src, Node dst) {
        if (src != null && dst != null) {
      XmlLocationData locatonData = (XmlLocationData)
          src.getUserData(XmlLocationData.LOCATION_DATA_KEY);
            if (locatonData != null) {
        dst.setUserData(XmlLocationData.LOCATION_DATA_KEY,
            locatonData, dataHandler);
      }
    }
  }
}

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

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

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

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

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

@Override
  public void handle(short operation, String key, Object data,
      Node src, Node dst) {
        if (src != null && dst != null) {
      XmlLocationData locatonData = (XmlLocationData)
          src.getUserData(XmlLocationData.LOCATION_DATA_KEY);
            if (locatonData != null) {
        dst.setUserData(XmlLocationData.LOCATION_DATA_KEY,
            locatonData, dataHandler);
      }
    }
  }
}

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

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

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

/**
   * Get the column number embedded in a node.
   * 
   * @param node
   *            the node
   * @return the column number, or -1 if none was embedded
   */
  public static int getColumnNumber(Node node) {
    Integer col = (Integer) node.getUserData(LocationAwareDOMParser.COLUMN_NUMBER);
    return col == null ? -1 : col;
  }
}

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

@Override
public Object getElementUserData(final Element element, final String key) {
  Node currentNode = element;
  while (currentNode != null) {
    Object userData = currentNode.getUserData(key);
    if (userData != null) {
      return userData;
    }
    currentNode = currentNode.getParentNode();
  }
  return null;
}

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

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

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

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

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

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

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

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

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

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

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

public Location getLocation() {
  try {
    Object o = getCurrentNode().getUserData("location");
    if (o instanceof Location) {
      return (Location)o;
    }
  } catch (Throwable ex) {
    //ignore, probably not DOM level 3
  }
  return super.getLocation();
}

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

public Location getLocation() {
  try {
    Object o = getCurrentNode().getUserData("location");
    if (o instanceof Location) {
      return (Location)o;
    }
  } catch (Throwable ex) {
    //ignore, probably not DOM level 3
  }
  return super.getLocation();
}

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

public Location getLocation() {
  try {
    Object o = getCurrentNode().getUserData("location");
    if (o instanceof Location) { 
      return (Location)o;
    }
  } catch (Throwable ex) {
    //ignore, probably not DOM level 3
  }
  return super.getLocation();
}

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

public Location getLocation() {
  try {
    Object o = getCurrentNode().getUserData("location");
    if (o instanceof Location) { 
      return (Location)o;
    }
  } catch (Throwable ex) {
    //ignore, probably not DOM level 3
  }
  return super.getLocation();
}

相关文章