List of usage examples for org.jdom2 Element getText
public String getText()
From source file:com.hotaviano.tableexporter.xls.XLSExporter.java
License:Open Source License
private void createHeader(Row row, Element element, CellStyle style) { int index = 0; for (Element el : element.getChildren()) { Cell headerColumn = row.createCell(index); headerColumn.setCellStyle(style); headerColumn.setCellValue(el.getText()); index++;/*w ww . j a v a 2s. com*/ } }
From source file:com.hotaviano.tableexporter.xls.XLSExporter.java
License:Open Source License
private void createBody(Sheet sheet, Element element) { int index = 0; for (Element trs : element.getChildren()) { Row row = sheet.createRow(++index); for (int i = 0; i < trs.getChildren().size(); i++) { Element td = trs.getChildren().get(i); row.createCell(i).setCellValue(td.getText()); }//from ww w .ja v a 2s .c o m } }
From source file:com.kixeye.scout.eureka.EurekaServiceAmazonDataCenterInfo.java
License:Apache License
/** * Creates a descriptor from a parent and a raw element. * /* w w w . j a 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 ww w. j a va 2 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.lapis.jsfexporter.xml.XMLExportType.java
License:Apache License
@Override public Element exportRow(IExportRow row) { Element currentElement = (Element) row.getParentRowId(); if (currentElement == null) { currentElement = rootElement;/* w w w . j a v a 2s.c om*/ } for (String namePart : row.getName()) { Element subElement = new Element(cleanElementName(namePart)); currentElement.addContent(subElement); currentElement = subElement; } for (IExportCell cell : row.getCells()) { Element cellElement = currentElement; for (String namePart : cell.getName()) { Element subElement = cellElement.getChild(namePart); if (subElement == null) { subElement = new Element(cleanElementName(namePart)); cellElement.addContent(subElement); } cellElement = subElement; } if (!cellElement.getText().equals("")) { String cellName = cellElement.getName(); cellElement = cellElement.getParentElement(); Element newCellElement = new Element(cellName); cellElement.addContent(newCellElement); cellElement = newCellElement; } cellElement.setText(cell.getValue()); } return currentElement; }
From source file:com.locutus.outils.graphes.ConvertisseurXGMLGraphe.java
License:Open Source License
/** * //from www. j ava 2s . c o m * @param dgc * @param el * @throws GraphConversionException */ private void createNodeAndAdd(DiGraph<String> dgc, Element el) throws GraphConversionException { // On cre un itrateur sur les informations du Node qu'on a // pralablement dtect. Iterator<Element> it3 = el.getChildren().iterator(); // On prpare la rcupration de l'id du node et du nomFichier du // Concept. int[] id = new int[1]; String nomFichierConcept = null; while (it3.hasNext()) { Element local3 = it3.next(); // On rcupre l'id if (local3.getAttribute("key") != null && local3.getAttribute("key").getValue().equals("id")) id[0] = Integer.parseInt(local3.getText()); // On rcupre le nom else if (local3.getAttribute("key") != null && local3.getAttribute("key").getValue().equals("label")) nomFichierConcept = new String(local3.getText()); } // Si le nom n'est pas vide if (nomFichierConcept != null) { idNode.put(id, new Node<String>(nomFichierConcept)); } else { throw new GraphConversionException( "Il manque le nom fichier du concept pour le node en cours de traitement"); } }
From source file:com.locutus.outils.graphes.ConvertisseurXGMLGraphe.java
License:Open Source License
/** * //from w w w .j ava 2 s .c om * @param dgc * @param local2 */ private void createEdge(DiGraph<String> dgc, Element local2) { Iterator<Element> it3 = local2.getChildren().iterator(); int[] arcId = new int[2]; while (it3.hasNext()) { Element local3 = it3.next(); if (local3.getAttribute("key") != null && local3.getAttribute("key").getValue().equals("source")) arcId[0] = Integer.parseInt(local3.getText()); else if (local3.getAttribute("key") != null && local3.getAttribute("key").getValue().equals("target")) arcId[1] = Integer.parseInt(local3.getText()); } edges.add(arcId); }
From source file:com.mycompany.hr.ws.HolidayEndpoint.java
License:Apache License
private Date parseDate(XPathExpression<Element> expression, Element element) throws ParseException { Element result = expression.evaluateFirst(element); if (result != null) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); return dateFormat.parse(result.getText()); } else {/*from w w w .ja va 2 s . c o m*/ throw new IllegalArgumentException("Could not evaluate [" + expression + "] on [" + element + "]"); } }
From source file:com.novell.ldapchai.impl.edir.NmasResponseSet.java
License:Open Source License
private static String readDisplayString(final Element questionElement, final Locale locale) { final Namespace XML_NAMESPACE = Namespace.getNamespace("xml", "http://www.w3.org/XML/1998/namespace"); // someday ResoureBundle won't suck and this will be a 5 line method. // see if the node has any localized displays. final List displayChildren = questionElement.getChildren("display"); // if no locale specified, or if no localized text is available, just use the default. if (locale == null || displayChildren == null || displayChildren.size() < 1) { return questionElement.getText(); }//from ww w .j av a 2 s . c o m // convert the xml 'display' elements to a map of locales/strings final Map<Locale, String> localizedStringMap = new HashMap<Locale, String>(); for (final Object aDisplayChildren : displayChildren) { final Element loopDisplay = (Element) aDisplayChildren; final Attribute localeAttr = loopDisplay.getAttribute("lang", XML_NAMESPACE); if (localeAttr != null) { final String localeStr = localeAttr.getValue(); final String displayStr = loopDisplay.getText(); final Locale localeKey = parseLocaleString(localeStr); localizedStringMap.put(localeKey, displayStr); } } final Locale matchedLocale = localeResolver(locale, localizedStringMap.keySet()); if (matchedLocale != null) { return localizedStringMap.get(matchedLocale); } // none found, so just return the default string. return questionElement.getText(); }
From source file:com.novell.ldapchai.impl.edir.NmasResponseSet.java
License:Open Source License
static ChallengeSet parseNmasUserResponseXML(final String str) throws IOException, JDOMException, ChaiValidationException { final List<Challenge> returnList = new ArrayList<Challenge>(); final Reader xmlreader = new StringReader(str); final SAXBuilder builder = new SAXBuilder(); final Document doc = builder.build(xmlreader); final Element rootElement = doc.getRootElement(); final int minRandom = StringHelper.convertStrToInt(rootElement.getAttributeValue("RandomQuestions"), 0); final String guidValue; {// ww w .j a v a 2s .c o m final Attribute guidAttribute = rootElement.getAttribute("GUID"); guidValue = guidAttribute == null ? null : guidAttribute.getValue(); } for (Iterator iter = doc.getDescendants(new ElementFilter("Challenge")); iter.hasNext();) { final Element loopQ = (Element) iter.next(); final int maxLength = StringHelper.convertStrToInt(loopQ.getAttributeValue("MaxLength"), 255); final int minLength = StringHelper.convertStrToInt(loopQ.getAttributeValue("MinLength"), 2); final String defineStrValue = loopQ.getAttributeValue("Define"); final boolean adminDefined = defineStrValue.equalsIgnoreCase("Admin"); final String typeStrValue = loopQ.getAttributeValue("Type"); final boolean required = typeStrValue.equalsIgnoreCase("Required"); final String challengeText = loopQ.getText(); final Challenge challenge = new ChaiChallenge(required, challengeText, minLength, maxLength, adminDefined, 0, false); returnList.add(challenge); } return new ChaiChallengeSet(returnList, minRandom, null, guidValue); }