List of usage examples for org.w3c.dom Element hasChildNodes
public boolean hasChildNodes();
From source file:com.fota.Link.sdpApi.java
public String CheckNumberPortabilityByPhoneNumber(String CTN) throws SAXException, IOException, ParserConfigurationException { String resultStr = null;/*from www . j a v a 2s . com*/ try { String endPointUrl = PropUtil.getPropValue("sdp.oif552.url"); String strRequest = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' " + "xmlns:oas='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'" + " xmlns:sdp='http://kt.com/sdp'>" + " <soapenv:Header>" + " <oas:Security>" + " <oas:UsernameToken>" + " <oas:Username>" + PropUtil.getPropValue("sdp.id") + "</oas:Username>" + " <oas:Password>" + PropUtil.getPropValue("sdp.pw") + "</oas:Password>" + " </oas:UsernameToken>" + " </oas:Security>" + " </soapenv:Header>" + " <soapenv:Body>" + " <sdp:checkNumberPortabilityByPhoneNumberRequest>" + " <!--You may enterthe following 6 items in any order-->" + " <sdp:CALL_CTN>" + CTN + "</sdp:CALL_CTN>" + " </sdp:checkNumberPortabilityByPhoneNumberRequest>\n" + " </soapenv:Body>\n" + "</soapenv:Envelope>"; // phone_number + telco_code + party_name + birth_date + [gender + // foreigner](?) // + auth_code + random_no + action_type // connection URL url = new URL(endPointUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestProperty("Content-type", "text/xml;charset=utf-8"); // connection.setRequestProperty("Content-Length", // String.valueOf(strRequest.length())); connection.setRequestMethod("POST"); connection.setDoOutput(true); connection.setDoInput(true); connection.connect(); // output OutputStream os = connection.getOutputStream(); // os.write(strRequest.getBytes(), 0, strRequest.length()); os.write(strRequest.getBytes("utf-8")); os.flush(); os.close(); // input InputStream is = connection.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is, "utf-8")); String line = null; String resValue = null; String parseStr = null; while ((line = br.readLine()) != null) { System.out.println(line); parseStr = line; //int nIndex = resultStr.indexOf("<sdp:ROUTING_DIGIT>"); //resValue = resultStr.substring(nIndex,nIndex+1); } DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource temp = new InputSource(); temp.setCharacterStream(new StringReader(parseStr)); Document doc = builder.parse(temp); //xml? NodeList list = doc.getElementsByTagName("*"); int i = 0; Element element; String contents; while (list.item(i) != null) { element = (Element) list.item(i); System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); System.out.println(element.getNodeName()); if (element.hasChildNodes()) { contents = element.getFirstChild().getNodeValue(); System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55"); System.out.println(element.getNodeName()); System.out.println(element.getFirstChild().getNodeName()); if (element.getNodeName().equals("sdp:ROUTING_DIGIT")) { //nero17 //resultStr = element.getFirstChild().getNodeName(); resultStr = contents; } System.out.println(contents); } i++; } connection.disconnect(); } catch (Exception e) { e.printStackTrace(); } if (resultStr.length() < 2) { resultStr = ""; } return resultStr; }
From source file:com.fota.Link.sdpApi.java
public String GetBasicUserInfoAndMarketInfo2(String CTN) throws JDOMException { String resultStr = null;/*www. jav a 2s.c om*/ try { String endPointUrl = PropUtil.getPropValue("sdp.oif516.url"); String strRequest = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' " + "xmlns:oas='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'" + " xmlns:sdp='http://kt.com/sdp'>" + " <soapenv:Header>" + " <oas:Security>" + " <oas:UsernameToken>" + " <oas:Username>" + PropUtil.getPropValue("sdp.id") + "</oas:Username>" + " <oas:Password>" + PropUtil.getPropValue("sdp.pw") + "</oas:Password>" + " </oas:UsernameToken>" + " </oas:Security>" + " </soapenv:Header>" + " <soapenv:Body>" + " <sdp:getBasicUserInfoAndMarketInfoRequest>" + " <!--You may enterthe following 6 items in any order-->" + " <sdp:CALL_CTN>" + CTN + "</sdp:CALL_CTN>" + " </sdp:getBasicUserInfoAndMarketInfoRequest>\n" + " </soapenv:Body>\n" + "</soapenv:Envelope>"; // connection URL url = new URL(endPointUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestProperty("Content-type", "text/xml;charset=utf-8"); connection.setRequestMethod("POST"); connection.setDoOutput(true); connection.setDoInput(true); connection.connect(); // output OutputStream os = connection.getOutputStream(); // os.write(strRequest.getBytes(), 0, strRequest.length()); os.write(strRequest.getBytes("utf-8")); os.flush(); os.close(); // input InputStream is = connection.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is, "utf-8")); String line = null; String resValue = null; String parseStr = null; while ((line = br.readLine()) != null) { System.out.println(line); parseStr = line; } DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource temp = new InputSource(); temp.setCharacterStream(new StringReader(parseStr)); Document doc = builder.parse(temp); //xml? NodeList list = doc.getElementsByTagName("*"); int i = 0; Element element; String contents; while (list.item(i) != null) { element = (Element) list.item(i); // System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); // System.out.println(element.getNodeName()); if (element.hasChildNodes()) { contents = element.getFirstChild().getNodeValue(); // System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55"); // System.out.println(element.getNodeName()); // System.out.println(element.getFirstChild().getNodeName()); if (element.getNodeName().equals("sdp:CUSTOMER_LINK_NAME")) { resultStr = element.getFirstChild().getNodeValue(); } System.out.println(contents); } i++; } //resultStr = resValue; resultStr = java.net.URLDecoder.decode(resultStr, "euc-kr"); connection.disconnect(); } catch (Exception e) { e.printStackTrace(); } return resultStr; }
From source file:com.fota.Link.sdpApi.java
public String GetBasicUserInfoAndMarketInfo(String CTN) throws JDOMException { String resultStr = null;/*from ww w .j a va 2s .c om*/ StringBuffer logSb = new StringBuffer(); try { String endPointUrl = PropUtil.getPropValue("sdp.oif516.url"); String strRequest = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' " + "xmlns:oas='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'" + " xmlns:sdp='http://kt.com/sdp'>" + " <soapenv:Header>" + " <oas:Security>" + " <oas:UsernameToken>" + " <oas:Username>" + PropUtil.getPropValue("sdp.id") + "</oas:Username>" + " <oas:Password>" + PropUtil.getPropValue("sdp.pw") + "</oas:Password>" + " </oas:UsernameToken>" + " </oas:Security>" + " </soapenv:Header>" + " <soapenv:Body>" + " <sdp:getBasicUserInfoAndMarketInfoRequest>" + " <!--You may enterthe following 6 items in any order-->" + " <sdp:CALL_CTN>" + CTN + "</sdp:CALL_CTN>" + " </sdp:getBasicUserInfoAndMarketInfoRequest>\n" + " </soapenv:Body>\n" + "</soapenv:Envelope>"; logSb.append("\r\n---------- GetBasicUserInfoAndMarketInfo(" + CTN + ") ----------"); logSb.append("\r\nendPointUrl : " + endPointUrl); logSb.append("\r\nrequest msg : \r\n==============================\r\n" + strRequest + "\r\n===============================\r\n"); logger.info(logSb.toString()); logSb.setLength(0); // connection URL url = new URL(endPointUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestProperty("Content-type", "text/xml;charset=utf-8"); connection.setRequestMethod("POST"); connection.setDoOutput(true); connection.setDoInput(true); connection.connect(); // output OutputStream os = connection.getOutputStream(); // os.write(strRequest.getBytes(), 0, strRequest.length()); os.write(strRequest.getBytes("utf-8")); os.flush(); os.close(); // input InputStream is = connection.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is, "utf-8")); String line = null; String resValue = null; String parseStr = null; while ((line = br.readLine()) != null) { System.out.println(line); parseStr = line; } DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource temp = new InputSource(); temp.setCharacterStream(new StringReader(parseStr)); Document doc = builder.parse(temp); //xml? NodeList list = doc.getElementsByTagName("*"); int i = 0; Element element; String contents; while (list.item(i) != null) { element = (Element) list.item(i); // System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); // System.out.println(element.getNodeName()); if (element.hasChildNodes()) { contents = element.getFirstChild().getNodeValue(); // System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55"); // System.out.println(element.getNodeName()); // System.out.println(element.getFirstChild().getNodeName()); if (element.getNodeName().equals("sdp:PREPAID")) { resultStr = contents; } System.out.println(contents); } i++; } //resultStr = resValue; connection.disconnect(); } catch (Exception e) { e.printStackTrace(); } return resultStr; }
From source file:com.fota.Link.sdpApi.java
public SDPInfoVO getSpecificSubscpnInfo(String CTN) { //String resultStr = null; SDPInfoVO resVO = new SDPInfoVO(); String strIMEI = null;// ww w . ja v a 2 s . c om String Model_Name = null; String return_cd = null; try { String endPointUrl = PropUtil.getPropValue("sdp.oif114.url"); String strRequest = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' " + "xmlns:oas='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'" + " xmlns:sdp='http://kt.com/sdp'>" + " <soapenv:Header>" + " <oas:Security>" + " <oas:UsernameToken>" + " <oas:Username>" + PropUtil.getPropValue("sdp.id") + "</oas:Username>" + " <oas:Password>" + PropUtil.getPropValue("sdp.pw") + "</oas:Password>" + " </oas:UsernameToken>" + " </oas:Security>" + " </soapenv:Header>" + " <soapenv:Body>" + " <sdp:getSpecificSubscpnInfoRequest>" + " <!--You may enterthe following 6 items in any order-->" // + " <sdp:Credt_Id></sdp:Credt_Id>" + " <sdp:User_Name>" + CTN + "</sdp:User_Name>" + "<sdp:Credt_Type_Cd>" + "05" + "</sdp:Credt_Type_Cd>" + " </sdp:getSpecificSubscpnInfoRequest>\n" + " </soapenv:Body>\n" + "</soapenv:Envelope>"; // connection URL url = new URL(endPointUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestProperty("Content-type", "text/xml;charset=utf-8"); connection.setRequestMethod("POST"); connection.setDoOutput(true); connection.setDoInput(true); connection.connect(); // output OutputStream os = connection.getOutputStream(); // os.write(strRequest.getBytes(), 0, strRequest.length()); os.write(strRequest.getBytes("utf-8")); os.flush(); os.close(); // input InputStream is = connection.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is, "utf-8")); String line = null; String parseStr = null; while ((line = br.readLine()) != null) { System.out.println(line); parseStr = line; } //resultStr = line; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource temp = new InputSource(); temp.setCharacterStream(new StringReader(parseStr)); Document doc = builder.parse(temp); //xml? NodeList list = doc.getElementsByTagName("*"); int i = 0; Element element; String contents; // sdp:returnCode while (list.item(i) != null) { element = (Element) list.item(i); //System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); //System.out.println(element.getNodeName()); if (element.hasChildNodes()) { contents = element.getFirstChild().getNodeValue(); //System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55"); //System.out.println(element.getNodeName()); //System.out.println(element.getFirstChild().getNodeName()); if (element.getNodeName().equals("n1:Resource_Unique_Id")) { if (element.getNextSibling().getFirstChild().getNodeValue().equals(("06"))) { //System.out.println("%%%%%%%%%%%%%%%%% FINDFIND!!! %%%%%%%%%%%%%%%%%%%%%%%%%%%55"); strIMEI = element.getFirstChild().getNodeValue(); //System.out.println("%%%%%%%%%%%%%%%%% FINDFIND!!! " + strIMEI + "%%%%%%%%%%%%%%%%%%%%%%%%%%%55"); } //resultStr = element.getFirstChild().getNodeName(); } if (element.getNodeName().equals("n1:Resource_Model_Name")) { Model_Name = element.getFirstChild().getNodeValue(); } if (element.getNodeName().equals("sdp:returnCode")) { return_cd = element.getFirstChild().getNodeValue(); } //n1:Resource_Model_Name System.out.println(contents); } i++; } connection.disconnect(); } catch (Exception e) { e.printStackTrace(); } resVO.setModem_model_nm(Model_Name); resVO.setImei(strIMEI); resVO.setReturn_cd(return_cd); return resVO; }
From source file:com.redhat.rcm.maven.plugin.buildmetadata.io.SdocBuilder.java
private void createEnvElement(final Element runtime) { final Element parent = document.createElement("env"); final Properties sorted = SortedProperties.createSorted(buildMetaDataProperties); final String matchPrefix = Constant.MAVEN_EXECUTION_PROPERTIES_PREFIX + '.'; for (final Map.Entry<Object, Object> entry : sorted.entrySet()) { final String key = String.valueOf(entry.getKey()); if (key.startsWith(matchPrefix)) { final String value = String.valueOf(entry.getValue()); final Element env = createValueElement("var", value, parent); if (env != null) { env.setAttribute(GI_NAME, key); }// w w w. ja v a 2 s . c o m } } if (parent.hasChildNodes()) { runtime.appendChild(parent); } }
From source file:fr.gouv.finances.dgfip.xemelios.utils.TextWriter.java
private void element(Writer writer, Element elem) throws IOException { if (prettyPrint) { checkTextBuffer(writer);/*w w w . ja v a 2s . co m*/ indent(writer); } String n = elem.getTagName(); writer.write('<'); writeText(writer, n); NamedNodeMap a = elem.getAttributes(); int size = a.getLength(); for (int i = 0; i < size; i++) { Attr att = (Attr) a.item(i); writer.write(' '); writeNode(writer, att); } if (elem.hasChildNodes()) { writer.write('>'); if (prettyPrint) { String text = getChildText(elem); if (text != null) writeEscapedText(writer, normalizeString(text), false); else { writer.write('\n'); indentLevel++; writeChildren(writer, elem); checkTextBuffer(writer); indentLevel--; indent(writer); } } else writeChildren(writer, elem); writer.write("</"); writeText(writer, n); writer.write('>'); } else { if (produceHTML) writer.write(">"); else writer.write("/>"); } if (prettyPrint) writer.write('\n'); }
From source file:curam.molsa.test.customfunctions.MOLSATestDatastore.java
/** * Recursively save datastore entities and child entities. * /* w ww . jav a 2 s . c o m*/ * @param datastore * @param rootElement * @param rootEntity * * @throws SAXException * @throws IOException * @throws ParserConfigurationException */ private void save(final Datastore datastore, final Map<String, MOLSADatastoreEntity> MOLSADatastoreEntities, final Element rootElement, final Entity rootEntity) throws SAXException, IOException, ParserConfigurationException { System.out.println("MOLSATestDatastore.save()"); /* * Iterate through the known datastore entities - search for each one inside * the xml passed in and map the attributes and their values. */ for (final MOLSADatastoreEntity mOLSADatastoreEntity : MOLSADatastoreEntities.values()) { final String entityName = mOLSADatastoreEntity.getName(); System.out.println("Entity Name" + entityName); final NodeList entities = rootElement.getChildNodes(); for (int i = 0; i < entities.getLength(); i++) { if (entities.item(i).getNodeType() == Node.ELEMENT_NODE && entities.item(i).getNodeName().equals(entityName)) { final Element entity = (Element) entities.item(i); final Entity dsEntity = mapFromXMLToDatastoreEntity(entity, datastore, mOLSADatastoreEntity); Boolean isModify = false; if (dsEntity.getEntityType().getKeyAttribute() != null) { final String id = entity.getAttribute(dsEntity.getEntityType().getKeyAttribute().getName()); if (id.length() != 0) { isModify = true; } } if (!isModify) { rootEntity.addChildEntity(dsEntity); } /* * Are there any child elements? If so, save these also. NB Recursive. */ if (entity.hasChildNodes()) { save(datastore, MOLSADatastoreEntities, entity, dsEntity); } } } } }
From source file:de.smartics.maven.plugin.buildmetadata.io.SdocBuilder.java
private void createJavaElement(final Element runtime) { final Element parent = document.createElement("java"); createContentElement(GI_NAME, Constant.PROP_NAME_JAVA_RUNTIME_NAME, parent); createContentElement(GI_VERSION, Constant.PROP_NAME_JAVA_RUNTIME_VERSION, parent); createContentElement("vendor", Constant.PROP_NAME_JAVA_VENDOR, parent); createContentElement("vm", Constant.PROP_NAME_JAVA_VM, parent); createContentElement("compiler", Constant.PROP_NAME_JAVA_COMPILER, parent); createContentElement("options", Constant.PROP_NAME_JAVA_OPTS, parent); for (final String key : buildMetaDataProperties.stringPropertyNames()) { final String prefix = "build.runtime.java."; if (key.startsWith(prefix)) { final String shortenedKey = key.substring(prefix.length()); createContentElement(shortenedKey, key, parent); }//ww w. j ava 2 s. com } if (parent.hasChildNodes()) { runtime.appendChild(parent); } }
From source file:eionet.gdem.conversion.odf.ODFSpreadsheetAnalyzer.java
/** * Get the content from p:text node or officde:value attribute - cell value * * @param cellElement/*w w w. j a v a2 s . com*/ * the first element of <code><table:table-cell></code> element. * * @return content inside text:p tag */ protected String processCell(Element cellElement) { String cellValue = null; if (cellElement.hasAttribute(officeNamespace + "value-type")) { String valueType = cellElement.getAttribute(officeNamespace + "value-type"); if ("date".equals(valueType)) { if (cellElement.hasAttribute(officeNamespace + "date-value")) { cellValue = cellElement.getAttribute(officeNamespace + "date-value"); } } else if ("time".equals(valueType)) { if (cellElement.hasAttribute(officeNamespace + "time-value")) { cellValue = cellElement.getAttribute(officeNamespace + "time-value"); } } else { if (cellElement.hasAttribute(officeNamespace + "value")) { cellValue = cellElement.getAttribute(officeNamespace + "value"); } } } // get value from p:text if (Utils.isNullStr(cellValue) && cellElement.hasChildNodes()) { Element ptext = (Element) cellElement.getFirstChild(); if (ptext != null && ptext.hasChildNodes()) { cellValue = ptext.getFirstChild().getNodeValue(); } } return cellValue; }
From source file:de.eorganization.hoopla.server.servlets.TemplateImportServlet.java
private void parseGoals(NodeList goalNodes, Decision newDecision) { newDecision.getGoals().clear();//from w ww.j a v a 2 s .c o m for (int i = 0; i < goalNodes.getLength(); i++) { Node node = goalNodes.item(i); if (node instanceof Element) { Goal newGoal = new Goal(); Element child = (Element) node; NodeList goalTagNodes = child.getChildNodes(); for (int x = 0; x < goalTagNodes.getLength(); x++) { if (goalTagNodes.item(x) instanceof Element) { Element goalTagElement = (Element) goalTagNodes.item(x); if (goalTagElement.getNodeName().equals("name")) { newGoal.setName(goalTagElement.getTextContent()); } if (goalTagElement.getNodeName().equals("description")) { newGoal.setDescription(goalTagElement.getTextContent()); } if (goalTagElement.getNodeName().equals("goalType")) { newGoal.setGoalType(GoalType.valueOf(goalTagElement.getTextContent())); } if (goalTagElement.getNodeName().equals("children")) { newGoal.setChildren(parseCriteria(goalTagElement.getChildNodes())); } if (goalTagElement.getNodeName().equals("importanceChildren")) { if (goalTagElement.hasChildNodes()) { parseImportanceChildren(goalTagElement.getChildNodes(), newGoal); } } } } newDecision.addGoal(newGoal); log.info("Parsed gaol: " + newGoal.getName() + ", " + newGoal.getDescription() + ", " + newGoal.getGoalType()); } } }