List of usage examples for org.jdom2 Element getChildText
public String getChildText(final String cname)
From source file:com.khodev.oradiff.io.XmlSchemaReader.java
License:Open Source License
private View getView(Element element) { View view = new View(element.getAttributeValue("name"), element.getChildText("source")); List<Element> children = getChildren(element, "columns"); for (Element child : children) try {//from w w w . jav a 2 s . c om view.getColumns().add(child.getAttributeValue("name")); } catch (Exception e) { e.printStackTrace(); } return view; }
From source file:com.kingmed.dp.ndp.impl.SignInResponseHandler.java
/** * ?NDP.serve?XML// w w w . ja v a2 s .co m * * @param responseBody * @return true : NDP.serve??, * <br/> * false : NDP.serve ? * @throws Exception */ private String checkStatus(String responseBody) throws Exception { String status = null; String expression = "//" + NDPServeImpl.CONNECTION; List<Element> items = null; String username; String message; items = checkStatus(responseBody, expression); for (Element itemElement : items) { status = itemElement.getChildText(NDPServeImpl.STATUS); message = itemElement.getChildText(NDPServeImpl.CONNECTION_STATUS_MESSAGE); username = itemElement.getChildText(NDPServeImpl.CONNECTION_STATUS_USERNAME); log.info("connectin Status=" + status + ",message=" + message + ",username=" + username); if (NDPServeImpl.STATUS_SUCCEEDED.equals(status)) { break; } } return status; }
From source file:com.kingmed.dp.ndp.impl.SignOutResponseHandler.java
/** * ?NDP.serve?XML//from w w w . ja va 2 s .co m * * @param responseBody * @return true : NDP.serve??, * <br/> * false : NDP.serve ? * @throws Exception */ private String checkStatus(String responseBody) throws Exception { String status = null; String expression = "//" + NDPServeImpl.CONNECTION; List<Element> items = null; String username; String message; items = checkStatus(responseBody, expression); for (Element itemElement : items) { status = itemElement.getChildText(NDPServeImpl.STATUS); message = itemElement.getChildText(NDPServeImpl.CONNECTION_STATUS_MESSAGE); username = itemElement.getChildText(NDPServeImpl.CONNECTION_STATUS_USERNAME); log.info("connectin status=" + status + ",message" + message + ",username=" + username); if (NDPServeImpl.STATUS_SUCCEEDED.equals(status)) { break; } } return status; }
From source file:com.kingmed.dp.ndp.impl.UpdateLinkedFoldersResponseHandler.java
/** * ?NDP.serve?XML//from w w w . ja va2 s . c om * * @param responseBody * @return true : NDP.serve??, * <br/> * false : NDP.serve ? * @throws Exception */ private String checkStatus(String responseBody) throws JDOMException, IOException { String status = null; String expression = "//" + NDPServeImpl.UPDATERESULT; List<Element> items = null; items = checkStatus(responseBody, expression); if (items == null) { log.warn("?"); return status; } for (Element itemElement : items) { status = itemElement.getChildText(NDPServeImpl.STATUS); log.info("Status=" + status); if (NDPServeImpl.STATUS_SUCCEEDED.equals(status)) { break; } //?500? //statusfailedmessage?? } return status; }
From source file:com.kixeye.scout.eureka.EurekaApplication.java
License:Apache License
/** * Creates a new application with a parent and raw element. * /*from w w w.j ava 2 s . co m*/ * @param parent * @param element */ protected EurekaApplication(EurekaApplications parent, Element element) { this.parent = parent; this.name = element.getChildText("name"); for (Element instance : element.getChildren("instance")) { instances.add(new EurekaServiceInstanceDescriptor(this, instance)); } }
From source file:com.kixeye.scout.eureka.EurekaServiceAmazonDataCenterInfo.java
License:Apache License
/** * Creates a descriptor from a parent and a raw element. * //from www.ja va2 s . c om * @param parent * @param instanceElement */ protected EurekaServiceAmazonDataCenterInfo(EurekaServiceInstanceDescriptor parent, Element instanceElement) { this.parent = parent; this.name = instanceElement.getChildText("name"); Element metadata = instanceElement.getChild("metadata"); if (metadata != null) { for (Element element : metadata.getChildren()) { this.metadata.put(element.getName(), element.getText()); } } }
From source file:com.kixeye.scout.eureka.EurekaServiceInstanceDescriptor.java
License:Apache License
/** * Creates a descriptor from a parent and a raw element. * /*from w w w .jav a2 s .co m*/ * @param parent * @param instanceElement */ protected EurekaServiceInstanceDescriptor(EurekaApplication parent, Element instanceElement) { this.parent = parent; this.app = instanceElement.getChildText("app"); this.ipAddress = instanceElement.getChildText("ipAddr"); this.hostname = instanceElement.getChildText("hostName"); this.vipAddress = instanceElement.getChildText("vipAddress"); int lastUpdatedTimestampRaw; try { lastUpdatedTimestampRaw = Integer.parseInt(instanceElement.getChildText("lastUpdatedTimestamp")); } catch (Exception e) { lastUpdatedTimestampRaw = -11; } this.lastUpdatedTimestamp = lastUpdatedTimestampRaw; int lastDirtyTimestampRaw; try { lastDirtyTimestampRaw = Integer.parseInt(instanceElement.getChildText("lastDirtyTimestamp")); } catch (Exception e) { lastDirtyTimestampRaw = -11; } this.lastDirtyTimestamp = lastDirtyTimestampRaw; Element port = instanceElement.getChild("port"); if (port != null) { this.isPortEnabled = Boolean.valueOf(port.getAttributeValue("enabled", "true")); this.port = Integer.valueOf(port.getTextTrim()); } else { this.isPortEnabled = false; this.port = -1; } Element securePort = instanceElement.getChild("securePort"); if (securePort != null) { this.isSecurePortEnabled = Boolean.valueOf(securePort.getAttributeValue("enabled", "true")); this.securePort = Integer.valueOf(securePort.getTextTrim()); } else { this.isSecurePortEnabled = false; this.securePort = -1; } Element statusElement = instanceElement.getChild("status"); ServiceStatus status = null; if (statusElement != null) { switch (statusElement.getTextTrim()) { case "UP": status = ServiceStatus.UP; break; case "DOWN": status = ServiceStatus.DOWN; break; default: status = ServiceStatus.UNKNOWN; } } this.status = status; Element overridenStatusElement = instanceElement.getChild("overriddenstatus"); ServiceStatus overridenStatus = null; if (overridenStatusElement != null) { switch (overridenStatusElement.getTextTrim()) { case "UP": overridenStatus = ServiceStatus.UP; break; case "DOWN": overridenStatus = ServiceStatus.DOWN; break; default: overridenStatus = ServiceStatus.UNKNOWN; } } this.overridenStatus = overridenStatus; Element metadata = instanceElement.getChild("metadata"); if (metadata != null) { for (Element element : metadata.getChildren()) { this.metadata.put(element.getName(), element.getText()); } } Element dataCenterInfo = instanceElement.getChild("dataCenterInfo"); if (dataCenterInfo != null) { Attribute dataCenterInfoClass = instanceElement.getAttribute("class"); if (dataCenterInfoClass != null && dataCenterInfoClass.getValue() != null) { switch (dataCenterInfoClass.getValue()) { case EurekaServiceAmazonDataCenterInfo.DATA_CENTER_INFO_CLASS: this.dataCenterInfo = new EurekaServiceAmazonDataCenterInfo(this, dataCenterInfo); break; default: this.dataCenterInfo = null; } } else { this.dataCenterInfo = null; } } else { this.dataCenterInfo = null; } }
From source file:com.move.in.nantes.cars.ParkingParser.java
private static List<Parking> parseXml() { List<Parking> listPakings = new ArrayList<Parking>(); try {// w w w .j a v a 2 s . co m SAXBuilder saxb = new SAXBuilder(); File file = new File("WEB-INF/json/Parking.xml"); Document doc = saxb.build(file); Element root = doc.getRootElement(); List<Element> locations = root.getChildren("data").get(0).getChildren("element"); for (int i = 0; i < locations.size(); i++) { Element elem = locations.get(i); if (elem.getChildText("CATEGORIE").equalsIgnoreCase("1001")) { String name = elem.getChild("geo").getChildText("name"); Coordinates coordinates = getCoordinates(elem.getChildText("_l")); String postalCode = elem.getChildText("CODE_POSTAL"); String city = elem.getChildText("COMMUNE"); String address = elem.getChildText("ADRESSE"); listPakings.add(new Parking(name, coordinates, postalCode, city, address)); } } } catch (JDOMException ex) { Logger.getLogger(ParkingParser.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ParkingParser.class.getName()).log(Level.SEVERE, null, ex); } return listPakings; }
From source file:com.ohnosequences.xml.model.go.GoTermXML.java
License:Open Source License
public static GoTermXML getGoTerm(String id) throws Exception { GoTermXML temp = new GoTermXML(); URL url = new URL(GO_TERM_SERVICE_URL + id); // Connect/*from w w w. j a v a 2 s . com*/ HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); // Get data SAXBuilder saxBuilder = new SAXBuilder(); Document doc = saxBuilder.build(urlConnection.getInputStream()); Element termElement = doc.getRootElement().getChild("term"); String idString, nameString, defString; idString = termElement.getChildText("id"); nameString = termElement.getChildText("name"); defString = termElement.getChild("def").getChildText("defstr"); if (!id.equals(idString)) { throw new Exception( "El id proporcionado y el encontrado en el xml proporcionado por el servicio no son el mismo"); } else { temp.setId(idString); temp.setGoName(nameString); temp.setDefinition(defString); } return temp; }
From source file:com.rhythm.louie.server.LouieProperties.java
License:Apache License
private static void loadInternals() throws JDOMException, IOException { Document internals;//from www. j a v a 2 s.co m SAXBuilder docBuilder = new SAXBuilder(); URL xmlURL = LouieProperties.class.getResource("/config/louie-internal.xml"); internals = docBuilder.build(xmlURL); Element louie = internals.getRootElement(); //Load internal defaults into Server Element serverDef = louie.getChild("server_defaults"); Server.setDefaultHost(serverDef.getChildText(HOST)); Server.setDefaultGateway(serverDef.getChildText(GATEWAY)); Server.setDefaultDisplay(serverDef.getChildText(DISPLAY)); Server.setDefaultIP(serverDef.getChildText(IP)); Server.setDefaultTimezone(serverDef.getChildText(TIMEZONE)); Server.setDefaultLocation(serverDef.getChildText(LOCATION)); Server.setDefaultPort(Integer.parseInt(serverDef.getChildText(PORT))); Server.setDefaultSecure(Boolean.parseBoolean(serverDef.getChildText(SECURE))); //Load internal defaults into ServiceProperties Element serviceDef = louie.getChild("service_defaults"); ServiceProperties.setDefaultCaching(Boolean.parseBoolean(serviceDef.getChildText(CACHING))); ServiceProperties.setDefaultEnable(Boolean.parseBoolean(serviceDef.getChildText(ENABLE))); ServiceProperties.setDefaultReadOnly(Boolean.parseBoolean(serviceDef.getChildText(READ_ONLY))); //Load internal services into ServiceProperties Element coreServices = louie.getChild("core_services"); processServices(coreServices, true); Element schedDef = louie.getChild("scheduler_defaults"); TaskSchedulerProperties.setThreadPoolSize(Integer.parseInt(schedDef.getChildText(POOL_SIZE))); Element accessDef = louie.getChild("group_defaults"); AccessManager.loadGroups(accessDef); }