當前位置: 首頁>>代碼示例>>Java>>正文


Java Element.getTextTrim方法代碼示例

本文整理匯總了Java中org.jdom2.Element.getTextTrim方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.getTextTrim方法的具體用法?Java Element.getTextTrim怎麽用?Java Element.getTextTrim使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jdom2.Element的用法示例。


在下文中一共展示了Element.getTextTrim方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loopxml

import org.jdom2.Element; //導入方法依賴的package包/類
/**
 * Method of going through OWL structure
 */
public void loopxml() {
  Iterator<?> processDescendants = rootNode.getDescendants(new ElementFilter());
  String text = "";

  while (processDescendants.hasNext()) {
    Element e = (Element) processDescendants.next();
    String currentName = e.getName();
    text = e.getTextTrim();
    if ("".equals(text)) {
      LOG.info(currentName);
    } else {
      LOG.info("{} : {}", currentName, text);
    }
  }
}
 
開發者ID:apache,項目名稱:incubator-sdap-mudrod,代碼行數:19,代碼來源:AggregateTriples.java

示例2: getPreferredRubricLabel

import org.jdom2.Element; //導入方法依賴的package包/類
protected static String getPreferredRubricLabel(Element classElement, String lang) {
	Iterator<Element> it = classElement.getChildren(ClamlConstants.RUBRIC_ELEMENT).iterator();
	String label = null;
	while (it.hasNext() && label == null) {
		Element rubric = it.next();
		if (ClamlConstants.RUBRIC_KIND_PREFFERD_ATTR.equals(rubric.getAttributeValue(ClamlConstants.KIND_ATTR))) {
			Element labelElement = rubric.getChild(ClamlConstants.LABEL_ELEMENT);
			if (labelElement != null) {
				if (CommonUtil.isEmptyString(lang) || lang.equals(labelElement.getAttributeValue(ClamlConstants.XML_LANG, Namespace.XML_NAMESPACE))) {
					label = labelElement.getTextTrim();
				}
			} else {
				throw new IllegalArgumentException(getKind(classElement) + " " + getCode(classElement) + ": " + ClamlConstants.RUBRIC_ELEMENT + " without "
						+ ClamlConstants.LABEL_ELEMENT);
			}
		}
	}
	return label;
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:20,代碼來源:ClamlClassProcessor.java

示例3: nextVersionDueDate

import org.jdom2.Element; //導入方法依賴的package包/類
public String nextVersionDueDate() {
    final Element element = nextVersionDueDateXpath.evaluateFirst(rootElement);
    return element == null ? "" : element.getTextTrim();
}
 
開發者ID:NHS-digital-website,項目名稱:hippo,代碼行數:5,代碼來源:PublishingPackage.java

示例4: getNotes

import org.jdom2.Element; //導入方法依賴的package包/類
public String getNotes() {
    final Element notesElement = notesXpath.evaluateFirst(rootElement);
    return notesElement == null ? "" : notesElement.getTextTrim();
}
 
開發者ID:NHS-digital-website,項目名稱:hippo,代碼行數:5,代碼來源:PublishingPackage.java

示例5: getAbstract

import org.jdom2.Element; //導入方法依賴的package包/類
public String getAbstract() {
    // abstract is not a required tag so check for null
    Element element = abstractXpath.evaluateFirst(rootElement);
    return element == null ? null : element.getTextTrim();
}
 
開發者ID:NHS-digital-website,項目名稱:hippo,代碼行數:6,代碼來源:PublishingPackage.java

示例6: parseTrafficMatrixSequence

import org.jdom2.Element; //導入方法依賴的package包/類
/**
 * Parse a traffic matrix file containing a sequence of traffic matrices
 *
 * @param trafficMatrixFile The name of the traffic matrix file
 * @return A <code>TrafficMatrixSequence</code>  object containing a
 * sequence of <code>TrafficMatrix</code> objects
 * @throws JDOMException If the XML file is badly formatted
 * @throws IOException If an error occurs while trying to read the file
 */
@SuppressWarnings("unused")
public static TrafficMatrixSequence parseTrafficMatrixSequence(
		String trafficMatrixFile) throws JDOMException, IOException {
	TrafficMatrixSequence trafficMatrixSequence = null;
	String timeUnit = null;
	int interval = -1;
	
	String name = null;
	String type = null;
	String value = null;

	SAXBuilder builder = new SAXBuilder();
	Document document = (Document) builder.build(trafficMatrixFile);
	Element rootNode = document.getRootElement();

	List<Element> properties = rootNode.getChildren("property");
	for (Element propertyElement: properties) {
		name = propertyElement.getAttributeValue("name");
		type = propertyElement.getAttributeValue("type");
		value = propertyElement.getTextTrim();
		if (name.equals("t_unit")) {
			timeUnit = value;
		} else if (name.equals("interval")) {
			interval = Integer.parseInt(value);
		} else {
			// If format is extended and new properties are added
			// put here the code to handle them
			continue;
		}
	}
	if (interval > 0 && timeUnit != null) {
		trafficMatrixSequence = new TrafficMatrixSequence(
				interval, timeUnit);
	} else {
		trafficMatrixSequence = new TrafficMatrixSequence();
	}
	List<Element> trafficMatrices = rootNode.getChildren("time");
	for (Element tmElement: trafficMatrices) {
		String volumeUnit = null;
		List<Element> tmProperties = tmElement.getChildren("property");
		for (Element tmPropertyElement: tmProperties) {
			name = tmPropertyElement.getAttributeValue("name");
			type = tmPropertyElement.getAttributeValue("type");
			value = tmPropertyElement.getTextTrim();
			if (name.equals("volume_unit")) {
				volumeUnit = value;
			} else {
				// If format is extended and new properties are added
				// put here the code to handle them
				continue;
			}
		}
		if(volumeUnit == null) {
			throw new JDOMException("The traffic matrix does not have " +
									 "a volume_unit attribute");
		}
		TrafficMatrix trafficMatrix = new TrafficMatrix(volumeUnit);
		List<Element> origins = tmElement.getChildren("origin");
		for (Element originElement: origins) {
			String o = originElement.getAttributeValue("id");
			List<Element> destinations = originElement.getChildren("destination");
			for (Element destinationElement: destinations) {
				String d = destinationElement.getAttributeValue("id");
				float load = Float.parseFloat(destinationElement.getValue());
				trafficMatrix.addFlow(o, d, load);
			}
		}
		trafficMatrixSequence.addMatrix(trafficMatrix);
	}
	return trafficMatrixSequence;
}
 
開發者ID:fnss,項目名稱:fnss-java,代碼行數:81,代碼來源:Parser.java


注:本文中的org.jdom2.Element.getTextTrim方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。