当前位置: 首页>>代码示例>>Java>>正文


Java Node.getText方法代码示例

本文整理汇总了Java中org.dom4j.Node.getText方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getText方法的具体用法?Java Node.getText怎么用?Java Node.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.dom4j.Node的用法示例。


在下文中一共展示了Node.getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import org.dom4j.Node; //导入方法依赖的package包/类
/**
 *  Given an encoded xpath, return the value of the referred to node
 *
 * @param  key  xpath encoded as necessary for use in jsp
 * @return      text of the node referred to by the xpath or an empty string if
 *      the node cannot be found
 */
public Object get(String key) {
	String xpath = XPathUtils.decodeXPath(key);
	Node node = doc.selectSingleNode(xpath);
	String val = "";
	if (node == null) {
		// prtln("DocMap.get(): couldn't find node for " + xpath);
	}
	else {
		try {
			val = node.getText();
		} catch (Exception e) {
			prtlnErr("DocMap.get(): unable to get Text for " + xpath);
		}
	}
	return val;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:24,代码来源:DocMap.java

示例2: handleRelationField

import org.dom4j.Node; //导入方法依赖的package包/类
private void handleRelationField(String xPathToField, Document xmlDocument)
{
	List nodes = xmlDocument.selectNodes( xPathToField );
	if(nodes != null){
		for(int i = 0; i< nodes.size(); i++){
			Node currentNode = (Node)nodes.get(i);
			String relation = currentNode.getText();
			
			// Insert the URL if an ID is present...
			if(!relation.toLowerCase().matches(".*http\\:\\/\\/.*|.*ftp\\:\\/\\/.*")){
				String relatedID = relation.substring(relation.indexOf(" ")+1,relation.length());
				
				ResultDocList results = 
					index.searchDocs("id:" + SimpleLuceneIndex.encodeToTerm(relatedID));
				if(results == null || results.size() == 0){
					currentNode.detach();
				}else{
					String url = ((ItemDocReader)((ResultDoc)results.get(0)).getDocReader()).getUrl();
					currentNode.setText(relation.substring(0,relation.indexOf(" ") + 1) + url );				
				}				
			}
		}			
	}			
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:25,代码来源:ADNToOAIDCFormatConverter.java

示例3: getEnumerationValuesOf

import org.dom4j.Node; //导入方法依赖的package包/类
/**
 *  Gets the curently assigned values for the given xpath in the current
 *  Document. This method can be called very many times for the same page, so
 *  we cache values in the multiValuesCache
 *
 * @param  encodedPath  a jsp-encoded xpath
 * @return              The enumerationValuesOf value
 */
public String[] getEnumerationValuesOf(String encodedPath) {
	// prtln("getEnumerationValuesOf() with " + encodedPath);
	String xpath = XPathUtils.decodeXPath(encodedPath);

	if (multiValuesCache.containsKey(xpath)) {
		String[] foundValues = (String[]) multiValuesCache.get(xpath);
		return foundValues;
	}
	List nodes = docMap.selectNodes(xpath);
	if (nodes == null) {
		prtlnErr("\tunable to find any nodes for " + xpath);
		return null;
	}
	String[] values = new String[nodes.size()];
	for (int i = 0; i < nodes.size(); i++) {
		Node node = (Node) nodes.get(i);
		String value = node.getText();
		values[i] = value;
	}

	multiValuesCache.put(xpath, values);
	// prtln("put " + values.length + " items in cache");
	return values;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:33,代码来源:SchemEditForm.java

示例4: readConfig

import org.dom4j.Node; //导入方法依赖的package包/类
private static String readConfig(List<String> configPaths) throws DocumentException {
    SAXReader reader = new SAXReader();
    for (String path : configPaths) {
        File file = new File(path);
        if (file.exists()) {
            Document doc = reader.read(file);
            Element root = doc.getRootElement();
            Iterator<Node> it = root.elementIterator();
            while (it.hasNext()) {
                Node node = it.next();
                if (node != null && "localRepository".equals(node.getName())) {
                    return node.getText();
                }
            }
        }
    }
    return null;
}
 
开发者ID:pingcai,项目名称:maven-package-gui-installer,代码行数:19,代码来源:Application.java

示例5: getInstanceValue

import org.dom4j.Node; //导入方法依赖的package包/类
public String getInstanceValue(Element element, String appName) throws MissingNodeException {
	Object value = element.selectObject(xpath);
	if (value == null)
		throw new MissingNodeException("Could not get value from element (path=" +
			xpath + ")");
	if (value instanceof List) {
		List list = (List) value;
		value = list.get(0);
	}

	if (value instanceof Node) {
		Node node = (Node) value;
		return node.getText();
	} else if (value instanceof String) {
		return (String) value;
	} else if (value instanceof Number) {
		String s = value.toString();
		if (s.endsWith(".0"))
			s = s.substring(0, s.length() - 2);
		return s;
	} else
		throw new IllegalStateException("Unexpected object returned from xpath query: " + value);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:ConvertToARFF.java

示例6: getValue

import org.dom4j.Node; //导入方法依赖的package包/类
private String getValue(String xpath) {
	XPath xpathObj = DocumentHelper.createXPath(xpath);
	xpathObj.setNamespaceURIs(getNSMap());
	Node node = xpathObj.selectSingleNode(doc);
	if (node != null)
		return node.getText();
	else
		return null;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:10,代码来源:ServiceDescriptionReader.java

示例7: getValue

import org.dom4j.Node; //导入方法依赖的package包/类
private String getValue (String xpath) {
	XPath xpathObj = DocumentHelper.createXPath(xpath);
	xpathObj.setNamespaceURIs(getNSMap());
	Node node = xpathObj.selectSingleNode(doc);
	if (node != null)
		return node.getText();
	else
		return null;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:10,代码来源:NsdlDcReader.java

示例8: getNodeText

import org.dom4j.Node; //导入方法依赖的package包/类
/**
 *  return the Text of a Node satisfying the given XPath.
 *
 * @param  xpath  an XPath\
 * @return        Text of Node or empty String if no Node is found
 */
protected String getNodeText(String xpath) {
	Node node = getNode(xpath);
	try {
		return node.getText();
	} catch (Throwable t) {

		// prtln ("getNodeText() failed with " + xpath + "\n" + t.getMessage());
		// Dom4jUtils.prettyPrint (docMap.getDocument());
	}
	return "";
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:18,代码来源:NdrResponseReader.java

示例9: getUrls

import org.dom4j.Node; //导入方法依赖的package包/类
public String[] getUrls() throws Exception {
	// Announcement url
	Node node = getDom4jDoc().selectSingleNode("/news-oppsRecord/announcementURL");
	if (node == null)
		return null;
	return new String[]{node.getText()};
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:8,代码来源:NewsOppsFileIndexingWriter.java

示例10: getDescription

import org.dom4j.Node; //导入方法依赖的package包/类
public String getDescription() throws Exception {
	// Description
	Node node = getDom4jDoc().selectSingleNode("/news-oppsRecord/description");
	if (node != null)
		return node.getText();
	return null;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:8,代码来源:NewsOppsFileIndexingWriter.java

示例11: isEmpty

import org.dom4j.Node; //导入方法依赖的package包/类
/**
 *  Returns true if an element (recursively) has no textual content, no
 *  children, and no attributes with values.<p>
 *
 *  Note: returns FALSE if no node exists at the given path.
 *
 * @param  xpath  Description of the Parameter
 * @return        true if empty, false if any errors are encountered
 */
public boolean isEmpty(String xpath) {
	Node node = doc.selectSingleNode(xpath);
	String msg = "";

	// return FALSE if a node is not found (this is kind of a wierd convention?)
	if (node == null) {
		msg = " ... couldn't find node at " + xpath + " returning FALSE";
		// prtlnErr(msg);
		return false;
	}

	if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
		String content = node.getText();
		// return (content == null || content.trim().length() == 0);

		// 2/28/07 - no longer ignore whitespace!
		return (content == null || content.length() == 0);
	}

	if (node.getNodeType() != Node.ELEMENT_NODE) {
		msg = "  ...  called with an unknown type of node - returning false";
		// prtlnErr(msg);
		return false;
	}

	boolean ret = Dom4jUtils.isEmpty((Element) node);
	return ret;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:38,代码来源:DocMap.java

示例12: getNodeText

import org.dom4j.Node; //导入方法依赖的package包/类
/**
 *  return the Text of a Node satisfying the given XPath.
 *
 * @param  xpath  an XPath\
 * @return        Text of Node or empty String if no Node is found
 */
private String getNodeText(String xpath) {
	Node node = getNode(xpath);
	String val = "";
	try {
		return node.getText();
	} catch (Throwable t) {
		// prtlnErr("getNodeText() failed with " + xpath + ": " + t.getMessage());
	}
	return "";
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:17,代码来源:DcsDataRecord.java

示例13: getNodeText

import org.dom4j.Node; //导入方法依赖的package包/类
/**
 *  return the Text of a Node satisfying the given XPath.
 *
 *@param  xpath  an XPath\
 *@return        Text of Node or empty String if no Node is found
 */
public String getNodeText(String xpath) {
	Node node = getNode(xpath);
	try {
		return node.getText();
	} catch (Throwable t) {
		
		// prtln ("getNodeText() failed with " + xpath + "\n" + t.getMessage());
		// Dom4jUtils.prettyPrint (docMap.getDocument());
	}
	return "";
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:18,代码来源:AbstractConfigReader.java

示例14: tryGetItemText

import org.dom4j.Node; //导入方法依赖的package包/类
public static String tryGetItemText(Node node, String itemName, String defaultValue) {
	if (node == null)
		return defaultValue;

	Node item = node.selectSingleNode(itemName);
	if (item == null)
		return defaultValue;

	return item.getText();
}
 
开发者ID:iunet,项目名称:iunet-blog,代码行数:11,代码来源:XmlUtil.java

示例15: id

import org.dom4j.Node; //导入方法依赖的package包/类
/**
 *  Assumes id is already placed in the xmlRecord. Note - the ID within the recordXml is ultimately
 used by the indexer, NOT the provided id (see RepositoryManger.putRecord).
 *
 *@param  recordXml                      xml record to be put
 *@param  xmlFormat                      metadata format of xml record (e.g., "adn")
 *@param  collection                     destination collection (e.g., "dcc")
 *@param  id                             xml record id
 *@return                                ID of created record
 *@exception  WebServiceClientException  Description of the Exception
 */
public String doPutRecord(String recordXml, String xmlFormat, String collection, String id, String status, String statusNote)
	throws WebServiceClientException {
	// prtln("doPutRecord()");
	// prtln (recordXml);
	String errorMsg;
	try {
		String encodedRecord = URLEncoder.encode(recordXml, "UTF-8");

		// package up the request URL
		String argString = "recordXml=" + encodedRecord.trim();
		argString += "&xmlFormat=" + xmlFormat.trim();
		argString += "&collection=" + collection.trim();
		argString += "&id=" + id.trim();
		if (status != null)
			argString += "&dcsStatus=" + status;
		if (statusNote != null)
			argString += "&dcsStatusNote=" + URLEncoder.encode(statusNote, "UTF-8");

		// URL url = new URL(baseUrl + "?" + argString);
		// Document response = Dom4jUtils.getXmlDocument(url);

		String logMsg = "doPutRecord() params:";
		logMsg += "\n\t" + "xmlFormat: " + xmlFormat;
		logMsg += "\n\t" + "collection: " + collection;
		logMsg += "\n\t" + "id: " + id;
		logMsg += "\n\t" + "status: " + status;
		logMsg += "\n\t" + "statusNote: " + statusNote;
		prtln (logMsg);
		
		setRequestUrl("PutRecord", argString);
		Document doc = getResponseDoc();

		// now we have to parse the doc looking for errors
		prtln(Dom4jUtils.prettyPrint(doc));
		Node errorNode = doc.selectSingleNode("/DCSWebService/error");
		if (errorNode != null) {
			throw new Exception(errorNode.getText());
		}

	} catch (UnsupportedEncodingException e) {
		errorMsg = "xmlRecord encoding error: " + e.getMessage();
		throw new WebServiceClientException(errorMsg);
	} catch (Throwable t) {
		errorMsg = t.getMessage();
		throw new WebServiceClientException(errorMsg);
	}
	return id;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:60,代码来源:WebServiceClient.java


注:本文中的org.dom4j.Node.getText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。