Tabnine Logo
Node.getNodeType
Code IndexAdd Tabnine to your IDE (free)

How to use
getNodeType
method
in
org.w3c.dom.Node

Best Java code snippets using org.w3c.dom.Node.getNodeType (Showing top 20 results out of 14,625)

Refine searchRefine arrow

  • NodeList.item
  • NodeList.getLength
  • Node.getChildNodes
  • Node.getNodeValue
  • Node.getNodeName
  • Element.getChildNodes
origin: skylot/jadx

private void parse(Document doc) {
  NodeList nodeList = doc.getChildNodes();
  for (int count = 0; count < nodeList.getLength(); count++) {
    Node node = nodeList.item(count);
    if (node.getNodeType() == Node.ELEMENT_NODE
        && node.hasChildNodes()) {
      parseAttrList(node.getChildNodes());
    }
  }
}
origin: pmd/pmd

private static boolean isElementNode(Node node, String name) {
  return node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals(name);
}
origin: libgdx/libgdx

private void addToDependencyMapFromXML (Map<String, List<ExternalExtensionDependency>> dependencies, Element eElement, String platform) {
  if (eElement.getElementsByTagName(platform).item(0) != null) {
    Element project = (Element)eElement.getElementsByTagName(platform).item(0);
    ArrayList<ExternalExtensionDependency> deps = new ArrayList<ExternalExtensionDependency>();
    if (project.getTextContent().trim().equals("")) {
      // No dependencies required
    } else if (project.getTextContent().trim().equals("null")) {
      // Not supported
      deps = null;
    } else {
      NodeList nList = project.getElementsByTagName("dependency");
      for (int i = 0; i < nList.getLength(); i++) {
        Node nNode = nList.item(i);
        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
          Element dependencyNode = (Element)nNode;
          boolean external = Boolean.parseBoolean(dependencyNode.getAttribute("external"));
          deps.add(new ExternalExtensionDependency(dependencyNode.getTextContent(), external));
        }
      }
    }
    dependencies.put(platform, deps);
  }
}
origin: Tencent/tinker

if (node.getNodeType() != Node.ELEMENT_NODE) {
  continue;
String resourceType = node.getNodeName();
if (resourceType.equals(ITEM_TAG)) {
  resourceType = node.getAttributes().getNamedItem("type").getNodeValue();
  if (resourceType.equals("id")) {
    resourceCollector.addIgnoreId(node.getAttributes().getNamedItem("name").getNodeValue());
origin: groovy/groovy-core

public static String text(Node node) {
  if (node.getNodeType() == Node.TEXT_NODE || node.getNodeType() == Node.CDATA_SECTION_NODE) {
    return node.getNodeValue();
  }
  if (node.hasChildNodes()) {
    return text(node.getChildNodes());
  }
  return "";
}
origin: oracle/opengrok

private String getValue(Node node) {
  if (node == null) {
    return null;
  }
  StringBuilder sb = new StringBuilder();
  Node n = node.getFirstChild();
  while (n != null) {
    if (n.getNodeType() == Node.TEXT_NODE) {
      sb.append(n.getNodeValue());
    }
    n = n.getNextSibling();
  }
  return sb.toString();
}
origin: Tencent/tinker

private void readPackageConfigFromXml(Node node) throws IOException {
  NodeList childNodes = node.getChildNodes();
  if (childNodes.getLength() > 0) {
    for (int j = 0, n = childNodes.getLength(); j < n; j++) {
      Node child = childNodes.item(j);
      if (child.getNodeType() == Node.ELEMENT_NODE) {
        Element check = (Element) child;
        String tagName = check.getTagName();
        String value = check.getAttribute(ATTR_VALUE);
        String name = check.getAttribute(ATTR_NAME);
        if (tagName.equals(ATTR_CONFIG_FIELD)) {
          mPackageFields.put(name, value);
        } else {
          System.err.println("unknown package config tag " + tagName);
        }
      }
    }
  }
}
origin: stanfordnlp/CoreNLP

/**
 * Reconstructs the resource from the XML file
 */
@SuppressWarnings("unchecked")
public SsurgeonWordlist(Element rootElt) {
 id = rootElt.getAttribute("id");
 NodeList wordEltNL = rootElt.getElementsByTagName(WORD_ELT);
 for (int i=0; i<wordEltNL.getLength(); i++) {
   Node node = wordEltNL.item(i);
   if (node.getNodeType() == Node.ELEMENT_NODE) {
     String word = Ssurgeon.getEltText((Element) node);
     words.add(word);
   }
 }    
}

origin: xalan/xalan

/**
 * Given a node, determine if it is a namespace node.
 * 
 * @param node 
 * 
 * @return boolean Returns true if this is a namespace node; otherwise, returns false.
 */
 private boolean isNamespaceNode(Node node) {
  
   if ((null != node) && 
     (node.getNodeType() == Node.ATTRIBUTE_NODE) &&
     (node.getNodeName().startsWith("xmlns:") || node.getNodeName().equals("xmlns"))) {
    return true;   
   } else {
    return false;
   }
 }
  
origin: com.sun.xml.bind/jaxb-impl

private void visit( Node n ) throws SAXException {
  setCurrentLocation( n );
  
  // if a case statement gets too big, it should be made into a separate method.
  switch(n.getNodeType()) {
  case Node.CDATA_SECTION_NODE:
  case Node.TEXT_NODE:
    String value = n.getNodeValue();
    receiver.characters( value.toCharArray(), 0, value.length() );
    break;
  case Node.ELEMENT_NODE:
    visit( (Element)n );
    break;
  case Node.ENTITY_REFERENCE_NODE:
    receiver.skippedEntity(n.getNodeName());
    break;
  case Node.PROCESSING_INSTRUCTION_NODE:
    ProcessingInstruction pi = (ProcessingInstruction)n;
    receiver.processingInstruction(pi.getTarget(),pi.getData());
    break;
  }
}

origin: androidquery/androidquery

private String text(Node n){
  
  String text = null;
  
  switch(n.getNodeType()){
    case Node.TEXT_NODE:
      text = n.getNodeValue();
      if(text != null) text = text.trim();
      break;
    case Node.CDATA_SECTION_NODE:
      text = n.getNodeValue();
      break;
    default:
      //AQUtility.debug("unknown", n);
  }
  
  if(text == null) text = "";
  
  return text;
  
}

origin: pmd/pmd

  private static String parseTextNode(Node exampleNode) {
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < exampleNode.getChildNodes().getLength(); i++) {
      Node node = exampleNode.getChildNodes().item(i);
      if (node.getNodeType() == Node.CDATA_SECTION_NODE || node.getNodeType() == Node.TEXT_NODE) {
        buffer.append(node.getNodeValue());
      }
    }
    return buffer.toString().trim();
  }
}
origin: stanfordnlp/CoreNLP

/**
 * For the given element, finds the first child Element with the given tag.
 */
private static Element getFirstTag(Element element, String tag) {
 try {
  NodeList nodeList = element.getElementsByTagName(tag);
  if (nodeList.getLength() == 0) return null;
  for (int i=0; i < nodeList.getLength(); i++) {
   Node node = nodeList.item(i);
   if (node.getNodeType() == Node.ELEMENT_NODE)
    return (Element) node;
  }
 } catch (Exception e) {
  log.warning("Error getting first tag "+tag+" under element="+element);
 }
 return null;
}
origin: org.freemarker/freemarker

void outputContent(NamedNodeMap nodes, StringBuilder buf) {
  for (int i = 0; i < nodes.getLength(); ++i) {
    Node n = nodes.item(i);
    if (n.getNodeType() != Node.ATTRIBUTE_NODE 
      || (!n.getNodeName().startsWith("xmlns:") && !n.getNodeName().equals("xmlns"))) { 
      outputContent(n, buf);
    }
  }
}
 
origin: groovy/groovy-core

public static String toString(Object o) {
  if (o instanceof Node) {
    if (((Node) o).getNodeType() == Node.TEXT_NODE) {
      return ((Node) o).getNodeValue();
    }
  }
  if (o instanceof NodeList) {
    return toString((NodeList) o);
  }
  return o.toString();
}
origin: hibernate/hibernate-orm

private static String extractContent(Element element, String defaultStr) {
  if ( element == null ) {
    return defaultStr;
  }
  NodeList children = element.getChildNodes();
  StringBuilder result = new StringBuilder("");
  for ( int i = 0; i < children.getLength() ; i++ ) {
    if ( children.item( i ).getNodeType() == Node.TEXT_NODE ||
        children.item( i ).getNodeType() == Node.CDATA_SECTION_NODE ) {
      result.append( children.item( i ).getNodeValue() );
    }
  }
  return result.toString().trim();
}
origin: libgdx/libgdx

private void writeUpdatedTMX (TiledMap tiledMap, FileHandle tmxFileHandle) throws IOException {
  Document doc;
  DocumentBuilder docBuilder;
  DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
  try {
    docBuilder = docFactory.newDocumentBuilder();
    doc = docBuilder.parse(tmxFileHandle.read());
    Node map = doc.getFirstChild();
    while (map.getNodeType() != Node.ELEMENT_NODE || map.getNodeName() != "map") {
      if ((map = map.getNextSibling()) == null) {
        throw new GdxRuntimeException("Couldn't find map node!");
      }
    }
    setProperty(doc, map, "atlas", settings.tilesetOutputDirectory + "/" + settings.atlasOutputName + ".atlas");
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    DOMSource source = new DOMSource(doc);
    outputDir.mkdirs();
    StreamResult result = new StreamResult(new File(outputDir, tmxFileHandle.name()));
    transformer.transform(source, result);
  } catch (ParserConfigurationException e) {
    throw new RuntimeException("ParserConfigurationException: " + e.getMessage());
  } catch (SAXException e) {
    throw new RuntimeException("SAXException: " + e.getMessage());
  } catch (TransformerConfigurationException e) {
    throw new RuntimeException("TransformerConfigurationException: " + e.getMessage());
  } catch (TransformerException e) {
    throw new RuntimeException("TransformerException: " + e.getMessage());
  }
}
origin: Tencent/tinker

private void readLibPatternsFromXml(Node node) throws IOException {
  NodeList childNodes = node.getChildNodes();
  if (childNodes.getLength() > 0) {
    for (int j = 0, n = childNodes.getLength(); j < n; j++) {
      Node child = childNodes.item(j);
      if (child.getNodeType() == Node.ELEMENT_NODE) {
        Element check = (Element) child;
        String tagName = check.getTagName();
        String value = check.getAttribute(ATTR_VALUE);
        if (tagName.equals(ATTR_PATTERN)) {
          addToPatterns(value, mSoFilePattern);
        } else {
          System.err.println("unknown dex tag " + tagName);
        }
      }
    }
  }
}
origin: libgdx/libgdx

private void writeUpdatedTMX (TiledMap tiledMap, FileHandle tmxFileHandle) throws IOException {
  Document doc;
  DocumentBuilder docBuilder;
  DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
  try {
    docBuilder = docFactory.newDocumentBuilder();
    doc = docBuilder.parse(tmxFileHandle.read());
    Node map = doc.getFirstChild();
    while (map.getNodeType() != Node.ELEMENT_NODE || map.getNodeName() != "map") {
      if ((map = map.getNextSibling()) == null) {
        throw new GdxRuntimeException("Couldn't find map node!");
      }
    }
    setProperty(doc, map, "atlas", settings.tilesetOutputDirectory + "/" + settings.atlasOutputName + ".atlas");
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    DOMSource source = new DOMSource(doc);
    outputDir.mkdirs();
    StreamResult result = new StreamResult(new File(outputDir, tmxFileHandle.name()));
    transformer.transform(source, result);
  } catch (ParserConfigurationException e) {
    throw new RuntimeException("ParserConfigurationException: " + e.getMessage());
  } catch (SAXException e) {
    throw new RuntimeException("SAXException: " + e.getMessage());
  } catch (TransformerConfigurationException e) {
    throw new RuntimeException("TransformerConfigurationException: " + e.getMessage());
  } catch (TransformerException e) {
    throw new RuntimeException("TransformerException: " + e.getMessage());
  }
}
origin: spring-projects/spring-framework

public BeanDefinitionHolder decorateBeanDefinitionIfRequired(
    Element ele, BeanDefinitionHolder definitionHolder, @Nullable BeanDefinition containingBd) {
  BeanDefinitionHolder finalDefinition = definitionHolder;
  // Decorate based on custom attributes first.
  NamedNodeMap attributes = ele.getAttributes();
  for (int i = 0; i < attributes.getLength(); i++) {
    Node node = attributes.item(i);
    finalDefinition = decorateIfRequired(node, finalDefinition, containingBd);
  }
  // Decorate based on custom nested elements.
  NodeList children = ele.getChildNodes();
  for (int i = 0; i < children.getLength(); i++) {
    Node node = children.item(i);
    if (node.getNodeType() == Node.ELEMENT_NODE) {
      finalDefinition = decorateIfRequired(node, finalDefinition, containingBd);
    }
  }
  return finalDefinition;
}
org.w3c.domNodegetNodeType

Javadoc

A code representing the type of the underlying object, as defined above.

Popular methods of Node

  • getNodeName
    The name of this node, depending on its type; see the table above.
  • getNodeValue
    The value of this node, depending on its type; see the table above. When it is defined to be null, s
  • getChildNodes
    A NodeList that contains all children of this node. If there are no children, this is a NodeList con
  • getTextContent
    This attribute returns the text content of this node and its descendants. When it is defined to be n
  • getAttributes
    A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
  • getFirstChild
    The first child of this node. If there is no such node, this returnsnull.
  • getLocalName
    Returns the local part of the qualified name of this node. For nodes of any type other than ELEMENT_
  • getParentNode
    The parent of this node. All nodes, except Attr,Document, DocumentFragment, Entity, and Notation may
  • getNextSibling
    The node immediately following this node. If there is no such node, this returns null.
  • appendChild
    Adds the node newChild to the end of the list of children of this node. If the newChild is already
  • getNamespaceURI
    The namespace URI of this node, or null if it is unspecified. This is not a computed value that is t
  • getOwnerDocument
    The Document object associated with this node. This is also the Document object used to create new n
  • getNamespaceURI,
  • getOwnerDocument,
  • removeChild,
  • hasChildNodes,
  • getPrefix,
  • setNodeValue,
  • getPreviousSibling,
  • insertBefore,
  • cloneNode

Popular in Java

  • Making http post requests using okhttp
  • onCreateOptionsMenu (Activity)
  • getExternalFilesDir (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Menu (java.awt)
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Notification (javax.management)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now