Java Code Examples for org.w3c.dom.NodeList
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project CheckIn4Me, under directory /src/com/davidivins/checkin4me/core/.
Source file: ServiceSetting.java

/** * constructor */ public ServiceSetting(Element xml,SharedPreferences persistent_storage){ NodeList display_names=xml.getElementsByTagName("display_name"); NodeList pref_names=xml.getElementsByTagName("pref_name"); Element display_name=(Element)display_names.item(0); Element pref_name=(Element)pref_names.item(0); this.display_name=display_name.getFirstChild().getNodeValue(); this.pref_name=pref_name.getFirstChild().getNodeValue(); this.persistent_storage=persistent_storage; this.persistent_storage_editor=persistent_storage.edit(); Log.i(TAG,"display_name = " + this.display_name); Log.i(TAG,"pref_name = " + this.pref_name); }
Example 2
From project bioportal-service, under directory /src/main/java/edu/mayo/cts2/framework/plugin/service/bioportal/transform/.
Source file: EntityDescriptionTransform.java

/** * Gets the children text map. * @param parentNode the parent node * @param children the children * @return the children text map */ public Map<String,String> getChildrenTextMap(Node parentNode,String... children){ Set<String> childrenSet=new HashSet<String>(Arrays.asList(children)); Map<String,String> returnMap=new HashMap<String,String>(); NodeList childList=parentNode.getChildNodes(); for (int i=0; i < childList.getLength(); i++) { Node child=childList.item(i); String nodeName=child.getNodeName(); if (childrenSet.contains(nodeName)) { returnMap.put(nodeName,TransformUtils.getNodeText(child)); } } return returnMap; }
Example 3
From project cilia-workbench, under directory /cilia-workbench-common/src/fr/liglab/adele/cilia/workbench/common/xml/.
Source file: XMLHelpers.java

/** * Gets the root node in a document. * @param document the document * @param nodeName the node name * @return the root node * @throws CiliaException if the root node doesn't match nodeName. */ public static Node getRootNode(Document document,String nodeName) throws CiliaException { NodeList nodes=document.getChildNodes(); if (nodes != null) { for (int i=0; i < nodes.getLength(); i++) if (nodes.item(i).getNodeName().equalsIgnoreCase(nodeName)) return nodes.item(i); } throw new CiliaException("Can't find root node " + nodeName); }
Example 4
From project addis, under directory /application/src/main/java/org/drugis/addis/imports/.
Source file: PubMedIDRetriever.java

private PubMedIdList getIdList(Document docTwo){ NodeList PID=docTwo.getElementsByTagName("Id"); PubMedIdList PubMedID=new PubMedIdList(); for (int i=0; i < PID.getLength(); i++) { PubMedID.add(new PubMedId(PID.item(i).getFirstChild().getNodeValue())); } return PubMedID; }
Example 5
public void readConnectionsXML() throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbFactory=DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder=dbFactory.newDocumentBuilder(); Document doc=dBuilder.parse(getClass().getResourceAsStream("/got/resource/xml/connection.xml")); doc.getDocumentElement().normalize(); NodeList nList=doc.getElementsByTagName("Connection"); for (int temp=0; temp < nList.getLength(); temp++) { Node nNode=nList.item(temp); String t1=nNode.getAttributes().getNamedItem("t1").getNodeValue(); String t2=nNode.getAttributes().getNamedItem("t2").getNodeValue(); getConnTerritories().get(t1).add(t2); getConnTerritories().get(t2).add(t1); } }
Example 6
From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/config/.
Source file: DocumentUtil.java

/** * ??????????????????? ConfigurationException ??? ?????????null * @param current * @param tagName * @return */ public static Element getTheOnlyElement(Element current,String tagName){ NodeList nodeList=current.getElementsByTagName(tagName); if (nodeList.getLength() > 1) { throw new ConfigurationException(tagName + " elements length over one!"); } if (nodeList.getLength() == 1) { return (Element)nodeList.item(0); } else { return null; } }
Example 7
From project android-client_1, under directory /src/com/googlecode/asmack/.
Source file: XMLUtils.java

/** * Return the first child of a node, based on name/namespace. * @param node The node to scan. * @param namespace The requested namespace, or null for no preference. * @param name The element name, or null for no preference. * @return The first matching node or null. */ public static Node getFirstChild(Node node,String namespace,String name){ NodeList childNodes=node.getChildNodes(); for (int i=0, l=childNodes.getLength(); i < l; i++) { Node child=childNodes.item(i); if (isInstance(child,namespace,name)) { return child; } } return null; }
Example 8
/** * Return a node that represents the first matched tag. A dummy node is returned if none found. * @param tag tag name * @return the xml dom * @see testTag */ public XmlDom tag(String tag){ NodeList nl=root.getElementsByTagName(tag); XmlDom result=null; if (nl != null && nl.getLength() > 0) { result=new XmlDom((Element)nl.item(0)); } return result; }
Example 9
From project any23, under directory /core/src/main/java/org/apache/any23/extractor/html/.
Source file: HTMLDocument.java

/** * Returns the text contained inside a node if leaf, <code>null</code> otherwise. * @return the text of a leaf node. */ public String getText(){ NodeList children=getDocument().getChildNodes(); if (children.getLength() == 1 && children.item(0) instanceof Text) { return children.item(0).getTextContent(); } return null; }
Example 10
private static Element getElementByName(Element element,String name){ Element result=null; NodeList children=element.getElementsByTagName(name); for (int i=0; i < children.getLength(); i++) { Node node=children.item(i); if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals(name)) { result=(Element)node; break; } } return result; }
Example 11
From project aranea, under directory /server/src/main/java/no/dusken/aranea/admin/control/.
Source file: ImportStvMediaController.java

/** * I take a xml element and the tag name, look for the tag and get the text content i.e for <employee><name>John</name></employee> xml snippet if the Element points to employee node and tagName is name I will return John */ private String getTextValue(Element ele,String tagName){ String textVal=null; NodeList nl=ele.getElementsByTagName(tagName); if (nl != null && nl.getLength() > 0) { Element el=(Element)nl.item(0); textVal=el.getFirstChild().getNodeValue(); } return textVal; }
Example 12
From project Archimedes, under directory /br.org.archimedes.io.xml/src/br/org/archimedes/io/xml/parsers/.
Source file: DimensionParser.java

@Override public Element parse(Node node) throws ElementCreationException { NodeList nodesCollection=((org.w3c.dom.Element)node).getElementsByTagName("size"); if (nodesCollection.getLength() == 1) { Node childNode=nodesCollection.item(0); this.size=XMLUtils.nodeToDouble(childNode); return super.parse(node); } return null; }
Example 13
From project arquillian-container-jbossas, under directory /jbossas-managed-4.2/src/main/java/org/jboss/arquillian/container/jbossas/managed_4_2/.
Source file: ManagementViewParser.java

private static List<String> extractServletNames(String descriptor) throws Exception { Document doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(descriptor.getBytes())); XPathExpression xPathExpression=XPathFactory.newInstance().newXPath().compile("/web-app/servlet/servlet-name"); NodeList nodes=(NodeList)xPathExpression.evaluate(doc,XPathConstants.NODESET); List<String> servletNames=new ArrayList<String>(); for (int i=0; i < nodes.getLength(); i++) { Node node=nodes.item(i); servletNames.add(node.getTextContent()); } return servletNames; }
Example 14
From project arquillian-core, under directory /config/impl-base/src/test/java/org/jboss/arquillian/config/descriptor/impl/.
Source file: AssertXPath.java

/** * Assert that the specified XPath Expression resolves to the specified values. <br/><br/> Assertions:<br/> "ExpectedValue count should match found Node count" <br/> "XPath content should match expected value" <br/> * @param xml The XML to assert against * @param expression XPath expression to extract * @param expectedValue The Expected values found by expression * @throws Exception XML/XPath related parse exceptions */ public static void assertXPath(String xml,String expression,Object... expectedValue) throws Exception { Document doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(xml.getBytes())); XPathExpression xPathExpression=XPathFactory.newInstance().newXPath().compile(expression); NodeList nodes=(NodeList)xPathExpression.evaluate(doc,XPathConstants.NODESET); Assert.assertEquals("ExpectedValue count should match found Node count",expectedValue.length,nodes.getLength()); for (int i=0; i < nodes.getLength(); i++) { Node node=nodes.item(i); Assert.assertEquals("XPath content should match expected value",String.valueOf(expectedValue[i]),node.getTextContent()); } }
Example 15
From project arquillian_deprecated, under directory /containers/glassfish-remote-3.1/src/main/java/org/jboss/arquillian/container/glassfish/remote_3_1/.
Source file: GlassFishRestDeployableContainer.java

private ProtocolMetaData parseForProtocolMetaData(String xmlResponse) throws XPathExpressionException { final ProtocolMetaData protocolMetaData=new ProtocolMetaData(); final HTTPContext httpContext=new HTTPContext(this.configuration.getRemoteServerAddress(),this.configuration.getRemoteServerHttpPort()); final XPath xpath=XPathFactory.newInstance().newXPath(); NodeList servlets=(NodeList)xpath.evaluate("/map/entry[@key = 'properties']/map/entry[@value = 'Servlet']",new InputSource(new StringReader(xmlResponse)),XPathConstants.NODESET); for (int i=0; i < servlets.getLength(); i++) { httpContext.add(new Servlet(servlets.item(i).getAttributes().getNamedItem("key").getNodeValue(),this.deploymentName)); } protocolMetaData.addContext(httpContext); return protocolMetaData; }
Example 16
From project as3-commons-jasblocks, under directory /src/main/java/org/as3commons/asblocks/impl/.
Source file: SWCResourceRoot.java

private List<ASQName> readCatalog(InputStream in) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException { Document doc=loadDoc(in); XPathFactory fact=XPathFactory.newInstance(); XPath xpath=fact.newXPath(); NodeList list=(NodeList)xpath.evaluate("/swc/libraries/library/script/def",doc,XPathConstants.NODESET); List<ASQName> result=new ArrayList<ASQName>(); for (int i=0; i < list.getLength(); i++) { Element def=(Element)list.item(i); String defined=def.getAttribute("id"); result.add(toQName(defined)); } return result; }
Example 17
From project AsmackService, under directory /src/com/googlecode/asmack/.
Source file: XMLUtils.java

/** * Return the first child of a node, based on name/namespace. * @param node The node to scan. * @param namespace The requested namespace, or null for no preference. * @param name The element name, or null for no preference. * @return The first matching node or null. */ public static Node getFirstChild(Node node,String namespace,String name){ NodeList childNodes=node.getChildNodes(); for (int i=0, l=childNodes.getLength(); i < l; i++) { Node child=childNodes.item(i); if (isInstance(child,namespace,name)) { return child; } } return null; }
Example 18
From project azure-sdk-for-java-samples, under directory /WAAD.WebSSO.JAVA/java/code/libraries/waad-federation/src/main/java/com/microsoft/samples/waad/federation/.
Source file: TrustedIssuersRepository.java

public Iterable<TrustedIssuer> getTrustedIdentityProviderUrls() throws ParserConfigurationException, SAXException, IOException { List<TrustedIssuer> trustedIssuers=new ArrayList<TrustedIssuer>(); DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder=factory.newDocumentBuilder(); Document document=documentBuilder.parse(getRepositoryStream()); NodeList xmlTrustedIssuers=document.getFirstChild().getChildNodes(); for (int i=0; i < xmlTrustedIssuers.getLength(); i++) { Node xmlTrustedIssuer=xmlTrustedIssuers.item(i); if (xmlTrustedIssuer instanceof Element) { trustedIssuers.add(new TrustedIssuer(xmlTrustedIssuer.getAttributes().getNamedItem(Constants.REPOSITORY_NAME_ATTRIBUTE).getTextContent(),xmlTrustedIssuer.getAttributes().getNamedItem(Constants.REPOSITORY_DISPLAY_NAME_ATTRIBUTE).getTextContent(),xmlTrustedIssuer.getAttributes().getNamedItem(Constants.REPOSITORY_REALM_ATTRIBUTE).getTextContent())); } } return trustedIssuers; }
Example 19
From project bam, under directory /release/jbossas/tests/activity-management/bean-service/src/main/java/org/overlord/bam/tests/actmgmt/jbossas/beanservice/.
Source file: Transformers.java

/** * Returns the text value of a child node of parent. */ private String getElementValue(Element parent,String elementName){ String value=null; NodeList nodes=parent.getElementsByTagName(elementName); if (nodes.getLength() > 0) { value=nodes.item(0).getChildNodes().item(0).getNodeValue(); } return value; }
Example 20
From project bbb-java, under directory /src/main/java/org/mconf/bbb/api/.
Source file: ParserUtils.java

static public String getNodeValue(Element element,String tagName){ NodeList list=element.getElementsByTagName(tagName); if (list != null && list.getLength() > 0 && list.item(0) != null && list.item(0).getFirstChild() != null) { return list.item(0).getFirstChild().getNodeValue(); } else return ""; }
Example 21
From project blueprint-namespaces, under directory /blueprint/blueprint-cm/src/main/java/org/apache/aries/blueprint/compendium/cm/.
Source file: CmNamespaceHandler.java

private static String getTextValue(Element element){ StringBuffer value=new StringBuffer(); NodeList nl=element.getChildNodes(); for (int i=0; i < nl.getLength(); i++) { Node item=nl.item(i); if ((item instanceof CharacterData && !(item instanceof Comment)) || item instanceof EntityReference) { value.append(item.getNodeValue()); } } return value.toString(); }
Example 22
From project bpelunit, under directory /net.bpelunit.framework/src/main/java/net/bpelunit/framework/control/util/.
Source file: XPathTool.java

public List<Node> evaluateAsList(String query,Object item) throws XPathExpressionException { NodeList nodes=(NodeList)fXPath.evaluate(query,item,XPathConstants.NODESET); List<Node> list=new ArrayList<Node>(); for (int i=0; i < nodes.getLength(); ++i) { list.add(nodes.item(i)); } return list; }
Example 23
From project BukkitUtilities, under directory /src/main/java/name/richardson/james/bukkit/utilities/updater/.
Source file: MavenManifest.java

public MavenManifest(final File file) throws SAXException, IOException, ParserConfigurationException { final DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder=docBuilderFactory.newDocumentBuilder(); final Document doc=docBuilder.parse(file); doc.getDocumentElement().normalize(); final NodeList root=doc.getChildNodes(); final Node meta=this.getNode("metadata",root); final Node versioning=this.getNode("versioning",meta.getChildNodes()); final Node versions=this.getNode("versions",versioning.getChildNodes()); final NodeList nodes=versions.getChildNodes(); this.setVersionList(nodes); file.deleteOnExit(); }
Example 24
From project C-Cat, under directory /util/src/main/java/gov/llnl/ontology/text/corpora/.
Source file: NYTDocumentReader.java

public static NYTCorpusDocument parseNYTCorpusDocumentFromDOMDocument(File file,Document document){ NYTCorpusDocument ldcDocument=new NYTCorpusDocument(); ldcDocument.setSourceFile(file); NodeList children=document.getChildNodes(); for (int i=0; i < children.getLength(); i++) { Node child=children.item(i); String name=child.getNodeName(); if (name.equals(NITF_TAG)) { handleNITFNode(child,ldcDocument); } } return ldcDocument; }
Example 25
From project capedwarf-blue, under directory /common/src/main/java/org/jboss/capedwarf/common/xml/.
Source file: XmlUtils.java

public static String getBody(Element element){ NodeList nodes=element.getChildNodes(); if (nodes == null || nodes.getLength() == 0) return null; Node firstNode=nodes.item(0); if (firstNode == null) return null; return firstNode.getNodeValue(); }
Example 26
From project Cilia_1, under directory /framework/runtime/src/main/java/fr/liglab/adele/cilia/admin/impl/.
Source file: CiliaChainInstanceParser.java

protected String getNodeValue(Node node){ NodeList childNode=node.getChildNodes(); String value=null; for (int i=0; childNode != null && i < childNode.getLength(); i++) { Node chnode=childNode.item(i); if (chnode.getNodeType() == Node.TEXT_NODE) { value=chnode.getNodeValue(); break; } } return value; }
Example 27
From project CIShell, under directory /clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/.
Source file: MenuAdapter.java

private void createMenuFromXML(String menuFilePath) throws InvalidSyntaxException { parseXMLFile(menuFilePath); Element documentElement=this.documentObjectModel.getDocumentElement(); NodeList topMenuList=documentElement.getElementsByTagName(TAG_TOP_MENU); if ((topMenuList != null) && (topMenuList.getLength() > 0)) { for (int ii=0; ii < topMenuList.getLength(); ii++) { Element element=(Element)topMenuList.item(ii); processTopMenu(element); } } }
Example 28
From project CloudReports, under directory /src/main/java/cloudreports/extensions/.
Source file: ExtensionsLoader.java

/** * Gets the aliases of all extension implementations of a given base class. It reads the classnames.xml file to get the list of aliases. * @param type the type of the extension. * @return a list of aliases of all extension implementationsof the given base class. * @since 1.0 */ public static List<String> getExtensionsAliasesByType(String type){ List<String> listAliases=new ArrayList<String>(); if (classnamesXml == null) return listAliases; NodeList classNodes=classnamesXml.getElementsByTagName("class"); for (int index=0; index < classNodes.getLength(); index++) { try { if (classNodes.item(index).getAttributes().getNamedItem("type").getNodeValue().equals(type)) listAliases.add(classNodes.item(index).getAttributes().getNamedItem("alias").getNodeValue()); } catch ( NullPointerException e) { continue; } } return listAliases; }
Example 29
From project codjo-data-process, under directory /codjo-data-process-gui/src/main/java/net/codjo/dataprocess/gui/treatmenthelper/.
Source file: TreatmentHelperGui.java

public static void checkRepositoryContent(String repositoryName,String repositoryPath,String content) throws Exception { Document doc=XMLUtils.parse(content); NodeList nodes=doc.getElementsByTagName(DataProcessConstants.TREATMENT_ENTITY_XML); int nbNodes=nodes.getLength(); for (int i=0; i < nbNodes; i++) { Node node=nodes.item(i); String treatmentId=node.getAttributes().getNamedItem("id").getNodeValue(); if (treatmentId.length() > 50) { throw new TreatmentException("La taille de l'identifiant d'un traitement ('" + treatmentId + "') d?asse 50 caract?es dans le repository '"+ repositoryName+ "' !\n(Il est dans le fichier : "+ repositoryPath+ ")"); } } }
Example 30
From project comm, under directory /src/main/java/io/s4/comm/util/.
Source 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; }
Example 31
From project components, under directory /soap/src/main/java/org/switchyard/component/soap/composer/.
Source file: SOAPMessageComposer.java

private List<Element> getChildElements(Node parent){ List<Element> children=new ArrayList<Element>(); NodeList nodes=parent.getChildNodes(); for (int i=0; i < nodes.getLength(); i++) { if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE) { children.add((Element)nodes.item(i)); } } return children; }
Example 32
From project constretto-core, under directory /constretto-spring/src/main/java/org/constretto/spring/internal/.
Source file: ConstrettoNamespaceHandler.java

public List<Element> getAllChildElements(Element element){ Assert.notNull(element,"Element must not be null"); NodeList childNodes=element.getChildNodes(); List<Element> childElements=new ArrayList<Element>(); for (int i=0; i < childNodes.getLength(); i++) { Node node=childNodes.item(i); if (node instanceof Element) { childElements.add((Element)node); } } return childElements; }
Example 33
From project core_1, under directory /common/src/main/java/org/switchyard/common/xml/.
Source file: XMLHelper.java

/** * Get the first child Element of the supplied node that matches a given tag name. * @param node The DOM Node. * @param name The name of the child node to search for. * @return The first child element with the matching tag name. */ public static Element getFirstChildElementByName(Node node,String name){ NodeList children=node.getChildNodes(); int childCount=children.getLength(); for (int i=0; i < childCount; i++) { Node child=children.item(i); if (child != null && child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName() != null && child.getNodeName().equals(name)) { return (Element)child; } } return null; }
Example 34
From project Absolute-Android-RSS, under directory /src/com/AA/Other/.
Source file: RSSParse.java

/** * Get the list of articles currently contained in the RSS feed. * @param isBackground if the request is being run in the background * @param callingContext current application context * @return List of articles contained in the RSS on success. On failure returns null */ public static List<Article> getArticles(boolean isBackground,Context callingContext){ if (!isNetworkAvailable(isBackground,callingContext)) return null; Document doc=getDocument(); if (doc == null) return null; try { ArrayList<Article> articles=new ArrayList<Article>(); NodeList items=doc.getElementsByTagName("item"); for (int i=0; i < items.getLength(); i++) { Element el=(Element)items.item(i); String title=el.getElementsByTagName("title").item(0).getFirstChild().getNodeValue(); String date=el.getElementsByTagName("pubDate").item(0).getFirstChild().getNodeValue(); String url=el.getElementsByTagName("link").item(0).getFirstChild().getNodeValue(); String desc=el.getElementsByTagName("description").item(0).getFirstChild().getNodeValue(); articles.add(new Article(desc,title,date,url)); } return articles; } catch ( Exception e) { Log.e("AARSS","Error Parsing RSS",e); return null; } }
Example 35
From project adt-maven-plugin, under directory /src/main/java/com/yelbota/plugins/adt/model/.
Source file: AneModel.java

private void parseXml(byte[] s) throws MojoFailureException { DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); try { DocumentBuilder db=dbf.newDocumentBuilder(); Document dom=db.parse(new InputSource(new ByteArrayInputStream(s))); NodeList nl=dom.getDocumentElement().getChildNodes(); for (int i=0; i < nl.getLength(); i++) { Object uel=nl.item(i); if (uel instanceof Element) { Element el=(Element)uel; String nodeName=el.getNodeName(); if (nodeName.equals("id")) id=el.getTextContent(); } } } catch ( ParserConfigurationException e) { throwParseFail(file,e); } catch ( SAXException e) { throwParseFail(file,e); } catch ( IOException e) { throwParseFail(file,e); } }
Example 36
From project amplafi-sworddance, under directory /src/main/java/com/sworddance/util/.
Source file: AbstractXmlParser.java

/** * For what ever reason this function is not available via the javax.xml api * @param parent * @param tagnames * @return */ protected NodeListImpl getChildElementsByTagName(Node parent,boolean onlyAllowed,String... tagnames){ NodeListImpl nodeList=new NodeListImpl(); List<String> tags=Arrays.asList(tagnames); NodeList children=parent.getChildNodes(); for (int i=0; i < children.getLength(); i++) { Node child=children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { if (tags.contains(child.getNodeName())) { nodeList.add(child); } else if (onlyAllowed) { ApplicationIllegalArgumentException.fail("Child element is named ",child.getNodeName()," only ",join(tagnames,",")," are permitted"); } } } return nodeList; }
Example 37
From project android-joedayz, under directory /Proyectos/LectorFeeds/src/com/android/joedayz/demo/.
Source file: XMLParser.java

public LinkedList<HashMap<String,String>> parse(){ DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); LinkedList<HashMap<String,String>> entries=new LinkedList<HashMap<String,String>>(); HashMap<String,String> entry; try { DocumentBuilder builder=factory.newDocumentBuilder(); Document dom=builder.parse(this.url.openConnection().getInputStream()); Element root=dom.getDocumentElement(); NodeList items=root.getElementsByTagName("item"); for (int i=0; i < items.getLength(); i++) { entry=new HashMap<String,String>(); Node item=items.item(i); NodeList properties=item.getChildNodes(); for (int j=0; j < properties.getLength(); j++) { Node property=properties.item(j); String name=property.getNodeName(); if (name.equalsIgnoreCase("title")) { entry.put(Main.DATA_TITLE,property.getFirstChild().getNodeValue()); } else if (name.equalsIgnoreCase("link")) { entry.put(Main.DATA_LINK,property.getFirstChild().getNodeValue()); } } entries.add(entry); } } catch ( Exception e) { throw new RuntimeException(e); } return entries; }
Example 38
From project ant4eclipse, under directory /org.ant4eclipse.ant.pde/src/org/ant4eclipse/ant/pde/.
Source file: PatchFeatureManifestTask.java

/** * Replaces the given plug-in-versions in given feature.xml-File. * @param featureXml The feature.xml file. NOTE: this file will be <b>changed</b> and thus must be writable * @param qualifier The new version for this feature. If set to null, the "version"-attribute of the "feature"-tag won't be changed * @param newBundleVersions A map containing plugin-id (String) - version (String) associations * @throws Exception */ protected void replaceVersions(File featureXml,String qualifier,StringMap newBundleVersions) throws Exception { Assure.notNull("featureXml",featureXml); Assure.assertTrue(featureXml.isFile(),"featureXml (" + featureXml + ") must point to an existing file"); DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document featureDom=builder.parse(featureXml); if (qualifier != null) { Element featureElement=featureDom.getDocumentElement(); String featureVersion=featureElement.getAttribute("version"); if (featureVersion != null && featureVersion.endsWith(".qualifier")) { featureElement.setAttribute("version",PdeBuildHelper.resolveVersion(new Version(featureVersion),qualifier).toString()); } } NodeList pluginNodes=featureDom.getDocumentElement().getElementsByTagName("plugin"); for (int i=0; i < pluginNodes.getLength(); i++) { Element element=(Element)pluginNodes.item(i); String id=element.getAttribute("id"); if (newBundleVersions.containsKey(id)) { String version=newBundleVersions.get(id); element.setAttribute("version",version); } } DOMSource domSource=new DOMSource(featureDom); Transformer transformer=TransformerFactory.newInstance().newTransformer(); StreamResult result=new StreamResult(featureXml); transformer.transform(domSource,result); }
Example 39
From project apps-for-android, under directory /CLiCkin2DaBeaT/src/com/google/clickin2dabeat/.
Source file: C2B.java

private void runC2B(Document c2b){ Node root=c2b.getElementsByTagName("c2b").item(0); title=root.getAttributes().getNamedItem("title").getNodeValue(); author=root.getAttributes().getNamedItem("author").getNodeValue(); level=root.getAttributes().getNamedItem("level").getNodeValue(); media=root.getAttributes().getNamedItem("media").getNodeValue(); NodeList beats=c2b.getElementsByTagName("beat"); targets=new ArrayList<Target>(); for (int i=0; i < beats.getLength(); i++) { NamedNodeMap attribs=beats.item(i).getAttributes(); double time=Double.parseDouble(attribs.getNamedItem("time").getNodeValue()); int x=Integer.parseInt(attribs.getNamedItem("x").getNodeValue()); int y=Integer.parseInt(attribs.getNamedItem("y").getNodeValue()); String colorStr=attribs.getNamedItem("color").getNodeValue(); targets.add(new Target(time,x,y,colorStr)); } if ((beats.getLength() == 0) || forceEditMode) { displayCreateLevelAlert(); } else { videoUri=Uri.parse(media); background.setVideoURI(videoUri); } }
Example 40
From project arquillian-extension-persistence, under directory /impl/src/main/java/org/jboss/arquillian/persistence/core/configuration/.
Source file: PersistenceDescriptorParser.java

public String obtainDataSourceName(final String descriptor){ try { final Document document=factory.newDocumentBuilder().parse(new ByteArrayInputStream(descriptor.getBytes())); final NodeList persistenceUnits=document.getElementsByTagName("persistence-unit"); if (persistenceUnits.getLength() > 1) { throw new MultiplePersistenceUnitsException("Multiple persistence units defined. Please specify default data source either in 'arquillian.xml' or by using @DataSource annotation"); } final Node persistenceUnit=persistenceUnits.item(0); Node dataSource=getJtaDataSource(persistenceUnit); if (dataSource == null) { dataSource=getNonJtaDataSource(persistenceUnit); } return dataSource.getTextContent(); } catch ( SAXException e) { throw new PersistenceDescriptorParsingException("Unable to parse descriptor " + descriptor,e); } catch ( IOException e) { throw new PersistenceDescriptorParsingException("Unable to parse descriptor " + descriptor,e); } catch ( ParserConfigurationException e) { throw new PersistenceDescriptorParsingException("Unable to parse descriptor " + descriptor,e); } }
Example 41
From project autopsy, under directory /RecentActivity/src/org/sleuthkit/autopsy/recentactivity/.
Source file: SearchEngineURLQueryAnalyzer.java

private void createEngines(){ NodeList nlist=xmlinput.getElementsByTagName("SearchEngine"); SearchEngineURLQueryAnalyzer.SearchEngine[] listEngines=new SearchEngineURLQueryAnalyzer.SearchEngine[nlist.getLength()]; for (int i=0; i < nlist.getLength(); i++) { try { NamedNodeMap nnm=nlist.item(i).getAttributes(); String EngineName=nnm.getNamedItem("engine").getNodeValue(); String EnginedomainSubstring=nnm.getNamedItem("domainSubstring").getNodeValue(); Map<String,String> splits=new HashMap<String,String>(); NodeList listSplits=xmlinput.getElementsByTagName("splitToken"); for (int k=0; k < listSplits.getLength(); k++) { if (listSplits.item(k).getParentNode().getAttributes().getNamedItem("engine").getNodeValue().equals(EngineName)) { splits.put(listSplits.item(k).getAttributes().getNamedItem("plainToken").getNodeValue(),listSplits.item(k).getAttributes().getNamedItem("regexToken").getNodeValue()); } } SearchEngineURLQueryAnalyzer.SearchEngine Se=new SearchEngineURLQueryAnalyzer.SearchEngine(EngineName,EnginedomainSubstring,splits); System.out.println("Search Engine: " + Se.toString()); listEngines[i]=Se; } catch ( Exception e) { logger.log(Level.WARNING,"Unable to create search engines!",e); } } engines=listEngines; }
Example 42
From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/regions/.
Source file: RegionMetadataParser.java

/** * Parses the specified input stream and returns a list of the regions declared in it. * @param input The stream containing the region metadata to parse. * @return The list of parsed regions. */ public List<Region> parseRegionMetadata(InputStream input){ Document document; try { DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder=factory.newDocumentBuilder(); document=documentBuilder.parse(input); } catch ( Exception e) { throw new RuntimeException("Unable to parse region metadata file: " + e.getMessage(),e); } NodeList regionNodes=document.getElementsByTagName(REGION_TAG); List<Region> regions=new ArrayList<Region>(); for (int i=0; i < regionNodes.getLength(); i++) { Node node=regionNodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element=(Element)node; regions.add(parseRegionElement(element)); } } return regions; }
Example 43
From project b3log-latke, under directory /latke/src/main/java/org/b3log/latke/cron/.
Source file: CronService.java

/** * Loads cron.xml. */ private static void loadCronXML(){ final String webRoot=AbstractServletListener.getWebRoot(); final File cronXML=new File(webRoot + File.separator + "WEB-INF"+ File.separator+ "cron.xml"); if (!cronXML.exists()) { LOGGER.log(Level.INFO,"Not found cron.xml, no cron jobs need to schedule"); return; } final DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance(); try { final DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder(); final Document document=documentBuilder.parse(cronXML); final Element root=document.getDocumentElement(); root.normalize(); final NodeList crons=root.getElementsByTagName("cron"); LOGGER.log(Level.CONFIG,"Reading cron jobs: "); for (int i=0; i < crons.getLength(); i++) { final Element cronElement=(Element)crons.item(i); final Element urlElement=(Element)cronElement.getElementsByTagName("url").item(0); final Element descriptionElement=(Element)cronElement.getElementsByTagName("description").item(0); final Element scheduleElement=(Element)cronElement.getElementsByTagName("schedule").item(0); final String url=urlElement.getTextContent(); final String description=descriptionElement.getTextContent(); final String schedule=scheduleElement.getTextContent(); LOGGER.log(Level.CONFIG,"Cron[url={0}, description={1}, schedule={2}]",new Object[]{url,description,schedule}); CRONS.add(new Cron(url,description,schedule)); } } catch ( final Exception e) { LOGGER.log(Level.SEVERE,"Reads cron.xml failed",e); throw new RuntimeException(e); } }
Example 44
From project blog_1, under directory /miniprojects/generic-pojo-mappers/src/main/java/net/jakubholy/blog/genericmappers/xml/.
Source file: XmlElements.java

/** * Map XML elements denoted by the xpath supplied via {@link #atXPath(String)} to Java beans of the provided type.<p> See JavaDoc of {@link GenericXmlToBeanParser} for details and examples. * @param beanType (required) the Java class to map the XML elements to * @return Non-null but possibly empty collection of beans corresponding to the matching XML elements (also empty ifno matching elements have been found there i.e. due to incorrect XPath and/or namespace configuration) */ public <T>Collection<T> getBeans(Class<T> beanType){ if (rootNodesXpath == null) { throw new UnsupportedOperationException("No xpath was set, sorry we do not " + "support extracting the root element directly yet; please set its xpath " + "and/or compalin to the developer"); } Collection<T> parsed=new LinkedList<T>(); NodeList entries=getNodesMatchingXPath(rootNodesXpath); if (entries.getLength() == 0) { GenericXmlToBeanParser.log.info("No matching elements found for '" + rootNodesXpath + "' in the xml '"+ xmlStart+ "'"); } for (int i=0; i < entries.getLength(); i++) { Node currentNode=entries.item(i); parsed.add(mapNodeToPojo(currentNode,beanType)); } return parsed; }
Example 45
From project c24-spring, under directory /c24-spring-integration/src/main/java/biz/c24/io/spring/integration/config/.
Source file: XPathHeaderEnricherParser.java

protected void processHeaders(Element element,ManagedMap<String,Object> headers,ParserContext parserContext){ Object source=parserContext.extractSource(element); NodeList childNodes=element.getChildNodes(); for (int i=0; i < childNodes.getLength(); i++) { Node node=childNodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element headerElement=(Element)node; String elementName=node.getLocalName(); if ("header".equals(elementName)) { BeanDefinitionBuilder builder=BeanDefinitionBuilder.genericBeanDefinition("biz.c24.io.spring.integration.transformer.C24XPathHeaderEnricher$XPathExpressionEvaluatingHeaderValueMessageProcessor"); String expressionString=headerElement.getAttribute("xpath-statement"); String expressionRef=headerElement.getAttribute("xpath-statement-ref"); boolean isExpressionString=StringUtils.hasText(expressionString); boolean isExpressionRef=StringUtils.hasText(expressionRef); if (!(isExpressionString ^ isExpressionRef)) { parserContext.getReaderContext().error("Exactly one of the 'xpath-statement' or 'xpath-statement-ref' attributes is required.",source); } if (isExpressionString) { builder.addConstructorArgValue(expressionString); } else { builder.addConstructorArgReference(expressionRef); } IntegrationNamespaceUtils.setValueIfAttributeDefined(builder,headerElement,"evaluation-type"); IntegrationNamespaceUtils.setValueIfAttributeDefined(builder,headerElement,"overwrite"); String headerName=headerElement.getAttribute("name"); headers.put(headerName,builder.getBeanDefinition()); } } } }
Example 46
From project Cafe, under directory /webapp/src/org/openqa/selenium/os/.
Source file: WindowsUtils.java

/** * Returns a map of process IDs to command lines * @return a map of process IDs to command lines * @throws Exception - if something goes wrong while reading the process list */ public static Map procMap() throws Exception { log.info("Reading Windows Process List..."); String output=executeCommand(findWMIC(),"process","list","full","/format:rawxml.xsl"); log.info("Done, searching for processes to kill..."); File TempWmicBatchFile=new File("TempWmicBatchFile.bat"); if (TempWmicBatchFile.exists()) { TempWmicBatchFile.delete(); } Document doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(output.getBytes())); NodeList procList=doc.getElementsByTagName("INSTANCE"); Map<String,String> processes=new HashMap<String,String>(); for (int i=0; i < procList.getLength(); i++) { Element process=(Element)procList.item(i); NodeList propList=process.getElementsByTagName("PROPERTY"); Map<String,Object> procProps=new HashMap<String,Object>(); for (int j=0; j < propList.getLength(); j++) { Element property=(Element)propList.item(j); String propName=property.getAttribute("NAME"); NodeList valList=property.getElementsByTagName("VALUE"); String value=null; if (valList.getLength() != 0) { Element valueElement=(Element)valList.item(0); Text valueNode=(Text)valueElement.getFirstChild(); value=valueNode.getData(); } procProps.put(propName,value); } String processID=(String)procProps.get("ProcessId"); String commandLine=(String)procProps.get("CommandLine"); processes.put(commandLine,processID); } return processes; }
Example 47
From project cascading, under directory /src/xml/cascading/operation/xml/.
Source file: XPathGenerator.java

@Override public void operate(FlowProcess flowProcess,FunctionCall<Pair<DocumentBuilder,Tuple>> functionCall){ TupleEntry input=functionCall.getArguments(); if (input.getObject(0) == null || !(input.getObject(0) instanceof String)) return; String value=(String)input.getString(0); if (value.length() == 0) return; Document document=parseDocument(functionCall.getContext().getLhs(),value); for (int i=0; i < getExpressions().size(); i++) { try { NodeList nodeList=(NodeList)getExpressions().get(i).evaluate(document,XPathConstants.NODESET); if (LOG.isDebugEnabled()) LOG.debug("xpath: {} was: {}",paths[i],nodeList != null && nodeList.getLength() != 0); if (nodeList == null) continue; for (int j=0; j < nodeList.getLength(); j++) { functionCall.getContext().getRhs().set(0,writeAsXML(nodeList.item(j))); functionCall.getOutputCollector().add(functionCall.getContext().getRhs()); } } catch ( XPathExpressionException exception) { throw new OperationException("could not evaluate xpath expression: " + paths[i],exception); } } }
Example 48
From project cdk, under directory /xinclude/src/main/java/org/apache/cocoon/pipeline/component/xpointer/.
Source file: XPointerPart.java

public boolean process(XPointerContext xpointerContext) throws SAXException, IOException { Document document=xpointerContext.getDocument(); XPath xpath=XPF.newXPath(); xpath.setNamespaceContext(xpointerContext); XPathExpression xpathExpression; try { xpathExpression=xpath.compile(expression); } catch ( XPathExpressionException e) { throw new SAXException("XPointer: expression \"" + expression + "\" is not a valid XPath expression",e); } try { NodeList nodeList=(NodeList)xpathExpression.evaluate(document,XPathConstants.NODESET); if (nodeList.getLength() > 0) { SAXConsumer consumer=xpointerContext.getXmlConsumer(); LocatorImpl locator=new LocatorImpl(); locator.setSystemId(xpointerContext.getSource().toString()); consumer.setDocumentLocator(locator); for (int i=0; i < nodeList.getLength(); i++) { DOMUtils.stream(nodeList.item(i),consumer); } return true; } else { if (xpointerContext.getLogger().isDebugEnabled()) { xpointerContext.getLogger().debug("XPointer: expression \"" + expression + "\" gave no results."); } return false; } } catch ( XPathExpressionException e) { throw new SAXException("XPointer: impossible to select DOM fragment using expression \"" + expression + "\", see nested exception",e); } }
Example 49
From project chukwa, under directory /src/main/java/org/apache/hadoop/chukwa/inputtools/jplugin/.
Source file: GenericChukwaMetricsList.java

public void fromXml(String xml) throws Exception { InputSource is=new InputSource(new StringReader(xml)); Document doc=docBuilder.parse(is); Element root=doc.getDocumentElement(); setRecordType(root.getTagName()); long timestamp=Long.parseLong(root.getAttribute("ts")); setTimestamp(timestamp); NodeList children=root.getChildNodes(); for (int i=0; i < children.getLength(); i++) { if (!children.item(i).getNodeName().equals("Metrics")) { continue; } NamedNodeMap attrs=children.item(i).getAttributes(); if (attrs == null) { continue; } GenericChukwaMetrics metrics=new GenericChukwaMetrics(); for (int a=0; a < attrs.getLength(); a++) { Attr attr=(Attr)attrs.item(a); String name=attr.getName(); String value=attr.getValue(); if (name.equals("key")) { metrics.setKey(value); } else { metrics.put(name,value); } } addMetrics(metrics); } }
Example 50
From project cidb, under directory /ncbieutils-access-service/src/main/java/edu/toronto/cs/cidb/ncbieutils/.
Source file: NCBIEUtilsAccessService.java

protected String getName(String id){ String url=composeURL(TERM_SUMMARY_QUERY_SCRIPT,TERM_SUMMARY_PARAM_NAME,id); String result=id; try { Document response=readXML(url); NodeList nodes=response.getElementsByTagName("DocSum"); if (nodes.getLength() > 0) { Map<String,String> idToName=this.getNameForId(nodes.item(0)); result=idToName.get(id); if (result != null && !id.equals(result)) { return result; } } this.logger.warn("Name not found for OMIM id " + id); return id; } catch ( Exception ex) { this.logger.error("Error while trying to retrieve name for " + getDatabaseName() + " id "+ id+ " "+ ex.getClass().getName()+ " "+ ex.getMessage(),ex); } return id; }
Example 51
From project Clotho-Core, under directory /ClothoApps/ConnectionConfigTool/src/org/clothocad/tool/connectconfigtool/.
Source file: frame.java

public frame(){ super("Configure Connection"); setIconImage(ImageSource.getTinyLogo()); InputStream stream=null; try { configFile=FileUtil.getConfigFile("data/private/org.clothocad.connection.configurableconnection/").getFileObject("hibernate.cfg.xml"); stream=configFile.getInputStream(); XMLParser parser=new XMLParser(stream,"hibernate-configuration"); List<Element> elements=parser.getNodesOfTag("session-factory"); Element root=elements.get(0); NodeList listy=root.getChildNodes(); server=listy.item(5).getTextContent(); database=listy.item(11).getTextContent(); login=listy.item(7).getTextContent(); password=listy.item(9).getTextContent(); int end=server.indexOf(":3306"); String tempy=server.substring(13,end); server=tempy; for (int i=0; i < listy.getLength(); i++) { Node anode=listy.item(i); System.out.println("e.getNodeName():" + i + " is "+ anode.getTextContent()); } initcomponents(); } catch ( Exception ex) { ex.printStackTrace(); } if (stream != null) { try { stream.close(); } catch ( IOException ex1) { } } }
Example 52
From project cloudbees-api-client, under directory /cloudbees-api-client/src/main/java/com/cloudbees/utils/.
Source file: AppConfigParser.java

public void load(ApplicationConfiguration applicationConfiguration,Document doc,String[] environments,String[] implicitEnvironments){ XPathFactory factory=XPathFactory.newInstance(); XPath xpath=factory.newXPath(); try { Element e=doc.getDocumentElement(); applyToAppConfig(applicationConfiguration,xpath,e); applicationConfiguration.setDefaultEnvironment(e.getAttribute("default")); if (environments == null || environments.length == 0) { environments=getEnvironmentList(applicationConfiguration.getDefaultEnvironment(),implicitEnvironments); } else { environments=getEnvironmentList(join(environments,","),implicitEnvironments); } NodeList nodes=(NodeList)xpath.evaluate("environment",e,XPathConstants.NODESET); Map<String,Node> envNodes=new HashMap<String,Node>(); for (int i=0; i < nodes.getLength(); i++) { Node n=nodes.item(i); String envName=getAttribute(n,"name",null); if (envName == null) throw new IllegalArgumentException("missing required attribute (name) on environment element"); envNodes.put(envName,n); } if (environments != null) { for ( String env : environments) { Node n=envNodes.get(env); if (n != null) { applyToAppConfig(applicationConfiguration,xpath,n); applicationConfiguration.getAppliedEnvironments().add(env); } } } } catch ( XPathExpressionException e) { e.printStackTrace(); } }
Example 53
From project cloudify, under directory /esc/src/main/java/org/cloudifysource/esc/driver/provisioning/openstack/.
Source file: OpenstackCloudDriver.java

private Node getNode(final String nodeId,final String token) throws OpenstackException { final Node node=new Node(); String response=""; try { response=service.path(this.pathPrefix + "servers/" + nodeId).header("X-Auth-Token",token).accept(MediaType.APPLICATION_XML).get(String.class); final DocumentBuilder documentBuilder=createDocumentBuilder(); final Document xmlDoc=documentBuilder.parse(new InputSource(new StringReader(response))); node.setId(xpath.evaluate("/server/@id",xmlDoc)); node.setStatus(xpath.evaluate("/server/@status",xmlDoc)); node.setName(xpath.evaluate("/server/@name",xmlDoc)); final NodeList addresses=(NodeList)xpath.evaluate("/server/addresses/network/ip/@addr",xmlDoc,XPathConstants.NODESET); if (node.getStatus().equalsIgnoreCase(MACHINE_STATUS_ACTIVE)) { if (addresses.getLength() != 2) { throw new IllegalStateException("Expected 2 addresses, private and public, got " + addresses.getLength() + " addresses"); } node.setPrivateIp(addresses.item(0).getTextContent()); node.setPublicIp(addresses.item(1).getTextContent()); } } catch ( final XPathExpressionException e) { throw new OpenstackException("Failed to parse XML Response from server. Response was: " + response + ", Error was: "+ e.getMessage(),e); } catch ( final SAXException e) { throw new OpenstackException("Failed to parse XML Response from server. Response was: " + response + ", Error was: "+ e.getMessage(),e); } catch ( final IOException e) { throw new OpenstackException("Failed to send request to server. Response was: " + response + ", Error was: "+ e.getMessage(),e); } catch ( UniformInterfaceException e) { throw new OpenstackException("Failed on get for server with node id " + nodeId + ". Response was: "+ response+ ", Error was: "+ e.getMessage(),e); } return node; }
Example 54
From project cmsandroid, under directory /src/com/zia/freshdocs/cmis/.
Source file: CMISParserBase.java

public CMISInfo getCMISInfo(InputStream is){ DocumentBuilder docBuilder=null; CMISInfo info=null; try { docBuilder=DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc=docBuilder.parse(is); NodeList nodes=doc.getElementsByTagName("cmis:cmisVersionSupported"); String rawVersion=nodes.item(0).getFirstChild().getNodeValue(); info=new CMISInfo(); info.setVersion(rawVersion.split("\\s")[0]); nodes=doc.getElementsByTagName("collection"); int n=nodes.getLength(); if (n > 0) { Element node=null; for (int i=0; i < n; i++) { node=(Element)nodes.item(i); if (node.hasAttribute(CMIS_COLLECTION_TYPE) && node.getAttribute(CMIS_COLLECTION_TYPE).equals("rootchildren")) { break; } else { NodeList collectionTypes=node.getElementsByTagName("cmisra:collectionType"); if (collectionTypes.getLength() > 0) { String colType=collectionTypes.item(0).getFirstChild().getNodeValue(); if (colType.equals("root")) { break; } } } } info.setRootURI(node.getAttribute("href")); } } catch ( Exception e) { Log.e(CMISParserBase.class.getSimpleName(),"Error getting root folder id",e); } return info; }
Example 55
From project Codeable_Objects, under directory /SoftObjects/src/com/ui/.
Source file: SVGReader.java

private boolean parseLines(Document doc){ NodeList nList=doc.getElementsByTagName("line"); for (int i=0; i < nList.getLength(); i++) { Node nNode=nList.item(i); if (nNode.hasAttributes()) { NamedNodeMap map=nNode.getAttributes(); String x1Value=map.getNamedItem("x1").getNodeValue(); String y1Value=map.getNamedItem("y1").getNodeValue(); String x2Value=map.getNamedItem("x2").getNodeValue(); String y2Value=map.getNamedItem("y2").getNodeValue(); if (x1Value != "" || y1Value != "" || x2Value != "" || y2Value != " ") { double x1=stringToDouble(x1Value); double y1=stringToDouble(y1Value); double x2=stringToDouble(x2Value); double y2=stringToDouble(y2Value); Line line=new Line(x1,y1,x2,y2); pattern.addLine(line); } } } return true; }
Example 56
From project coffeescript-netbeans, under directory /src/coffeescript/nb/project/sample/.
Source file: CoffeeScriptApplicationWizardIterator.java

private static void filterProjectXML(FileObject fo,ZipInputStream str,String name) throws IOException { try { ByteArrayOutputStream baos=new ByteArrayOutputStream(); FileUtil.copy(str,baos); Document doc=XMLUtil.parse(new InputSource(new ByteArrayInputStream(baos.toByteArray())),false,false,null,null); NodeList nl=doc.getDocumentElement().getElementsByTagName("name"); if (nl != null) { for (int i=0; i < nl.getLength(); i++) { Element el=(Element)nl.item(i); if (el.getParentNode() != null && "data".equals(el.getParentNode().getNodeName())) { NodeList nl2=el.getChildNodes(); if (nl2.getLength() > 0) { nl2.item(0).setNodeValue(name); } break; } } } OutputStream out=fo.getOutputStream(); try { XMLUtil.write(doc,out,"UTF-8"); } finally { out.close(); } } catch ( Exception ex) { Exceptions.printStackTrace(ex); writeFile(str,fo); } }
Example 57
From project com.cedarsoft.serialization, under directory /test-utils/src/main/java/com/cedarsoft/serialization/test/utils/.
Source file: XmlNamespaceTranslator.java

public void translateNamespaces(@Nonnull Document xmlDoc,boolean addNsToAttributes){ Stack<Node> nodes=new Stack<Node>(); nodes.push(xmlDoc.getDocumentElement()); while (!nodes.isEmpty()) { Node node=nodes.pop(); switch (node.getNodeType()) { case Node.ATTRIBUTE_NODE: case Node.ELEMENT_NODE: Value<String> value=this.translations.get(new Key<String>(node.getNamespaceURI())); if (value != null) { node=xmlDoc.renameNode(node,value.getValue(),node.getNodeName()); } break; } if (addNsToAttributes) { NamedNodeMap attributes=node.getAttributes(); if (!(attributes == null || attributes.getLength() == 0)) { for (int i=0, count=attributes.getLength(); i < count; ++i) { Node attribute=attributes.item(i); if (attribute != null) { nodes.push(attribute); } } } } NodeList childNodes=node.getChildNodes(); if (!(childNodes == null || childNodes.getLength() == 0)) { for (int i=0, count=childNodes.getLength(); i < count; ++i) { Node childNode=childNodes.item(i); if (childNode != null) { nodes.push(childNode); } } } } }
Example 58
From project androidannotations, under directory /AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/helper/.
Source file: AndroidManifestFinder.java

private List<String> extractComponentNames(String applicationPackage,NodeList componentNodes){ List<String> componentQualifiedNames=new ArrayList<String>(); for (int i=0; i < componentNodes.getLength(); i++) { Node activityNode=componentNodes.item(i); Node nameAttribute=activityNode.getAttributes().getNamedItem("android:name"); String qualifiedName=manifestNameToValidQualifiedName(applicationPackage,nameAttribute); if (qualifiedName != null) { componentQualifiedNames.add(qualifiedName); } else { Messager messager=processingEnv.getMessager(); if (nameAttribute != null) { messager.printMessage(Kind.NOTE,String.format("A class activity declared in the AndroidManifest.xml cannot be found in the compile path: [%s]",nameAttribute.getNodeValue())); } else { messager.printMessage(Kind.NOTE,String.format("The %d activity node in the AndroidManifest.xml has no android:name attribute",i)); } } } return componentQualifiedNames; }