本文整理匯總了Java中org.w3c.dom.Node.getNodeType方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.getNodeType方法的具體用法?Java Node.getNodeType怎麽用?Java Node.getNodeType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.w3c.dom.Node
的用法示例。
在下文中一共展示了Node.getNodeType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseConnectionFactory
import org.w3c.dom.Node; //導入方法依賴的package包/類
protected void parseConnectionFactory(Context context, Node node) {
ConnectionFactoryConfiguration connectionFactoryConfiguration = new ConnectionFactoryConfiguration();
context.setConnectionFactoryConfiguration(connectionFactoryConfiguration);
Properties attributes = parseAttributes(node);
String type = attributes.getProperty("type"); //$NON-NLS-1$
if (stringHasValue(type)) {
connectionFactoryConfiguration.setConfigurationType(type);
}
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseProperty(connectionFactoryConfiguration, childNode);
}
}
}
示例2: lengthUnknownElement
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Method lengthUnknownElement
* NOTE possibly buggy.
* @return the number of the UnknownElement tags
*/
public int lengthUnknownElement() {
int res = 0;
NodeList nl = this.constructionElement.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Node current = nl.item(i);
/**
* $todo$ using this method, we don't see unknown Elements
* from Signature NS; revisit
*/
if ((current.getNodeType() == Node.ELEMENT_NODE)
&& current.getNamespaceURI().equals(Constants.SignatureSpecNS)) {
res++;
}
}
return res;
}
示例3: getStrFromNode
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Method getStrFromNode
*
* @param xpathnode
* @return the string for the node.
*/
public static String getStrFromNode(Node xpathnode) {
if (xpathnode.getNodeType() == Node.TEXT_NODE) {
// we iterate over all siblings of the context node because eventually,
// the text is "polluted" with pi's or comments
StringBuilder sb = new StringBuilder();
for (Node currentSibling = xpathnode.getParentNode().getFirstChild();
currentSibling != null;
currentSibling = currentSibling.getNextSibling()) {
if (currentSibling.getNodeType() == Node.TEXT_NODE) {
sb.append(((Text) currentSibling).getData());
}
}
return sb.toString();
} else if (xpathnode.getNodeType() == Node.ATTRIBUTE_NODE) {
return ((Attr) xpathnode).getNodeValue();
} else if (xpathnode.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
return ((ProcessingInstruction) xpathnode).getNodeValue();
}
return null;
}
示例4: getLastChildElementNS
import org.w3c.dom.Node; //導入方法依賴的package包/類
/** Finds and returns the last child node with the given qualified name. */
public static Element getLastChildElementNS(Node parent,
String[][] elemNames) {
// search for node
Node child = parent.getLastChild();
while (child != null) {
if (child.getNodeType() == Node.ELEMENT_NODE) {
for (int i = 0; i < elemNames.length; i++) {
String uri = child.getNamespaceURI();
if (uri != null && uri.equals(elemNames[i][0]) &&
child.getLocalName().equals(elemNames[i][1])) {
return (Element)child;
}
}
}
child = child.getPreviousSibling();
}
// not found
return null;
}
示例5: next
import org.w3c.dom.Node; //導入方法依賴的package包/類
public int next() throws XMLStreamException {
while(true) {
int r = _next();
switch (r) {
case CHARACTERS:
// if we are currently at text node, make sure that this is a meaningful text node.
Node prev = _current.getPreviousSibling();
if(prev!=null && prev.getNodeType()==Node.TEXT_NODE)
continue; // nope. this is just a continuation of previous text that should be invisible
Text t = (Text)_current;
wholeText = t.getWholeText();
if(wholeText.length()==0)
continue; // nope. this is empty text.
return CHARACTERS;
case START_ELEMENT:
splitAttributes();
return START_ELEMENT;
default:
return r;
}
}
}
示例6: getLastChild
import org.w3c.dom.Node; //導入方法依賴的package包/類
/** Internal function.
* Return the last child Node, from the input node
* after applying filter, whatToshow.
* The current node is not consulted or set.
*/
Node getLastChild(Node node) {
if (node == null) return null;
if ( !fEntityReferenceExpansion
&& node.getNodeType() == Node.ENTITY_REFERENCE_NODE)
return null;
Node newNode = node.getLastChild();
if (newNode == null) return null;
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP
&& newNode.hasChildNodes())
{
Node lChild = getLastChild(newNode);
if (lChild == null) {
return getPreviousSibling(newNode, node);
}
return lChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getPreviousSibling(newNode, node);
}
}
示例7: getChild
import org.w3c.dom.Node; //導入方法依賴的package包/類
/** Get the first direct child with a given type
*/
public static Node getChild( Node parent, int type ) {
Node n=parent.getFirstChild();
while( n!=null && type != n.getNodeType() ) {
n=n.getNextSibling();
}
if( n==null ) return null;
return n;
}
示例8: getPrivateKeyFromStaticResolvers
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Searches the library wide KeyResolvers for Private keys
*
* @return the private key contained in this KeyInfo
* @throws KeyResolverException
*/
PrivateKey getPrivateKeyFromStaticResolvers() throws KeyResolverException {
Iterator<KeyResolverSpi> it = KeyResolver.iterator();
while (it.hasNext()) {
KeyResolverSpi keyResolver = it.next();
keyResolver.setSecureValidation(secureValidation);
Node currentChild = this.constructionElement.getFirstChild();
String uri = this.getBaseURI();
while (currentChild != null) {
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
// not using StorageResolvers at the moment
// since they cannot return private keys
PrivateKey pk =
keyResolver.engineLookupAndResolvePrivateKey(
(Element) currentChild, uri, null
);
if (pk != null) {
return pk;
}
}
currentChild = currentChild.getNextSibling();
}
}
return null;
}
示例9: getValueForNode
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Retrieves the text value from a node's child text node.
*/
static String getValueForNode(Node node, String defaultValue)
{
String value = null;
if( node != null )
{
switch( node.getNodeType() )
{
case Node.ELEMENT_NODE: {
Node textNode = node.getFirstChild();
if( textNode != null )
{
value = textNode.getNodeValue();
}
break;
}
case Node.ATTRIBUTE_NODE: {
value = node.getNodeValue();
break;
}
default:
break;
}
}
if( value == null )
{
return defaultValue;
}
else
{
return value;
}
}
示例10: getVictimCoordinateZ
import org.w3c.dom.Node; //導入方法依賴的package包/類
private String getVictimCoordinateZ(Element info, String tagcoordinate, String tagdimension){
String valuez = "";
NodeList coordinateNmElmntLst = info.getElementsByTagName(tagcoordinate);
Node coordinateNode = coordinateNmElmntLst.item(0);
if (coordinateNode.getNodeType() == Node.ELEMENT_NODE){
Element coorInfo = (Element) coordinateNode;
//Obtain information about y coordinate for the current victim
NodeList zNmElmntLst = coorInfo.getElementsByTagName(tagdimension);
Element zNmElmnt = (Element) zNmElmntLst.item(0);
NodeList zNm = zNmElmnt.getChildNodes();
valuez = ((Node)zNm.item(0)).getNodeValue();
}
return valuez;
}
示例11: getChild
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Get the first direct child with a given type
*/
public static Node getChild(Node parent, int type) {
Node n = parent.getFirstChild();
while (n != null && type != n.getNodeType()) {
n = n.getNextSibling();
}
if (n == null)
return null;
return n;
}
示例12: _ProcessNode
import org.w3c.dom.Node; //導入方法依賴的package包/類
private static void _ProcessNode(Node n, int level) throws Exception {
n.getAttributes();
n.getChildNodes();
// At this point, for JVM 1.6 and Xerces <= 1.3.1,
// Test-XML.xml::mytest:Y's attribute is (already) bad.
switch (n.getNodeType()) {
case Node.TEXT_NODE:
String str = n.getNodeValue().trim();
/* ...Only print non-empty strings... */
if (str.length() > 0) {
String valStr = n.getNodeValue();
_Println(valStr, level);
}
break;
case Node.COMMENT_NODE:
break;
default: {
String nodeNameStr = n.getNodeName();
_Println(nodeNameStr + " (" + n.getClass() + "):", level);
/* ...Print children... */
_ProcessChildren(n, level);
/* ...Print optional node attributes... */
_PrintAttributes(n, level);
}
}
}
示例13: enabled
import org.w3c.dom.Node; //導入方法依賴的package包/類
public Enumeration enabled(GrammarEnvironment ctx) {
Enumeration en = ctx.getDocumentChildren();
while (en.hasMoreElements()) {
Node next = (Node) en.nextElement();
if (next.getNodeType() == next.DOCUMENT_TYPE_NODE) {
return org.openide.util.Enumerations.singleton (next);
}
}
return null;
}
示例14: configure
import org.w3c.dom.Node; //導入方法依賴的package包/類
/**
* Performs custom configuration for this database object.
*/
public void configure(Element element) throws Exception {
super.configure(element);
String version = element.getAttribute("version");
if (version == null) {
String s = XMLUtils.prettyPrintDOM(element);
EngineException ee = new EngineException("Unable to find version number for the database object \"" + getName() + "\".\nXML data: " + s);
throw ee;
}
if (VersionUtils.compare(version, "1.2.2") <= 0) {
NodeList properties = element.getElementsByTagName("property");
Element propValue = (Element) XMLUtils.findNodeByAttributeValue(properties, "name", "removeFields");
Node xmlNode = null;
NodeList nl = propValue.getChildNodes();
int len_nl = nl.getLength();
Boolean bRemoveFields = null;
for (int j = 0 ; j < len_nl ; j++) {
xmlNode = nl.item(j);
if (xmlNode.getNodeType() == Node.ELEMENT_NODE) {
bRemoveFields = (Boolean) XMLUtils.readObjectFromXml((Element) xmlNode);
continue;
}
}
setSelectionType((bRemoveFields == null) ? "[^(field)]" : (bRemoveFields.booleanValue() ? "" : "[^(field)]"));
hasChanged = true;
Engine.logBeans.warn("[RemoveBlocks] The object \"" + getName() + "\" has been updated to version 1.2.3");
}
}
示例15: getNext
import org.w3c.dom.Node; //導入方法依賴的package包/類
/** Get the next sibling with the same name and type
*/
public static Node getNext( Node current ) {
String name=current.getNodeName();
int type=current.getNodeType();
return getNext( current, name, type);
}