org.w3c.dom.NodeList

Here are the examples of the java api class org.w3c.dom.NodeList taken from open source projects.

1. SamlTest#testEncryptedXML()

Project: OWASP-WebScarab
File: SamlTest.java
@Test
public void testEncryptedXML() throws Exception {
    // setup
    DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    builderFactory.setNamespaceAware(true);
    DocumentBuilder builder = builderFactory.newDocumentBuilder();
    Document document = builder.parse(SamlTest.class.getResourceAsStream("/test-saml-response-encrypted-attribute.xml"));
    NodeList nodeList = document.getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:assertion", "EncryptedAttribute");
    assertEquals(1, nodeList.getLength());
    Element encryptedAttributeElement = (Element) nodeList.item(0);
    NodeList encryptedDataNodeList = encryptedAttributeElement.getElementsByTagNameNS("http://www.w3.org/2001/04/xmlenc#", "EncryptedData");
    assertEquals(1, encryptedDataNodeList.getLength());
    Element encryptedDataElement = (Element) encryptedDataNodeList.item(0);
    Init.init();
    XMLCipher xmlCipher = XMLCipher.getInstance(XMLCipher.AES_128);
    String aes128HexStr = "2a1e3d83f475ec3c007f487c5150a5f2";
    byte[] aes128Bytes = Hex.decode(aes128HexStr);
    SecretKeySpec secretKeySpec = new SecretKeySpec(aes128Bytes, "AES");
    xmlCipher.init(XMLCipher.DECRYPT_MODE, secretKeySpec);
    xmlCipher.doFinal(document, encryptedDataElement);
    LOG.debug("decrypted attribute: " + toString(encryptedAttributeElement));
    NodeList attributeNodeList = encryptedAttributeElement.getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:assertion", "Attribute");
    assertEquals(1, attributeNodeList.getLength());
}

2. SamlModel#hasDestinationIndication()

Project: OWASP-WebScarab
File: SamlModel.java
public boolean hasDestinationIndication(ConversationID id) {
    Document document = getSAMLDocument(id);
    if (null == document) {
        return false;
    }
    NodeList saml2ResponseNodeList = document.getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:protocol", "Response");
    if (0 != saml2ResponseNodeList.getLength()) {
        return hasDestinationIndicationSaml2Response((Element) saml2ResponseNodeList.item(0));
    }
    NodeList saml2AuthnRequestNodeList = document.getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:protocol", "AuthnRequest");
    if (0 != saml2AuthnRequestNodeList.getLength()) {
        return hasDestinationIndicationSaml2AuthnRequest((Element) saml2AuthnRequestNodeList.item(0));
    }
    NodeList saml1ResponseNodeList = document.getElementsByTagNameNS("urn:oasis:names:tc:SAML:1.0:protocol", "Response");
    if (0 != saml1ResponseNodeList.getLength()) {
        return hasDestinationIndicationSaml1Response((Element) saml1ResponseNodeList.item(0));
    }
    return false;
}

3. SamlModel#getSAMLVersion()

Project: OWASP-WebScarab
File: SamlModel.java
public int getSAMLVersion(ConversationID id) {
    Document document = getSAMLDocument(id);
    if (null == document) {
        return 0;
    }
    NodeList saml1ResponseNodeList = document.getElementsByTagNameNS("urn:oasis:names:tc:SAML:1.0:protocol", "Response");
    if (0 != saml1ResponseNodeList.getLength()) {
        return SAML_VERSION_1_1;
    }
    NodeList saml2AuthnRequestNodeList = document.getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:protocol", "AuthnRequest");
    if (0 != saml2AuthnRequestNodeList.getLength()) {
        return SAML_VERSION_2;
    }
    NodeList saml2ResponseNodeList = document.getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:protocol", "Response");
    if (0 != saml2ResponseNodeList.getLength()) {
        return SAML_VERSION_2;
    }
    return 0;
}

4. XMLDocumentHelper#createElementMappingForNodes()

Project: commons-configuration
File: XMLDocumentHelper.java
/**
     * Creates the element mapping for the specified nodes and all their child
     * nodes.
     *
     * @param n1 node 1
     * @param n2 node 2
     * @param mapping the mapping to be filled
     */
private static void createElementMappingForNodes(Node n1, Node n2, Map<Node, Node> mapping) {
    mapping.put(n1, n2);
    NodeList childNodes1 = n1.getChildNodes();
    NodeList childNodes2 = n2.getChildNodes();
    int count = Math.min(childNodes1.getLength(), childNodes2.getLength());
    for (int i = 0; i < count; i++) {
        createElementMappingForNodes(childNodes1.item(i), childNodes2.item(i), mapping);
    }
}

5. DMLConfig#updateYarnMemorySettings()

Project: incubator-systemml
File: DMLConfig.java
/**
	 * 
	 * @param amMem
	 * @param mrMem
	 */
public void updateYarnMemorySettings(String amMem, String mrMem) {
    //app master memory
    NodeList list1 = _xmlRoot.getElementsByTagName(YARN_APPMASTERMEM);
    if (list1 != null && list1.getLength() > 0) {
        Element elem = (Element) list1.item(0);
        elem.getFirstChild().setNodeValue(String.valueOf(amMem));
    }
    //mapreduce memory
    NodeList list2 = _xmlRoot.getElementsByTagName(YARN_MAPREDUCEMEM);
    if (list2 != null && list2.getLength() > 0) {
        Element elem = (Element) list2.item(0);
        elem.getFirstChild().setNodeValue(String.valueOf(mrMem));
    }
}

6. XformsQueueProcessor#getPatientIdentifier()

Project: buendia
File: XformsQueueProcessor.java
private String getPatientIdentifier(Document doc) {
    NodeList elemList = doc.getDocumentElement().getElementsByTagName("patient");
    if (!(elemList != null && elemList.getLength() > 0))
        return null;
    Element patientNode = (Element) elemList.item(0);
    NodeList children = patientNode.getChildNodes();
    int len = patientNode.getChildNodes().getLength();
    for (int index = 0; index < len; index++) {
        Node child = children.item(index);
        if (child.getNodeType() != Node.ELEMENT_NODE)
            continue;
        if ("patient_identifier".equalsIgnoreCase(((Element) child).getAttribute("openmrs_table")) && "identifier".equalsIgnoreCase(((Element) child).getAttribute("openmrs_attribute")))
            return child.getTextContent();
    }
    return null;
}

7. SuiteExecutionReportTest#shouldHandleMissingRunTimesGraceFully()

Project: fitnesse
File: SuiteExecutionReportTest.java
@Test
public void shouldHandleMissingRunTimesGraceFully() throws Exception {
    Element element = mock(Element.class);
    NodeList emptyNodeList = mock(NodeList.class);
    when(element.getElementsByTagName("runTimeInMillis")).thenReturn(emptyNodeList);
    when(emptyNodeList.getLength()).thenReturn(0);
    assertThat(report1.getRunTimeInMillisOrZeroIfNotPresent(element), is(0L));
    element = mock(Element.class);
    NodeList matchingNodeList = mock(NodeList.class);
    Node elementWithText = mock(Element.class);
    when(element.getElementsByTagName("runTimeInMillis")).thenReturn(matchingNodeList);
    when(matchingNodeList.getLength()).thenReturn(1);
    when(matchingNodeList.item(0)).thenReturn(elementWithText);
    when(elementWithText.getTextContent()).thenReturn("255");
    assertThat(report1.getRunTimeInMillisOrZeroIfNotPresent(element), is(255L));
}

8. ExecutionReportTest#shouldHandleMissingRunTimesGraceFully()

Project: fitnesse
File: ExecutionReportTest.java
@Test
public void shouldHandleMissingRunTimesGraceFully() throws Exception {
    TestExecutionReport report = new TestExecutionReport(new FitNesseVersion("version"), "rootPath");
    Element element = mock(Element.class);
    NodeList emptyNodeList = mock(NodeList.class);
    when(element.getElementsByTagName("totalRunTimeInMillis")).thenReturn(emptyNodeList);
    when(emptyNodeList.getLength()).thenReturn(0);
    assertThat(report.getTotalRunTimeInMillisOrMinusOneIfNotPresent(element), is(-1L));
    element = mock(Element.class);
    NodeList matchingNodeList = mock(NodeList.class);
    Node elementWithText = mock(Element.class);
    when(element.getElementsByTagName("totalRunTimeInMillis")).thenReturn(matchingNodeList);
    when(matchingNodeList.getLength()).thenReturn(1);
    when(matchingNodeList.item(0)).thenReturn(elementWithText);
    when(elementWithText.getTextContent()).thenReturn("255");
    assertThat(report.getTotalRunTimeInMillisOrMinusOneIfNotPresent(element), is(255L));
}

9. TestMixinXml#textExceptions()

Project: etch
File: TestMixinXml.java
/** @throws Exception */
@org.junit.Test
public void textExceptions() throws Exception {
    // verify exceptions
    NodeList exceptionsNodeList = document.getElementsByTagName("exceptions");
    assertEquals(exceptionsNodeList.getLength(), 1);
    Node exceptionsNode = exceptionsNodeList.item(0);
    ArrayList<Node> list = new ArrayList<Node>();
    NodeList exceptionsNodeChildren = exceptionsNode.getChildNodes();
    for (int i = 0; i < exceptionsNodeChildren.getLength(); i++) {
        if (exceptionsNodeChildren.item(i).getNodeName() == "exception") {
            list.add(exceptionsNodeChildren.item(i));
        }
    }
    assertEquals(list.size(), 0);
}

10. XPathPropertyArrayItemGetter#get()

Project: esper
File: XPathPropertyArrayItemGetter.java
public Object get(EventBean eventBean) throws PropertyAccessException {
    Object result = getter.get(eventBean);
    if (!(result instanceof NodeList)) {
        return null;
    }
    NodeList nodeList = (NodeList) result;
    if (nodeList.getLength() <= index) {
        return null;
    }
    return nodeList.item(index);
}

11. JaxpIssue43Test#getSchemaSources()

Project: openjdk
File: JaxpIssue43Test.java
private Source[] getSchemaSources() throws Exception {
    List<Source> list = new ArrayList<Source>();
    String file = getClass().getResource("hello_literal.wsdl").getFile();
    Source source = new StreamSource(new FileInputStream(file), file);
    Transformer trans = TransformerFactory.newInstance().newTransformer();
    DOMResult result = new DOMResult();
    trans.transform(source, result);
    // Look for <xsd:schema> element in wsdl
    Element e = ((Document) result.getNode()).getDocumentElement();
    NodeList typesList = e.getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/", "types");
    NodeList schemaList = ((Element) typesList.item(0)).getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "schema");
    Element elem = (Element) schemaList.item(0);
    list.add(new DOMSource(elem, file + "#schema0"));
    return list.toArray(new Source[list.size()]);
}

12. NodeListTest#lastItemTest()

Project: openjdk
File: NodeListTest.java
@Test(dataProvider = "xml")
public void lastItemTest(String xmlFileName, String nodeName) throws Exception {
    Document document = createDOM(xmlFileName);
    NodeList nl = document.getElementsByTagName(nodeName);
    int n = nl.getLength();
    Element elem1 = (Element) nl.item(n - 1);
    nl.item(n);
    Element elem3 = (Element) nl.item(n - 1);
    assertEquals(elem3, elem1);
}

13. EntityChildTest#test()

Project: openjdk
File: EntityChildTest.java
@Test
public void test() throws Exception {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setValidating(true);
    DocumentBuilder docBuilder = dbf.newDocumentBuilder();
    Document document = docBuilder.parse(new File(XML_DIR + "entitychild.xml"));
    Element root = document.getDocumentElement();
    NodeList n = root.getElementsByTagName("table");
    NodeList nl = n.item(0).getChildNodes();
    assertEquals(n.getLength(), 1);
    assertEquals(nl.getLength(), 3);
}

14. XMLModelsParser#getModels()

Project: spaceracer3d
File: XMLModelsParser.java
public ArrayList<String> getModels(final String objectName) throws Exception {
    if (filename == null) {
        throw new Exception("No XML file to parse is specified!");
    }
    final ArrayList<String> models = new ArrayList<String>();
    final String expression = "/models/" + objectName;
    final InputSource inputSource = new InputSource(filename);
    final NodeList nodes = (NodeList) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);
    NodeList modelNodes;
    String model = null;
    for (int i = 0; i < nodes.getLength(); i++) {
        modelNodes = nodes.item(i).getChildNodes();
        for (int j = 1; j < modelNodes.getLength(); j += 2) {
            model = modelNodes.item(j).getTextContent();
            if (model != null && model.length() > 0) {
                models.add(model);
            }
        }
    }
    return models;
}

15. SamlModel#hasDestinationIndicationSaml1Response()

Project: OWASP-WebScarab
File: SamlModel.java
private boolean hasDestinationIndicationSaml1Response(Element responseElement) {
    if (null != responseElement.getAttributeNode("Recipient")) {
        return true;
    }
    NodeList assertionNodeList = responseElement.getElementsByTagNameNS("urn:oasis:names:tc:SAML:1.0:assertion", "Assertion");
    if (0 == assertionNodeList.getLength()) {
        return false;
    }
    Element assertionElement = (Element) assertionNodeList.item(0);
    NodeList audienceNodeList = assertionElement.getElementsByTagNameNS("urn:oasis:names:tc:SAML:1.0:assertion", "Audience");
    if (0 != audienceNodeList.getLength()) {
        return true;
    }
    return false;
}

16. XmlAgentConfigurationBuilder#getForbiddenPaths()

Project: ApplicationInsights-Java
File: XmlAgentConfigurationBuilder.java
private void getForbiddenPaths(Element parent, AgentConfigurationDefaultImpl agentConfiguration) {
    NodeList nodes = parent.getElementsByTagName(EXCLUDED_PREFIXES_TAG);
    Element forbiddenElement = getFirst(nodes);
    if (forbiddenElement == null) {
        return;
    }
    HashSet<String> excludedPrefixes = new HashSet<String>();
    NodeList addClasses = forbiddenElement.getElementsByTagName(FORBIDDEN_PREFIX_TAG);
    if (addClasses == null) {
        return;
    }
    for (int index = 0; index < addClasses.getLength(); ++index) {
        Element classElement = getClassDataElement(addClasses.item(index));
        if (classElement == null) {
            continue;
        }
        excludedPrefixes.add(classElement.getFirstChild().getTextContent());
    }
    agentConfiguration.setExcludedPrefixes(excludedPrefixes);
}

17. Response#addPartStructureList()

Project: sakai
File: Response.java
/*
	 * Helpers
	 */
/**
	 * Locate (and save as PartStructure id/value pairs) all matching items
	 *
	 * @param rootElement
	 *            Start looking here
	 * @param partDataName
	 *            Name of the XML element we're looking for
	 * @param item
	 *            Current MatchItem (eg Asset)
	 * @param id
	 *            Part ID
	 * @return true if PartStructure data was added, false if none found
	 */
private boolean addPartStructureList(Element parentElement, String partDataName, MatchItem item, org.osid.shared.Id id) {
    NodeList nodeList = DomUtils.getElementList(parentElement, partDataName);
    boolean partsAdded = false;
    for (int i = 0; i < nodeList.getLength(); i++) {
        Element element = (Element) nodeList.item(i);
        String text = DomUtils.getText(element);
        if (!StringUtils.isNull(text)) {
            addPartStructure(item, id, text);
            partsAdded = true;
        }
    }
    return partsAdded;
}

18. ExclusionSeqRecurrenceRule#set()

Project: sakai
File: ExclusionSeqRecurrenceRule.java
/**
	* Take values from this xml element
	* @param el The xml element.
	*/
public void set(Element el) {
    // the children (time ranges)
    NodeList children = el.getChildNodes();
    final int length = children.getLength();
    for (int i = 0; i < length; i++) {
        Node child = children.item(i);
        if (child.getNodeType() != Node.ELEMENT_NODE)
            continue;
        Element element = (Element) child;
        // look for a time range
        if (element.getTagName().equals("exclude")) {
            try {
                m_exclusions.add(new Integer(element.getAttribute("sequence")));
            } catch (Exception e) {
                M_log.warn("set: while reading exclude sequence: " + e);
            }
        }
    }
}

19. ExclusionRecurrenceRule#set()

Project: sakai
File: ExclusionRecurrenceRule.java
/**
	* Take values from this xml element
	* @param el The xml element.
	*/
public void set(Element el) {
    // the children (time ranges)
    NodeList children = el.getChildNodes();
    final int length = children.getLength();
    for (int i = 0; i < length; i++) {
        Node child = children.item(i);
        if (child.getNodeType() != Node.ELEMENT_NODE)
            continue;
        Element element = (Element) child;
        // look for a time range
        if (element.getTagName().equals("range")) {
            try {
                m_ranges.add(TimeService.newTimeRange(element.getAttribute("range")));
            } catch (Exception e) {
                M_log.warn("set: while reading time range: " + e);
            }
        }
    }
}

20. ConfigParser#getElementContentText()

Project: s4
File: ConfigParser.java
public String getElementContentText(Node node) {
    if (node.getNodeType() != Node.ELEMENT_NODE) {
        return "";
    }
    NodeList children = node.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        if (child.getNodeType() == Node.TEXT_NODE) {
            return child.getNodeValue();
        }
    }
    return "";
}

21. ConfigParser#processConfigElement()

Project: s4
File: ConfigParser.java
public Config processConfigElement(Node configElement) {
    String version = ((Element) configElement).getAttribute("version");
    if (version == null || version.length() > 0) {
        version = "-1";
    }
    NodeList nodeList = configElement.getChildNodes();
    Config config = new Config(version);
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("cluster")) {
            config.addCluster(processClusterElement(node));
        }
    }
    return config;
}

22. ConfigParser#parse()

Project: s4
File: ConfigParser.java
public Config parse(String configFilename) {
    Config config = null;
    Document document = createDocument(configFilename);
    NodeList topLevelNodeList = document.getChildNodes();
    for (int i = 0; i < topLevelNodeList.getLength(); i++) {
        Node node = topLevelNodeList.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("config")) {
            config = processConfigElement(node);
        }
    }
    verifyConfig(config);
    return config;
}

23. CommandBundleGenerator#getCommandProperties()

Project: rstudio
File: CommandBundleGenerator.java
public Map<String, Element> getCommandProperties() throws UnableToCompleteException {
    Map<String, Element> properties = new HashMap<String, Element>();
    NodeList nodes = getConfigDoc("/commands/cmd");
    for (int i = 0; i < nodes.getLength(); i++) {
        Element cmd = (Element) nodes.item(i);
        String id = cmd.getAttribute("id");
        properties.put(id, cmd);
    }
    return properties;
}

24. CommandBundleGenerator#emitShortcuts()

Project: rstudio
File: CommandBundleGenerator.java
private void emitShortcuts(SourceWriter writer) throws UnableToCompleteException {
    writer.println("private void __registerShortcuts() {");
    writer.indent();
    NodeList nodes = getConfigDoc("/commands/shortcuts");
    for (int i = 0; i < nodes.getLength(); i++) {
        NodeList groups = nodes.item(i).getChildNodes();
        for (int j = 0; j < groups.getLength(); j++) {
            if (groups.item(j).getNodeType() != Node.ELEMENT_NODE)
                continue;
            String groupName = ((Element) groups.item(j)).getAttribute("name");
            new ShortcutsEmitter(logger_, groupName, (Element) groups.item(j)).generate(writer);
        }
    }
    writer.outdent();
    writer.println("}");
}

25. StringArrayResourceLoader#processNode()

Project: robolectric
File: StringArrayResourceLoader.java
@Override
protected void processNode(Node node, String name, boolean isSystem) throws XPathExpressionException {
    XPathExpression itemXPath = XPathFactory.newInstance().newXPath().compile("item");
    NodeList childNodes = (NodeList) itemXPath.evaluate(node, XPathConstants.NODESET);
    List<String> arrayValues = new ArrayList<String>();
    for (int j = 0; j < childNodes.getLength(); j++) {
        Node childNode = childNodes.item(j);
        String value = childNode.getTextContent();
        if (value.startsWith("@")) {
            value = value.substring(1);
            arrayValues.add(stringResourceLoader.getValue(value, isSystem));
        } else {
            arrayValues.add(value);
        }
    }
    String valuePointer = (isSystem ? "android:" : "") + "array/" + name;
    stringArrayValues.put(valuePointer, arrayValues.toArray(new String[arrayValues.size()]));
}

26. PluralResourceLoader#processNode()

Project: robolectric
File: PluralResourceLoader.java
@Override
protected void processNode(Node node, String name, boolean isSystem) throws XPathExpressionException {
    XPathExpression itemXPath = XPathFactory.newInstance().newXPath().compile("item");
    NodeList childNodes = (NodeList) itemXPath.evaluate(node, XPathConstants.NODESET);
    PluralRules rules = new PluralRules();
    for (int j = 0; j < childNodes.getLength(); j++) {
        Node childNode = childNodes.item(j);
        String value = childNode.getTextContent();
        String quantity = childNode.getAttributes().getNamedItem("quantity").getTextContent();
        if (value.startsWith("@")) {
            value = value.substring(1);
            rules.add(new Plural(quantity, stringResourceLoader.getValue(value, isSystem)));
        } else {
            rules.add(new Plural(quantity, value));
        }
    }
    plurals.put("plurals/" + name, rules);
}

27. MenuLoader#processResourceXml()

Project: robolectric
File: MenuLoader.java
@Override
protected void processResourceXml(File xmlFile, Document document, boolean ignored) throws Exception {
    MenuNode topLevelNode = new MenuNode("top-level", new HashMap<String, String>());
    NodeList items = document.getChildNodes();
    if (items.getLength() != 1)
        throw new RuntimeException("Expected only one top-level item in menu file " + xmlFile.getName());
    if (items.item(0).getNodeName().compareTo("menu") != 0)
        throw new RuntimeException("Expected a top-level item called 'menu' in menu file " + xmlFile.getName());
    processChildren(items.item(0).getChildNodes(), topLevelNode);
    menuNodesByMenuName.put("menu/" + xmlFile.getName().replace(".xml", ""), topLevelNode);
}

28. DrawableResourceLoader#buildStateListDrawable()

Project: robolectric
File: DrawableResourceLoader.java
private StateListDrawable buildStateListDrawable(Document d) {
    StateListDrawable drawable = new StateListDrawable();
    ShadowStateListDrawable shDrawable = Robolectric.shadowOf(drawable);
    NodeList items = d.getElementsByTagName("item");
    for (int i = 0; i < items.getLength(); i++) {
        Node node = items.item(i);
        Node drawableName = node.getAttributes().getNamedItem("android:drawable");
        if (drawableName != null) {
            int resId = resourceExtractor.getResourceId(drawableName.getNodeValue());
            int stateId = getStateId(node);
            shDrawable.addState(stateId, resId);
        }
    }
    return drawable;
}

29. DrawableResourceLoader#getDrawableIds()

Project: robolectric
File: DrawableResourceLoader.java
/**
     * Get drawables by resource id.
     * 
     * @param resourceId
     *            Resource id
     * @return Drawables
     */
protected int[] getDrawableIds(int resourceId) {
    String resourceName = resourceExtractor.getResourceName(resourceId);
    Document document = documents.get(resourceName);
    NodeList items = document.getElementsByTagName("item");
    int[] drawableIds = new int[items.getLength()];
    for (int i = 0; i < items.getLength(); i++) {
        if (resourceName.startsWith("android:")) {
            drawableIds[i] = -1;
        } else {
            Node item = items.item(i);
            Node drawableName = item.getAttributes().getNamedItem("android:drawable");
            if (drawableName != null) {
                drawableIds[i] = resourceExtractor.getResourceId(drawableName.getNodeValue());
            }
        }
    }
    return drawableIds;
}

30. DrawableResourceLoader#getXmlDrawable()

Project: robolectric
File: DrawableResourceLoader.java
public Drawable getXmlDrawable(int resId) {
    if (!isXml(resId)) {
        return null;
    }
    Document xmlDoc = documents.get(resourceExtractor.getResourceName(resId));
    NodeList nodes = xmlDoc.getElementsByTagName("selector");
    if (nodes != null && nodes.getLength() > 0) {
        return buildStateListDrawable(xmlDoc);
    }
    nodes = xmlDoc.getElementsByTagName("layer-list");
    if (nodes != null && nodes.getLength() > 0) {
        return new LayerDrawable(null);
    }
    return null;
}

31. AttrResourceLoader#processResourceXml()

Project: robolectric
File: AttrResourceLoader.java
@Override
protected void processResourceXml(File xmlFile, Document document, boolean isSystem) throws Exception {
    XPathExpression stringsXPath = XPathFactory.newInstance().newXPath().compile("/resources/declare-styleable/attr/enum");
    NodeList stringNodes = (NodeList) stringsXPath.evaluate(document, XPathConstants.NODESET);
    for (int i = 0; i < stringNodes.getLength(); i++) {
        Node node = stringNodes.item(i);
        String viewName = node.getParentNode().getParentNode().getAttributes().getNamedItem("name").getNodeValue();
        String enumName = node.getParentNode().getAttributes().getNamedItem("name").getNodeValue();
        String name = node.getAttributes().getNamedItem("name").getNodeValue();
        String value = node.getAttributes().getNamedItem("value").getNodeValue();
        classAttrEnumToValue.put(key(viewName, enumName, name, isSystem), value);
        knownClassAttrs.add(key(viewName, enumName, isSystem));
    }
}

32. XMLUtils#replaceSingleNode()

Project: Resteasy
File: XMLUtils.java
/**
	 * Adds or replaces node in parent.
	 * @param parent
	 * @param node
	 * @throws Exception - Node cannot exist more than once,
	 * i.e. multiple nodes with the same name cannot exist in parent.
	 */
public static void replaceSingleNode(Element parent, final Node node) throws RuntimeException {
    NodeList nodes = parent.getElementsByTagName(node.getNodeName());
    if (nodes.getLength() > 1) {
        throw new RuntimeException("Parent element contains multiple nodes with the name " + node.getNodeName());
    }
    if (nodes.getLength() == 0) {
        parent.appendChild(node);
    } else {
        parent.replaceChild(node, nodes.item(0));
    }
}

33. XMLSettingNode#getStrings()

Project: Resteasy
File: XMLSettingNode.java
public List<String> getStrings(String expression) {
    NodeList nodes = this.getNodeList(expression);
    if (nodes != null && nodes.getLength() > 0) {
        List<String> strings = new ArrayList<String>();
        for (int i = 0; i < nodes.getLength(); i++) {
            strings.add(nodes.item(i).getTextContent());
        }
        return strings;
    }
    return null;
}

34. XMLSettingNode#getSettings()

Project: Resteasy
File: XMLSettingNode.java
public List<XMLSettingNode> getSettings(String expression) {
    NodeList nodes = this.getNodeList(expression);
    List<XMLSettingNode> settingNodes = new ArrayList<XMLSettingNode>();
    for (int i = 0; i < nodes.getLength(); i++) {
        settingNodes.add(new XMLSettingNode((Element) nodes.item(i)));
    }
    return settingNodes;
}

35. XMLSettingNode#getLongs()

Project: Resteasy
File: XMLSettingNode.java
public List<Long> getLongs(String expression) {
    NodeList nodes = this.getNodeList(expression);
    List<Long> longs = new ArrayList<Long>();
    for (int i = 0; i < nodes.getLength(); i++) {
        String value = nodes.item(i).getTextContent();
        if (value != null) {
            Long numberValue = NumberUtils.toLong(value);
            if (numberValue != null) {
                longs.add(numberValue);
            }
        }
    }
    return longs;
}

36. XMLSettingNode#getIntegers()

Project: Resteasy
File: XMLSettingNode.java
public List<Integer> getIntegers(String expression) {
    NodeList nodes = this.getNodeList(expression);
    List<Integer> integers = new ArrayList<Integer>();
    for (int i = 0; i < nodes.getLength(); i++) {
        String value = nodes.item(i).getTextContent();
        if (value != null) {
            Integer numberValue = NumberUtils.toInt(value);
            if (numberValue != null) {
                integers.add(numberValue);
            }
        }
    }
    return integers;
}

37. XMLSettingNode#getDoubles()

Project: Resteasy
File: XMLSettingNode.java
public List<Double> getDoubles(String expression) {
    NodeList nodes = this.getNodeList(expression);
    List<Double> doubles = new ArrayList<Double>();
    for (int i = 0; i < nodes.getLength(); i++) {
        String value = nodes.item(i).getTextContent();
        if (value != null) {
            Double numberValue = NumberUtils.toDouble(value);
            if (numberValue != null) {
                doubles.add(numberValue);
            }
        }
    }
    return doubles;
}

38. SettingsReader#setColumns()

Project: ReportGenerator
File: SettingsReader.java
private void setColumns(Document doc) {
    NodeList columnNodeList = doc.getElementsByTagName("column");
    for (int s = 0; s < columnNodeList.getLength(); s++) {
        Node columnNode = columnNodeList.item(s);
        if (columnNode.getNodeType() == Node.ELEMENT_NODE) {
            Element elementColumnNode = (Element) columnNode;
            Column column = new Column();
            column.setTitle(getTitle(elementColumnNode));
            column.setWidth(getSize(elementColumnNode, "width"));
            if (columnsList == null) {
                columnsList = new ArrayList<>();
            }
            columnsList.add(column);
        }
    }
}

39. ConfigurationLoader#getRootNode()

Project: redpen
File: ConfigurationLoader.java
private Element getRootNode(Document doc, String rootTag) {
    doc.getDocumentElement().normalize();
    NodeList rootConfigElementList = doc.getElementsByTagName(rootTag);
    if (rootConfigElementList.getLength() == 0) {
        throw new IllegalStateException("No \"" + rootTag + "\" block found in the configuration");
    } else if (rootConfigElementList.getLength() > 1) {
        LOG.warn("More than one \"" + rootTag + "\" blocks in the configuration");
    }
    Node root = rootConfigElementList.item(0);
    Element rootElement = (Element) root;
    LOG.info("Succeeded to load configuration file");
    return rootElement;
}

40. ConfigurationLoader#getSpecifiedNodeList()

Project: redpen
File: ConfigurationLoader.java
private NodeList getSpecifiedNodeList(Element rootElement, String elementName) {
    NodeList elementList = rootElement.getElementsByTagName(elementName);
    if (elementList.getLength() == 0) {
        LOG.info("No \"" + elementName + "\" block found in the configuration");
        return null;
    } else if (elementList.getLength() > 1) {
        LOG.info("More than one \"" + elementName + " \" blocks in the configuration");
    }
    return elementList;
}

41. ConfigurationLoader#extractSymbolConfig()

Project: redpen
File: ConfigurationLoader.java
private void extractSymbolConfig(ConfigurationBuilder configBuilder, NodeList symbolTableConfigElementList, String language) throws RedPenException {
    configBuilder.setLanguage(language);
    NodeList symbolTableElementList = getSpecifiedNodeList((Element) symbolTableConfigElementList.item(0), "symbol");
    if (symbolTableElementList == null) {
        LOG.warn("there is no character block");
        return;
    }
    for (int temp = 0; temp < symbolTableElementList.getLength(); temp++) {
        Node nNode = symbolTableElementList.item(temp);
        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
            Element element = (Element) nNode;
            Symbol currentSymbol = createSymbol(element);
            configBuilder.addSymbol(currentSymbol);
        }
    }
}

42. ProfileCollection#getChildren()

Project: railo
File: ProfileCollection.java
private static Element[] getChildren(Node parent, String nodeName) {
    if (parent == null)
        return new Element[0];
    NodeList list = parent.getChildNodes();
    int len = list.getLength();
    ArrayList rtn = new ArrayList();
    for (int i = 0; i < len; i++) {
        Node node = list.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equalsIgnoreCase(nodeName)) {
            rtn.add(node);
        }
    }
    return (Element[]) rtn.toArray(new Element[rtn.size()]);
}

43. ProfileCollection#getChildByName()

Project: railo
File: ProfileCollection.java
private static Element getChildByName(Node parent, String nodeName, boolean insertBefore) {
    if (parent == null)
        return null;
    NodeList list = parent.getChildNodes();
    int len = list.getLength();
    for (int i = 0; i < len; i++) {
        Node node = list.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equalsIgnoreCase(nodeName)) {
            return (Element) node;
        }
    }
    Element newEl = parent.getOwnerDocument().createElement(nodeName);
    if (insertBefore)
        parent.insertBefore(newEl, parent.getFirstChild());
    else
        parent.appendChild(newEl);
    return newEl;
}

44. XMLUtil#getChildNode()

Project: railo
File: XMLUtil.java
public static synchronized Node getChildNode(Node node, short type, boolean caseSensitive, String filter, int index) {
    NodeList nodes = node.getChildNodes();
    int len = nodes.getLength();
    Node n;
    int count = 0;
    for (int i = 0; i < len; i++) {
        try {
            n = nodes.item(i);
            if (n != null && n.getNodeType() == type) {
                if (filter == null || (caseSensitive ? filter.equals(n.getLocalName()) : filter.equalsIgnoreCase(n.getLocalName()))) {
                    if (count == index)
                        return n;
                    count++;
                }
            }
        } catch (Throwable t) {
        }
    }
    return null;
}

45. XMLUtil#getChildNodesAsList()

Project: railo
File: XMLUtil.java
public static synchronized List<Node> getChildNodesAsList(Node node, short type, boolean caseSensitive, String filter) {
    List<Node> rtn = new ArrayList<Node>();
    NodeList nodes = node.getChildNodes();
    int len = nodes.getLength();
    Node n;
    for (int i = 0; i < len; i++) {
        try {
            n = nodes.item(i);
            if (n != null && n.getNodeType() == type) {
                if (filter == null || (caseSensitive ? filter.equals(n.getLocalName()) : filter.equalsIgnoreCase(n.getLocalName())))
                    rtn.add(n);
            }
        } catch (Throwable t) {
        }
    }
    return rtn;
}

46. XMLUtil#getChildNodes()

Project: railo
File: XMLUtil.java
public static synchronized ArrayNodeList getChildNodes(Node node, short type, boolean caseSensitive, String filter) {
    ArrayNodeList rtn = new ArrayNodeList();
    NodeList nodes = node.getChildNodes();
    int len = nodes.getLength();
    Node n;
    for (int i = 0; i < len; i++) {
        try {
            n = nodes.item(i);
            if (n != null && n.getNodeType() == type) {
                if (filter == null || (caseSensitive ? filter.equals(n.getLocalName()) : filter.equalsIgnoreCase(n.getLocalName())))
                    rtn.add(n);
            }
        } catch (Throwable t) {
        }
    }
    return rtn;
}

47. XMLUtil#childNodesLength()

Project: railo
File: XMLUtil.java
public static synchronized int childNodesLength(Node node, short type, boolean caseSensitive, String filter) {
    NodeList nodes = node.getChildNodes();
    int len = nodes.getLength();
    Node n;
    int count = 0;
    for (int i = 0; i < len; i++) {
        try {
            n = nodes.item(i);
            if (n != null && n.getNodeType() == type) {
                if (filter == null || (caseSensitive ? filter.equals(n.getLocalName()) : filter.equalsIgnoreCase(n.getLocalName())))
                    count++;
            }
        } catch (Throwable t) {
        }
    }
    return count;
}

48. SearchEngineSupport#getIndexElement()

Project: railo
File: SearchEngineSupport.java
@Override
public Element getIndexElement(Element collElement, String id) {
    NodeList children = collElement.getChildNodes();
    int len = children.getLength();
    for (int i = 0; i < len; i++) {
        Node n = children.item(i);
        if (n instanceof Element && n.getNodeName().equals("index")) {
            Element el = (Element) n;
            if (el.getAttribute("id").equals(id))
                return el;
        }
    }
    return null;
}

49. SearchEngineSupport#getCollectionElement()

Project: railo
File: SearchEngineSupport.java
/**
     * return XML Element matching collection name
     * @param name
     * @return matching XML Element
     */
protected final Element getCollectionElement(String name) {
    Element root = doc.getDocumentElement();
    NodeList children = root.getChildNodes();
    int len = children.getLength();
    for (int i = 0; i < len; i++) {
        Node n = children.item(i);
        if (n instanceof Element && n.getNodeName().equals("collection")) {
            Element el = (Element) n;
            if (el.getAttribute("name").equalsIgnoreCase(name))
                return el;
        }
    }
    return null;
}

50. SearchEngineSupport#purgeCollection()

Project: railo
File: SearchEngineSupport.java
/**
     * purge a Collection
     * @param name Name of the Collection to purge
     * @throws SearchException
     */
private final synchronized void purgeCollection(String name) throws SearchException {
    //Map map=(Map)collections.get(name);
    //if(map!=null)map.clear();
    Element parent = getCollectionElement(name);
    NodeList list = parent.getChildNodes();
    int len = list.getLength();
    for (int i = len - 1; i >= 0; i--) {
        parent.removeChild(list.item(i));
    }
    //doc.getDocumentElement().removeChild(getCollectionElement(name));
    store();
}

51. SchedulerImpl#pauseScheduleTask()

Project: railo
File: SchedulerImpl.java
@Override
public void pauseScheduleTask(String name, boolean pause, boolean throwWhenNotExist) throws ScheduleException, IOException {
    for (int i = 0; i < tasks.length; i++) {
        if (tasks[i].getTask().equalsIgnoreCase(name)) {
            tasks[i].setPaused(pause);
        }
    }
    NodeList list = doc.getDocumentElement().getChildNodes();
    Element el = su.getElement(list, "name", name);
    if (el != null) {
        el.setAttribute("paused", Caster.toString(pause));
    //el.getParentNode().removeChild(el);
    } else if (throwWhenNotExist)
        throw new ScheduleException("can't " + (pause ? "pause" : "resume") + " schedule task [" + name + "], task doesn't exist");
    //init();
    su.store(doc, schedulerFile);
}

52. SchedulerImpl#addScheduleTask()

Project: railo
File: SchedulerImpl.java
@Override
public void addScheduleTask(ScheduleTask task, boolean allowOverwrite) throws ScheduleException, IOException {
    //ScheduleTask exTask = getScheduleTask(task.getTask(),null);
    NodeList list = doc.getDocumentElement().getChildNodes();
    Element el = su.getElement(list, "name", task.getTask());
    if (!allowOverwrite && el != null)
        throw new ScheduleException("there is already a schedule task with name " + task.getTask());
    addTask((ScheduleTaskImpl) task);
    // Element update
    if (el != null) {
        setAttributes(el, task);
    } else // Element insert
    {
        doc.getDocumentElement().appendChild(toElement(task));
    }
    su.store(doc, schedulerFile);
}

53. SchedulerImpl#readInAllTasks()

Project: railo
File: SchedulerImpl.java
/**
	 * read in all schedule tasks
	 * @return all schedule tasks
	 * @throws PageException
     */
private ScheduleTaskImpl[] readInAllTasks() throws PageException {
    Element root = doc.getDocumentElement();
    NodeList children = root.getChildNodes();
    ArrayList<ScheduleTaskImpl> list = new ArrayList<ScheduleTaskImpl>();
    int len = children.getLength();
    for (int i = 0; i < len; i++) {
        Node n = children.item(i);
        if (n instanceof Element && n.getNodeName().equals("task")) {
            list.add(readInTask((Element) n));
        }
    }
    return list.toArray(new ScheduleTaskImpl[list.size()]);
}

54. XmlSearch#nodelist()

Project: railo
File: XmlSearch.java
private static Array nodelist(XObject rs, boolean caseSensitive) throws TransformerException, PageException {
    NodeList list = rs.nodelist();
    int len = list.getLength();
    Array rtn = new ArrayImpl();
    for (int i = 0; i < len; i++) {
        Node n = list.item(i);
        if (n != null)
            rtn.append(XMLCaster.toXMLStruct(n, caseSensitive));
    }
    return rtn;
}

55. XMLConverter#_deserializeArray()

Project: railo
File: XMLConverter.java
/**
	 * Desirialize a Struct Object
	 * @param el Struct Object as XML Element
	 * @return Struct Object
	 * @throws ConverterException
	 */
private Array _deserializeArray(Element el) throws ConverterException {
    Array array = new ArrayImpl();
    NodeList list = el.getChildNodes();
    int len = list.getLength();
    for (int i = 0; i < len; i++) {
        Node node = list.item(i);
        if (node instanceof Element)
            try {
                array.append(_deserialize((Element) node));
            } catch (PageException e) {
                throw toConverterException(e);
            }
    }
    return array;
}

56. XMLConverter#_deserializeStruct()

Project: railo
File: XMLConverter.java
/**
	 * Desirialize a Struct Object
	 * @param elStruct Struct Object as XML Element
	 * @return Struct Object
	 * @throws ConverterException
	 */
private Object _deserializeStruct(Element elStruct) throws ConverterException {
    String type = elStruct.getAttribute("type");
    Struct struct = new StructImpl();
    NodeList list = elStruct.getChildNodes();
    int len = list.getLength();
    for (int i = 0; i < len; i++) {
        //print.ln(i);
        Node node = list.item(i);
        if (node instanceof Element) {
            Element var = (Element) node;
            Element value = getChildElement((Element) node);
            if (value != null) {
                struct.setEL(var.getAttribute("name"), _deserialize(value));
            }
        }
    }
    if (struct.size() == 0 && type != null && type.length() > 0) {
        return "";
    }
    return struct;
}

57. XMLConverter#_deserializeQueryField()

Project: railo
File: XMLConverter.java
/**
	 * deserilize a single Field of a query WDDX Object
	 * @param query
	 * @param field
	 * @throws ConverterException 
	 * @throws PageException
	 */
private void _deserializeQueryField(Query query, Element field) throws PageException, ConverterException {
    String name = field.getAttribute("name");
    NodeList list = field.getChildNodes();
    int len = list.getLength();
    int count = 0;
    for (int i = 0; i < len; i++) {
        Node node = list.item(i);
        if (node instanceof Element) {
            query.setAt(name, ++count, _deserialize((Element) node));
        }
    }
}

58. XMLConverter#_deserializeString()

Project: railo
File: XMLConverter.java
private Object _deserializeString(Element element) {
    NodeList childList = element.getChildNodes();
    int len = childList.getLength();
    StringBuffer sb = new StringBuffer();
    Node data;
    String str;
    for (int i = 0; i < len; i++) {
        data = childList.item(i);
        if (data == null)
            continue;
        //<char code="0a"/>
        if ("char".equals(data.getNodeName())) {
            str = ((Element) data).getAttribute("code");
            sb.append((char) NumberUtil.hexToInt(str, 10));
        } else {
            sb.append(str = data.getNodeValue());
        }
    }
    return sb.toString();
//return XMLUtil.unescapeXMLString(sb.toString());
}

59. WDDXConverter#_deserializeArray()

Project: railo
File: WDDXConverter.java
/**
	 * Desirialize a Struct Object
	 * @param el Struct Object as XML Element
	 * @return Struct Object
	 * @throws ConverterException
	 */
private Array _deserializeArray(Element el) throws ConverterException {
    Array array = new ArrayImpl();
    NodeList list = el.getChildNodes();
    int len = list.getLength();
    for (int i = 0; i < len; i++) {
        Node node = list.item(i);
        if (node instanceof Element)
            try {
                array.append(_deserialize((Element) node));
            } catch (PageException e) {
                throw toConverterException(e);
            }
    }
    return array;
}

60. WDDXConverter#_deserializeStruct()

Project: railo
File: WDDXConverter.java
/**
	 * Desirialize a Struct Object
	 * @param elStruct Struct Object as XML Element
	 * @return Struct Object
	 * @throws ConverterException
	 */
private Object _deserializeStruct(Element elStruct) throws ConverterException {
    String type = elStruct.getAttribute("type");
    Struct struct = new StructImpl();
    NodeList list = elStruct.getChildNodes();
    int len = list.getLength();
    for (int i = 0; i < len; i++) {
        //print.ln(i);
        Node node = list.item(i);
        if (node instanceof Element) {
            Element var = (Element) node;
            Element value = getChildElement((Element) node);
            if (value != null) {
                struct.setEL(var.getAttribute("name"), _deserialize(value));
            }
        }
    }
    if (struct.size() == 0 && type != null && type.length() > 0) {
        return "";
    }
    return struct;
}

61. WDDXConverter#_deserializeQueryField()

Project: railo
File: WDDXConverter.java
/**
	 * deserilize a single Field of a query WDDX Object
	 * @param query
	 * @param field
	 * @throws ConverterException 
	 * @throws PageException
	 */
private void _deserializeQueryField(Query query, Element field) throws PageException, ConverterException {
    String name = field.getAttribute("name");
    NodeList list = field.getChildNodes();
    int len = list.getLength();
    int count = 0;
    for (int i = 0; i < len; i++) {
        Node node = list.item(i);
        if (node instanceof Element) {
            query.setAt(KeyImpl.init(name), ++count, _deserialize((Element) node));
        }
    }
}

62. WDDXConverter#_deserializeString()

Project: railo
File: WDDXConverter.java
private Object _deserializeString(Element element) {
    NodeList childList = element.getChildNodes();
    int len = childList.getLength();
    StringBuffer sb = new StringBuffer();
    Node data;
    String str;
    for (int i = 0; i < len; i++) {
        data = childList.item(i);
        if (data == null)
            continue;
        //<char code="0a"/>
        if ("char".equals(data.getNodeName())) {
            str = ((Element) data).getAttribute("code");
            sb.append((char) NumberUtil.hexToInt(str, 10));
        } else {
            sb.append(str = data.getNodeValue());
        }
    }
    return sb.toString();
//return XMLUtil.unescapeXMLString(sb.toString());
}

63. ConfigFactory#getChildren()

Project: railo
File: ConfigFactory.java
/**
	 * return all direct child Elements of a Element with given Name
	 * 
	 * @param parent
	 * @param nodeName
	 * @return matching children
	 */
public static Element[] getChildren(Node parent, String nodeName) {
    if (parent == null)
        return new Element[0];
    NodeList list = parent.getChildNodes();
    int len = list.getLength();
    ArrayList<Element> rtn = new ArrayList<Element>();
    for (int i = 0; i < len; i++) {
        Node node = list.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equalsIgnoreCase(nodeName)) {
            rtn.add((Element) node);
        }
    }
    return rtn.toArray(new Element[rtn.size()]);
}

64. ConfigFactory#getChildByName()

Project: railo
File: ConfigFactory.java
public static Element getChildByName(Node parent, String nodeName, boolean insertBefore, boolean doNotCreate) {
    if (parent == null)
        return null;
    NodeList list = parent.getChildNodes();
    int len = list.getLength();
    for (int i = 0; i < len; i++) {
        Node node = list.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equalsIgnoreCase(nodeName)) {
            return (Element) node;
        }
    }
    if (doNotCreate)
        return null;
    Element newEl = parent.getOwnerDocument().createElement(nodeName);
    if (insertBefore)
        parent.insertBefore(newEl, parent.getFirstChild());
    else
        parent.appendChild(newEl);
    return newEl;
}

65. SmilLayoutElementImpl#getRootLayout()

Project: qksms
File: SmilLayoutElementImpl.java
public SMILRootLayoutElement getRootLayout() {
    NodeList childNodes = this.getChildNodes();
    SMILRootLayoutElement rootLayoutNode = null;
    int childrenCount = childNodes.getLength();
    for (int i = 0; i < childrenCount; i++) {
        if (childNodes.item(i).getNodeName().equals("root-layout")) {
            rootLayoutNode = (SMILRootLayoutElement) childNodes.item(i);
        }
    }
    if (null == rootLayoutNode) {
        // root-layout node is not set. Create a default one.
        rootLayoutNode = (SMILRootLayoutElement) getOwnerDocument().createElement("root-layout");
        appendChild(rootLayoutNode);
    }
    return rootLayoutNode;
}

66. ElementSequentialTimeContainerImpl#getActiveChildrenAt()

Project: qksms
File: ElementSequentialTimeContainerImpl.java
/*
     * ElementSequentialTimeContainer Interface
     */
public NodeList getActiveChildrenAt(float instant) {
    NodeList allChildren = this.getTimeChildren();
    ArrayList<Node> nodes = new ArrayList<Node>();
    for (int i = 0; i < allChildren.getLength(); i++) {
        instant -= ((ElementTime) allChildren.item(i)).getDur();
        if (instant < 0) {
            nodes.add(allChildren.item(i));
            return new NodeListImpl(nodes);
        }
    }
    return new NodeListImpl(nodes);
}

67. PythonNatureStore#getChildValuesWithType()

Project: Pydev
File: PythonNatureStore.java
/**
     * Returns the text contents of a nodes' children. The children shall have the specified type.
     * 
     * @param node
     * @param type
     * @return the array of strings with the text contents or null if the node has no children.
     */
private String[] getChildValuesWithType(Node node, String... type) {
    traceFunc("getChildValuesWithType");
    NodeList childNodes = node.getChildNodes();
    if (childNodes != null && childNodes.getLength() > 0) {
        List<String> result = new ArrayList<String>();
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node child = childNodes.item(i);
            String nodeName = child.getNodeName();
            for (String t : type) {
                if (nodeName.equals(t)) {
                    result.add(getTextContent(child));
                    //after added, we can break the inner for.
                    break;
                }
            }
        }
        String[] retval = new String[result.size()];
        traceFunc("END getChildValuesWithType");
        return result.toArray(retval);
    }
    traceFunc("END getChildValuesWithType (null)");
    return null;
}

68. PythonNatureStore#getRootNodeInXml()

Project: Pydev
File: PythonNatureStore.java
/**
     * Get the root node of the project description
     * 
     * @return the root Node object
     * @throws MisconfigurationException 
     * @throws CoreException if root node is not present
     */
private synchronized Node getRootNodeInXml() throws MisconfigurationException {
    traceFunc("getRootNodeInXml");
    if (document == null) {
        throw new MisconfigurationException("Found null XML document. Please check if " + this.xmlFile + " is a valid XML file.");
    }
    NodeList nodeList = document.getElementsByTagName("pydev_project");
    Node ret = null;
    if (nodeList != null && nodeList.getLength() > 0) {
        ret = nodeList.item(0);
    }
    traceFunc("END getRootNodeInXml -- ", ret);
    if (ret != null) {
        return ret;
    }
    throw new RuntimeException(StringUtils.format("Error. Unable to get the %s tag by its name. Project: %s", "pydev_project", project));
}

69. ChartElement#read()

Project: processors
File: ChartElement.java
public void read(Element chartElem, FlowChartSystem flowChartSystem) throws MaltChainedException {
    setItem(chartElem.getAttribute("item"));
    String chartItemClassName = chartElem.getAttribute("class");
    Class<?> clazz = null;
    try {
        if (PluginLoader.instance() != null) {
            clazz = PluginLoader.instance().getClass(chartItemClassName);
        }
        if (clazz == null) {
            clazz = Class.forName(chartItemClassName);
        }
        this.chartItemClass = clazz.asSubclass(org.maltparserx.core.flow.item.ChartItem.class);
    } catch (ClassCastException e) {
        throw new FlowException("The class '" + clazz.getName() + "' is not a subclass of '" + org.maltparserx.core.flow.item.ChartItem.class.getName() + "'. ", e);
    } catch (ClassNotFoundException e) {
        throw new FlowException("The class " + chartItemClassName + "  could not be found. ", e);
    }
    NodeList attrElements = chartElem.getElementsByTagName("attribute");
    for (int i = 0; i < attrElements.getLength(); i++) {
        ChartAttribute attribute = new ChartAttribute();
        attribute.read((Element) attrElements.item(i), flowChartSystem);
        attributes.put(((Element) attrElements.item(i)).getAttribute("name"), attribute);
    }
}

70. ChartSpecification#read()

Project: processors
File: ChartSpecification.java
public void read(Element chartElem, FlowChartManager flowCharts) throws MaltChainedException {
    setName(chartElem.getAttribute("name"));
    NodeList flowChartProcessList = chartElem.getElementsByTagName("preprocess");
    if (flowChartProcessList.getLength() == 1) {
        readChartItems((Element) flowChartProcessList.item(0), flowCharts, preProcessChartItemSpecifications);
    } else if (flowChartProcessList.getLength() > 1) {
        throw new FlowException("The flow chart '" + getName() + "' has more than one preprocess elements. ");
    }
    flowChartProcessList = chartElem.getElementsByTagName("process");
    if (flowChartProcessList.getLength() == 1) {
        readChartItems((Element) flowChartProcessList.item(0), flowCharts, processChartItemSpecifications);
    } else if (flowChartProcessList.getLength() > 1) {
        throw new FlowException("The flow chart '" + getName() + "' has more than one process elements. ");
    }
    flowChartProcessList = chartElem.getElementsByTagName("postprocess");
    if (flowChartProcessList.getLength() == 1) {
        readChartItems((Element) flowChartProcessList.item(0), flowCharts, postProcessChartItemSpecifications);
    } else if (flowChartProcessList.getLength() > 1) {
        throw new FlowException("The flow chart '" + getName() + "' has more than one postprocess elements. ");
    }
}

71. FlowChartManager#readFlowCharts()

Project: processors
File: FlowChartManager.java
private void readFlowCharts(Element flowcharts) throws MaltChainedException {
    NodeList flowChartList = flowcharts.getElementsByTagName("flowchart");
    for (int i = 0; i < flowChartList.getLength(); i++) {
        String flowChartName = ((Element) flowChartList.item(i)).getAttribute("name");
        if (!chartSpecifications.containsKey(flowChartName)) {
            ChartSpecification chart = new ChartSpecification();
            chartSpecifications.put(flowChartName, chart);
            chart.read((Element) flowChartList.item(i), this);
        } else {
            throw new FlowException("Problem parsing the flow chart file. The flow chart with the name " + flowChartName + " already exists. ");
        }
    }
}

72. XmlReader#readFeatureModel()

Project: processors
File: XmlReader.java
private void readFeatureModel(Element featuremodel, SpecificationModels featureSpecModels) throws MaltChainedException {
    int specModelIndex = featureSpecModels.getNextIndex();
    NodeList submodelList = featuremodel.getElementsByTagName("submodel");
    if (submodelList.getLength() == 0) {
        NodeList featureList = featuremodel.getElementsByTagName("feature");
        for (int i = 0; i < featureList.getLength(); i++) {
            String featureText = ((Element) featureList.item(i)).getTextContent().trim();
            if (featureText.length() > 1) {
                featureSpecModels.add(specModelIndex, featureText);
            }
        }
    } else {
        for (int i = 0; i < submodelList.getLength(); i++) {
            String name = ((Element) submodelList.item(i)).getAttribute("name");
            NodeList featureList = ((Element) submodelList.item(i)).getElementsByTagName("feature");
            for (int j = 0; j < featureList.getLength(); j++) {
                String featureText = ((Element) featureList.item(j)).getTextContent().trim();
                if (featureText.length() > 1) {
                    featureSpecModels.add(specModelIndex, name, featureText);
                }
            }
        }
    }
}

73. PXDOMStyleAdapter#getElementChildren()

Project: pixate-freestyle-android
File: PXDOMStyleAdapter.java
/**
     * Returns the children of the given node. In case 'onlyElements' is passed,
     * only the ELEMENT_NODEs will be returned.
     * 
     * @param node
     * @param onlyElements
     * @return
     */
private List<Object> getElementChildren(Node node, boolean onlyElements) {
    NodeList childNodes = node.getChildNodes();
    if (childNodes == null) {
        return Collections.emptyList();
    }
    List<Object> children = new ArrayList<Object>(childNodes.getLength());
    for (int i = 0; i < childNodes.getLength(); i++) {
        short nodeType = childNodes.item(i).getNodeType();
        if (!onlyElements || (onlyElements && nodeType != Document.COMMENT_NODE && nodeType != Document.PROCESSING_INSTRUCTION_NODE)) {
            children.add(childNodes.item(i));
        }
    }
    return children;
}

74. CoberturaXMLParser#getSourceDirs()

Project: phabricator-jenkins-plugin
File: CoberturaXMLParser.java
private List<String> getSourceDirs(Document doc) {
    if (workspace == null) {
        return Collections.emptyList();
    }
    List<String> sourceDirs = new ArrayList<String>();
    NodeList sources = doc.getElementsByTagName(TAG_NAME_SOURCE);
    for (int i = 0; i < sources.getLength(); i++) {
        Node source = sources.item(i);
        String srcDir = source.getTextContent();
        if (srcDir.contains(workspace + "/")) {
            String relativeSrcDir = srcDir.replaceFirst(workspace + "/", "");
            if (!relativeSrcDir.isEmpty()) {
                sourceDirs.add(relativeSrcDir);
            }
        }
    }
    return sourceDirs;
}

75. ScriptValuesHelp#getSample()

Project: pentaho-kettle
File: ScriptValuesHelp.java
public String getSample(String strFunctionName, String strFunctionNameWithArgs) {
    String sRC = "// Sorry, no Script available for " + strFunctionNameWithArgs;
    NodeList nl = dom.getElementsByTagName("jsFunction");
    for (int i = 0; i < nl.getLength(); i++) {
        if (nl.item(i).getAttributes().getNamedItem("name").getNodeValue().equals(strFunctionName)) {
            Node elSample = ((Element) nl.item(i)).getElementsByTagName("sample").item(0);
            if (elSample.hasChildNodes()) {
                return (elSample.getFirstChild().getNodeValue());
            }
        }
    }
    return sRC;
}

76. ScriptValuesHelp#buildFunctionList()

Project: pentaho-kettle
File: ScriptValuesHelp.java
private static void buildFunctionList() {
    hatFunctionsList = new Hashtable<String, String>();
    NodeList nlFunctions = dom.getElementsByTagName("jsFunction");
    for (int i = 0; i < nlFunctions.getLength(); i++) {
        String strFunctionName = nlFunctions.item(i).getAttributes().getNamedItem("name").getNodeValue();
        Node elType = ((Element) nlFunctions.item(i)).getElementsByTagName("type").item(0);
        String strType = "";
        if (elType.hasChildNodes()) {
            strType = elType.getFirstChild().getNodeValue();
        }
        NodeList nlFunctionArgs = ((Element) nlFunctions.item(i)).getElementsByTagName("argument");
        for (int j = 0; j < nlFunctionArgs.getLength(); j++) {
            String strFunctionArgs = nlFunctionArgs.item(j).getFirstChild().getNodeValue();
            hatFunctionsList.put(strFunctionName + "(" + strFunctionArgs + ")", strType);
        }
        if (nlFunctionArgs.getLength() == 0) {
            hatFunctionsList.put(strFunctionName + "()", strType);
        }
    }
}

77. ScriptHelp#getSample()

Project: pentaho-kettle
File: ScriptHelp.java
public String getSample(String strFunctionName, String strFunctionNameWithArgs) {
    String sRC = "// Sorry, no Script available for " + strFunctionNameWithArgs;
    NodeList nl = dom.getElementsByTagName("jsFunction");
    for (int i = 0; i < nl.getLength(); i++) {
        if (nl.item(i).getAttributes().getNamedItem("name").getNodeValue().equals(strFunctionName)) {
            Node elSample = ((Element) nl.item(i)).getElementsByTagName("sample").item(0);
            if (elSample.hasChildNodes()) {
                return (elSample.getFirstChild().getNodeValue());
            }
        }
    }
    return sRC;
}

78. ScriptHelp#buildFunctionList()

Project: pentaho-kettle
File: ScriptHelp.java
private static void buildFunctionList() {
    hatFunctionsList = new Hashtable<String, String>();
    NodeList nlFunctions = dom.getElementsByTagName("jsFunction");
    for (int i = 0; i < nlFunctions.getLength(); i++) {
        String strFunctionName = nlFunctions.item(i).getAttributes().getNamedItem("name").getNodeValue();
        Node elType = ((Element) nlFunctions.item(i)).getElementsByTagName("type").item(0);
        String strType = "";
        if (elType.hasChildNodes()) {
            strType = elType.getFirstChild().getNodeValue();
        }
        NodeList nlFunctionArgs = ((Element) nlFunctions.item(i)).getElementsByTagName("argument");
        for (int j = 0; j < nlFunctionArgs.getLength(); j++) {
            String strFunctionArgs = nlFunctionArgs.item(j).getFirstChild().getNodeValue();
            hatFunctionsList.put(strFunctionName + "(" + strFunctionArgs + ")", strType);
        }
        if (nlFunctionArgs.getLength() == 0) {
            hatFunctionsList.put(strFunctionName + "()", strType);
        }
    }
}

79. DomUtils#getChildElementsByName()

Project: pentaho-kettle
File: DomUtils.java
/**
   * <p>
   * Returns a list of child elements with the given name. Returns an empty list if there are no such child elements.
   * </p>
   *
   * @param parent
   *          parent element
   * @param localName
   *          Local name of the child element
   * @return child elements
   */
protected static List<Element> getChildElementsByName(Element parent, String localName) {
    List<Element> elements = new ArrayList<Element>();
    NodeList children = parent.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node node = children.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element element = (Element) node;
            if (element.getLocalName().equals(localName)) {
                elements.add(element);
            }
        }
    }
    return elements;
}

80. DomUtils#getChildElementByName()

Project: pentaho-kettle
File: DomUtils.java
/**
   * <p>
   * Returns the first child element with the given name. Returns <code>null</code> if not found.
   * </p>
   *
   * @param parent
   *          parent element
   * @param localName
   *          name of the child element
   * @return child element, null if not found.
   */
protected static Element getChildElementByName(Element parent, String localName) {
    NodeList children = parent.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node node = children.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element element = (Element) node;
            if (element.getLocalName().equals(localName)) {
                return element;
            }
        }
    }
    return null;
}

81. OdfSheet#isRowEmpty()

Project: pentaho-kettle
File: OdfSheet.java
/**
   * Check if row contains non-empty cells
   *
   * @param rowElem
   * @return
   */
protected boolean isRowEmpty(TableTableRowElement rowElem) {
    NodeList cells = rowElem.getChildNodes();
    int cellsLen = cells.getLength();
    for (int j = 0; j < cellsLen; j++) {
        // iterate over cells
        Node cell = cells.item(j);
        if (cell instanceof TableTableCellElement) {
            if (cell.hasChildNodes()) {
                return false;
            }
        }
    }
    return true;
}

82. OdfSheet#findNrRows()

Project: pentaho-kettle
File: OdfSheet.java
/**
   * Calculate the number of rows in the table
   *
   * @return number of rows in the table
   */
protected int findNrRows() {
    int rowCount = table.getRowCount();
    // remove last empty rows from counter
    NodeList nodes = table.getOdfElement().getChildNodes();
    int nodesLen = nodes.getLength();
    for (int i = nodesLen - 1; i >= 0; i--) {
        Node node = nodes.item(i);
        if (node instanceof TableTableRowElement) {
            TableTableRowElement rowElement = (TableTableRowElement) node;
            if (isRowEmpty(rowElement)) {
                // remove this row from counter
                rowCount -= rowElement.getTableNumberRowsRepeatedAttribute();
            } else {
                // stop checking at first non-empty row
                break;
            }
        }
    }
    return rowCount;
}

83. XMLHandler#getNodeElements()

Project: pentaho-kettle
File: XMLHandler.java
public static String[] getNodeElements(Node node) {
    // List of String
    ArrayList<String> elements = new ArrayList<String>();
    NodeList nodeList = node.getChildNodes();
    if (nodeList == null) {
        return null;
    }
    for (int i = 0; i < nodeList.getLength(); i++) {
        String nodeName = nodeList.item(i).getNodeName();
        if (elements.indexOf(nodeName) < 0) {
            elements.add(nodeName);
        }
    }
    if (elements.isEmpty()) {
        return null;
    }
    return elements.toArray(new String[elements.size()]);
}

84. XMLHandler#getNodeValue()

Project: pentaho-kettle
File: XMLHandler.java
/**
   * Find the value entry in a node
   *
   * @param n
   *          The node
   * @return The value entry as a string
   */
public static String getNodeValue(Node n) {
    if (n == null) {
        return null;
    }
    // Find the child-nodes of this Node n:
    NodeList children = n.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        // Try all children
        Node childnode = children.item(i);
        String retval = childnode.getNodeValue();
        if (retval != null) {
            // We found the right value
            return retval;
        }
    }
    return null;
}

85. XMLHandler#getSubNode()

Project: pentaho-kettle
File: XMLHandler.java
/**
   * Search for a subnode in the node with a certain tag.
   *
   * @param n
   *          The node to look in
   * @param tag
   *          The tag to look for
   * @return The subnode if the tag was found, or null if nothing was found.
   */
public static Node getSubNode(Node n, String tag) {
    int i;
    NodeList children;
    Node childnode;
    if (n == null) {
        return null;
    }
    // Get the childres one by one out of the node,
    // compare the tags and return the first found.
    //
    children = n.getChildNodes();
    for (i = 0; i < children.getLength(); i++) {
        childnode = children.item(i);
        if (childnode.getNodeName().equalsIgnoreCase(tag)) {
            return childnode;
        }
    }
    return null;
}

86. XMLHandler#getNodeWithAttributeValue()

Project: pentaho-kettle
File: XMLHandler.java
/**
   * Get node child with a certain subtag set to a certain value
   *
   * @param n
   *          The node to search in
   * @param tag
   *          The tag to look for
   * @param subtag
   *          The subtag to look for
   * @param subtagvalue
   *          The value the subtag should have
   * @param copyNr
   *          The nr of occurance of the value
   * @return The node found or null if we couldn't find anything.
   */
public static Node getNodeWithAttributeValue(Node n, String tag, String attributeName, String attributeValue) {
    NodeList children;
    Node childnode;
    children = n.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        childnode = children.item(i);
        if (childnode.getNodeName().equalsIgnoreCase(tag)) {
            // <hop>
            Node attribute = childnode.getAttributes().getNamedItem(attributeName);
            if (attribute != null && attributeValue.equals(attribute.getTextContent())) {
                return childnode;
            }
        }
    }
    return null;
}

87. XMLHandler#getNodeWithTagValue()

Project: pentaho-kettle
File: XMLHandler.java
/**
   * Get node child with a certain subtag set to a certain value
   *
   * @param n
   *          The node to search in
   * @param tag
   *          The tag to look for
   * @param subtag
   *          The subtag to look for
   * @param subtagvalue
   *          The value the subtag should have
   * @param nr
   *          The nr of occurance of the value
   * @return The node found or null if we couldn't find anything.
   */
public static Node getNodeWithTagValue(Node n, String tag, String subtag, String subtagvalue, int nr) {
    NodeList children;
    Node childnode, tagnode;
    String value;
    int count = 0;
    children = n.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        childnode = children.item(i);
        if (childnode.getNodeName().equalsIgnoreCase(tag)) {
            // <hop>
            tagnode = getSubNode(childnode, subtag);
            value = getNodeValue(tagnode);
            if (value.equalsIgnoreCase(subtagvalue)) {
                if (count == nr) {
                    return childnode;
                }
                count++;
            }
        }
    }
    return null;
}

88. XMLHandler#getNodes()

Project: pentaho-kettle
File: XMLHandler.java
/**
   * Get nodes with a certain tag one level down
   *
   * @param n
   *          The node to look in
   * @param tag
   *          The tags to count
   * @return The list of nodes found with the specified tag
   */
public static List<Node> getNodes(Node n, String tag) {
    NodeList children;
    Node childnode;
    List<Node> nodes = new ArrayList<Node>();
    if (n == null) {
        return nodes;
    }
    children = n.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        childnode = children.item(i);
        if (childnode.getNodeName().equalsIgnoreCase(tag)) {
            // <file>
            nodes.add(childnode);
        }
    }
    return nodes;
}

89. XMLHandler#countNodes()

Project: pentaho-kettle
File: XMLHandler.java
/**
   * Count nodes with a certain tag
   *
   * @param n
   *          The node to look in
   * @param tag
   *          The tags to count
   * @return The number of nodes found with a certain tag
   */
public static int countNodes(Node n, String tag) {
    NodeList children;
    Node childnode;
    int count = 0;
    if (n == null) {
        return 0;
    }
    children = n.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        childnode = children.item(i);
        if (childnode.getNodeName().equalsIgnoreCase(tag)) {
            // <file>
            count++;
        }
    }
    return count;
}

90. XMLHandler#getTagValueWithAttribute()

Project: pentaho-kettle
File: XMLHandler.java
/**
   * Get the value of a tag in a node
   *
   * @param n
   *          The node to look in
   * @param tag
   *          The tag to look for
   * @return The value of the tag or null if nothing was found.
   */
public static String getTagValueWithAttribute(Node n, String tag, String attribute) {
    NodeList children;
    Node childnode;
    if (n == null) {
        return null;
    }
    children = n.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        childnode = children.item(i);
        if (childnode.getNodeName().equalsIgnoreCase(tag) && childnode.getAttributes().getNamedItem(attribute) != null) {
            if (childnode.getFirstChild() != null) {
                return childnode.getFirstChild().getNodeValue();
            }
        }
    }
    return null;
}

91. XMLHandler#getTagValue()

Project: pentaho-kettle
File: XMLHandler.java
/**
   * Get the value of a tag in a node
   *
   * @param n
   *          The node to look in
   * @param tag
   *          The tag to look for
   * @return The value of the tag or null if nothing was found.
   */
public static String getTagValue(Node n, String tag) {
    NodeList children;
    Node childnode;
    if (n == null) {
        return null;
    }
    children = n.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        childnode = children.item(i);
        if (childnode.getNodeName().equalsIgnoreCase(tag)) {
            if (childnode.getFirstChild() != null) {
                return childnode.getFirstChild().getNodeValue();
            }
        }
    }
    return null;
}

92. XMLUtil#getNodeValue()

Project: PdfBox-Android
File: XMLUtil.java
/**
     * This will get the text value of an element.
     *
     * @param node The node to get the text value for.
     * @return The text of the node.
     */
public static String getNodeValue(Element node) {
    String retval = "";
    NodeList children = node.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node next = children.item(i);
        if (next instanceof Text) {
            retval = next.getNodeValue();
        }
    }
    return retval;
}

93. XMLUtil#getNodeValue()

Project: PdfBox-Android
File: XMLUtil.java
/**
     * This will get the text value of an element.
     *
     * @param node The node to get the text value for.
     * @return The text of the node.
     */
public static String getNodeValue(Element node) {
    StringBuilder sb = new StringBuilder();
    NodeList children = node.getChildNodes();
    int numNodes = children.getLength();
    for (int i = 0; i < numNodes; i++) {
        Node next = children.item(i);
        if (next instanceof Text) {
            sb.append(next.getNodeValue());
        }
    }
    return sb.toString();
}

94. DomHelper#getElementChildren()

Project: pdfbox
File: DomHelper.java
public static List<Element> getElementChildren(Element description) throws XmpParsingException {
    NodeList nl = description.getChildNodes();
    List<Element> ret = new ArrayList<Element>(nl.getLength());
    for (int i = 0; i < nl.getLength(); i++) {
        if (nl.item(i) instanceof Element) {
            ret.add((Element) nl.item(i));
        }
    }
    return ret;
}

95. DomHelper#getFirstChildElement()

Project: pdfbox
File: DomHelper.java
/**
     * Return the first child element of the element parameter. If there is no child, null is returned
     * 
     * @param description
     * @return the first child element. Might be null.
     * @throws XmpParsingException
     */
public static Element getFirstChildElement(Element description) throws XmpParsingException {
    NodeList nl = description.getChildNodes();
    for (int i = 0; i < nl.getLength(); i++) {
        if (nl.item(i) instanceof Element) {
            return (Element) nl.item(i);
        }
    }
    return null;
}

96. DomHelper#getUniqueElementChild()

Project: pdfbox
File: DomHelper.java
public static Element getUniqueElementChild(Element description) throws XmpParsingException {
    NodeList nl = description.getChildNodes();
    int pos = -1;
    for (int i = 0; i < nl.getLength(); i++) {
        if (nl.item(i) instanceof Element) {
            if (pos >= 0) {
                // invalid : found two child elements
                throw new XmpParsingException(ErrorType.Undefined, "Found two child elements in " + description);
            } else {
                pos = i;
            }
        }
    }
    return (Element) nl.item(pos);
}

97. XMLUtil#getNodeValue()

Project: pdfbox
File: XMLUtil.java
/**
     * This will get the text value of an element.
     *
     * @param node The node to get the text value for.
     * @return The text of the node.
     */
public static String getNodeValue(Element node) {
    StringBuilder sb = new StringBuilder();
    NodeList children = node.getChildNodes();
    int numNodes = children.getLength();
    for (int i = 0; i < numNodes; i++) {
        Node next = children.item(i);
        if (next instanceof Text) {
            sb.append(next.getNodeValue());
        }
    }
    return sb.toString();
}

98. DCTFilter#getAdobeTransform()

Project: pdfbox
File: DCTFilter.java
// reads the APP14 Adobe transform tag and returns its value, or 0 if unknown
private Integer getAdobeTransform(IIOMetadata metadata) {
    Element tree = (Element) metadata.getAsTree("javax_imageio_jpeg_image_1.0");
    Element markerSequence = (Element) tree.getElementsByTagName("markerSequence").item(0);
    NodeList app14AdobeNodeList = markerSequence.getElementsByTagName("app14Adobe");
    if (app14AdobeNodeList != null && app14AdobeNodeList.getLength() > 0) {
        Element adobe = (Element) app14AdobeNodeList.item(0);
        return Integer.parseInt(adobe.getAttribute("transform"));
    }
    return 0;
}

99. SamlCompliantLogoutMessageCreatorTests#verifyMessageBuilding()

Project: passport
File: SamlCompliantLogoutMessageCreatorTests.java
@Test
public void verifyMessageBuilding() throws Exception {
    final SingleLogoutService service = mock(SingleLogoutService.class);
    when(service.getOriginalUrl()).thenReturn(TestUtils.CONST_TEST_URL);
    final URL logoutUrl = new URL(service.getOriginalUrl());
    final DefaultLogoutRequest request = new DefaultLogoutRequest("TICKET-ID", service, logoutUrl);
    final String msg = builder.create(request);
    final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    final DocumentBuilder builder = factory.newDocumentBuilder();
    final InputStream is = new ByteArrayInputStream(msg.getBytes());
    final Document document = builder.parse(is);
    final NodeList list = document.getDocumentElement().getElementsByTagName("samlp:SessionIndex");
    assertEquals(list.getLength(), 1);
    assertEquals(list.item(0).getTextContent(), request.getTicketId());
}

100. SamlCompliantLogoutMessageCreatorTests#verifyMessageBuilding()

Project: passport
File: SamlCompliantLogoutMessageCreatorTests.java
@Test
public void verifyMessageBuilding() throws Exception {
    final SingleLogoutService service = mock(SingleLogoutService.class);
    when(service.getOriginalUrl()).thenReturn(TestUtils.CONST_TEST_URL);
    final URL logoutUrl = new URL(service.getOriginalUrl());
    final DefaultLogoutRequest request = new DefaultLogoutRequest("TICKET-ID", service, logoutUrl);
    final String msg = builder.create(request);
    final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    final DocumentBuilder builder = factory.newDocumentBuilder();
    final InputStream is = new ByteArrayInputStream(msg.getBytes());
    final Document document = builder.parse(is);
    final NodeList list = document.getDocumentElement().getElementsByTagName("samlp:SessionIndex");
    assertEquals(list.getLength(), 1);
    assertEquals(list.item(0).getTextContent(), request.getTicketId());
}