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


Java Node.setText方法代碼示例

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


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

示例1: put

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Updates the Document by setting the Text of the Node at the specified
 *  xpath. If there is no node at the specified path, a new one is created.<p>
 *
 *  ISSUE: what if there is no value (one way this happens is when there is a
 *  field in the form but no value is supplied by user. In this case we
 *  shouldn't bother creating a new node because there is no value to insert.
 *  But what if there was formerly a value and the user has deleted it? if the
 *  node is an Element, then should that element be deleted? (The user should
 *  be warned first!) if the node is an attribute, then should that attribute
 *  be deleted? (the user won't be warned, since this does not have the
 *  "ripple" effect that deleting an element can have. (maybe the user should
 *  be warned only if the element has children with values).
 *
 * @param  key  unencoded xpath
 * @param  val  value to assign to node at xpath
 */
public void put(Object key, Object val) {
	String xpath = XPathUtils.decodeXPath((String) key);

	Node node = doc.selectSingleNode(xpath);
	if (node == null) {
		// prtln("DocMap.put(): creating new node for " + xpath);
		try {
			node = createNewNode(xpath);
		} catch (Exception e) {
			prtlnErr("DocMap.put(): couldn't create new node at \"" + xpath + "\": " + e);
			return;
		}
	}
	// 2/28/07 no longer trim values!
	/* 		String trimmed_val = "";
	if (val != null)
		trimmed_val = ((String) val).trim();
	node.setText(trimmed_val);*/
	node.setText(val != null ? (String) val : "");
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:38,代碼來源:DocMap.java

示例2: smartPut

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Tests xpath against provided schema (via SchemaHelper) before putting
 *  value, creating a new Node if one is not found at xpath.
 *
 * @param  xpath          NOT YET DOCUMENTED
 * @param  value          NOT YET DOCUMENTED
 * @exception  Exception  NOT YET DOCUMENTED
 */
public void smartPut(String xpath, String value) throws Exception {
	if (schemaHelper != null && schemaHelper.getSchemaNode(xpath) == null) {
		throw new Exception("stuffValue got an illegal xpath: " + xpath);
	}

	if (value == null)
		throw new Exception("stuffValue got a null value (which is illegal) for " + xpath);

	Node node = selectSingleNode(xpath);
	if (node == null)
		node = createNewNode(xpath);
	if (node == null)
		throw new Exception("smartPut failed to find or create node: " + xpath);
	else {
		// 2/18/07 no longer trim values!
		// node.setText(value.trim());
		node.setText(value);
	}
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:28,代碼來源:DocMap.java

示例3: 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

示例4: setNodeText

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Sets the nodeText for specified path, creating new node if necessary.
 *
 *@param  xpath  The new nodeText value
 *@param  value  The new nodeText value
 */
protected void setNodeText(String xpath, String value) {
	Node node = getNode(xpath);
	if (node == null) {
		prtln("setNodeText did not find node at " + xpath + " - creating ...");
		try {
			node = docMap.createNewNode(xpath);
		} catch (Exception e) {
			prtln("configReader could not find or create node at " + xpath);
			return;
		}
	}
	node.setText(value);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:20,代碼來源:AbstractConfigReader.java

示例5: setMetadataProviderHandle

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Sets the metadataProviderHandle attribute of the CollectionConfigReader
 *  object
 *
 * @param  handle  The new metadataProviderHandle value
 */
public void setMetadataProviderHandle(String handle) {
	// prtln("setMetadataProviderHandle()  handle: \"" + handle + "\"");
	Node node =
		DocumentHelper.makeElement(this.getDocument(), metadataProviderHandlePath);
	node.setText(handle);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:13,代碼來源:CollectionConfigReader.java

示例6: stuffValue

import org.dom4j.Node; //導入方法依賴的package包/類
public void stuffValue (DocMap docMap, String xpath, String value, SchemaHelper schemaHelper) throws Exception {
	
	if (schemaHelper.getSchemaNode(xpath) == null)
		throw new Exception ("stuffValue got an illegal xpath: " + xpath);
	
	Node node = docMap.selectSingleNode (xpath);
	if (node == null)
		node = docMap.createNewNode(xpath);
	if (node == null)
		throw new Exception ("node not found for " + xpath);
	else
		node.setText(value);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:14,代碼來源:SchemaHelperTester.java

示例7: updateCollectionRecord

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Updates a collection record Document.
 *
 * @param  collectionRecordDoc  A collection record Document (may be from the template)
 * @param  title                Title (must not be null)
 * @param  description          Description (can be null)
 * @param  additionalMetadata   Additional metadata (String, XML, or null)
 * @param  xmlFormat            Format specifier or "DDS_UNCHANGED" to leave unchanged
 * @param  key                  Collection key or "DDS_UNCHANGED" to leave unchanged
 * @param  id                   Record ID or "DDS_UNCHANGED" to leave unchanged
 * @param  accessionDate        Accession date or null to leave unchanged
 * @return                      An updated Document
 * @exception  Exception        If error
 */
private org.dom4j.Document updateCollectionRecord(
                                                  org.dom4j.Document collectionRecordDoc,
                                                  String title,
                                                  String description,
                                                  String additionalMetadata,
                                                  String xmlFormat,
                                                  String key,
                                                  String id,
                                                  Date accessionDate) throws Exception {

	if (!key.equals("DDS_UNCHANGED"))
		collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='access']/*[local-name()='key']").setText(key);

	if (!xmlFormat.equals("DDS_UNCHANGED"))
		collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='access']/*[local-name()='key']/@libraryFormat").setText(xmlFormat);

	if (!id.equals("DDS_UNCHANGED"))
		collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='metaMetadata']/*[local-name()='catalogEntries']/*[local-name()='catalog']/@entry").setText(id);

	if (accessionDate != null)
		collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='approval']/*[local-name()='collectionStatuses']/*[local-name()='collectionStatus']/@date").setText(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(accessionDate));

	// Update the short title:
	Node shortTitleNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='shortTitle']");
	if (shortTitleNode != null)
		shortTitleNode.setText(title);

	// For previous repositories that are upgraded, remove the fullTitle (legacy)
	Node fullTitleNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='fullTitle']");
	if (fullTitleNode != null)
		fullTitleNode.detach();

	Node descriptionNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='description']");
	if (descriptionNode == null)
		descriptionNode = ((Branch) collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']")).addElement("description");

	if (description == null || description.trim().length() == 0)
		description = title;
	descriptionNode.setText(description);

	// Delete and then re-create the additionalMetadata node:
	Node additionalMetadataNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='additionalMetadata']");
	if (additionalMetadataNode != null)
		additionalMetadataNode.detach();

	if (additionalMetadata != null && additionalMetadata.trim().length() > 0) {
		org.dom4j.Document additionalMetadataDocument;
		try {
			additionalMetadataDocument = Dom4jUtils.getXmlDocument("<additionalMetadata>" + additionalMetadata + "</additionalMetadata>");
		} catch (Throwable t) {
			throw new PutCollectionException("Error processing additionalMetadata argument: " + t.getMessage(), PutCollectionException.ERROR_CODE_BAD_ADDITIONAL_METADATA);
		}
		((Branch) collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']")).add(additionalMetadataDocument.getRootElement());
	}

	return collectionRecordDoc;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:72,代碼來源:RepositoryManager.java

示例8: setToXMLNode

import org.dom4j.Node; //導入方法依賴的package包/類
public void setToXMLNode(Node xml, Object value, SessionFactoryImplementor factory)
throws HibernateException {
	xml.setText( toXMLString(value, factory) );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:5,代碼來源:NullableType.java

示例9: setToXMLNode

import org.dom4j.Node; //導入方法依賴的package包/類
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) throws HibernateException {
	node.setText( toString( value ) );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:4,代碼來源:ByteArrayBlobType.java

示例10: setToXMLNode

import org.dom4j.Node; //導入方法依賴的package包/類
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory)
		throws HibernateException {
	node.setText( toXMLString(value, factory) );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:5,代碼來源:CustomType.java

示例11: setToXMLNode

import org.dom4j.Node; //導入方法依賴的package包/類
@SuppressWarnings({ "unchecked" })
public final void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) {
	node.setText( toString( (T) value ) );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:5,代碼來源:AbstractStandardBasicType.java

示例12: setToXMLNode

import org.dom4j.Node; //導入方法依賴的package包/類
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) throws HibernateException {
	node.setText( toXMLString(value, factory) );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:4,代碼來源:MetaType.java

示例13: setAggregatorHandle

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Sets the aggregatorHandle attribute of the CollectionConfigReader object
 *
 * @param  pid  The new aggregatorHandle value
 */
public void setAggregatorHandle(String pid) {
	Node node = DocumentHelper.makeElement(this.getDocument(), aggregatorHandlePath);
	node.setText(pid);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:10,代碼來源:CollectionConfigReader.java

示例14: setAgentHandle

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Sets the agentHandle attribute of the CollectionConfigReader object
 *
 * @param  pid  The new agentHandle value
 */
public void setAgentHandle(String pid) {
	Node node = DocumentHelper.makeElement(this.getDocument(), agentHandlePath);
	node.setText(pid);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:10,代碼來源:CollectionConfigReader.java

示例15: setNdrOaiLink

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Sets the ndrOaiLink attribute of the CollectionConfigReader object
 *
 * @param  link  The new ndrOaiLink value
 */
public void setNdrOaiLink(String link) {
	Node node = DocumentHelper.makeElement(this.getDocument(), ndrOaiLinkPath);
	node.setText(link);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:10,代碼來源:CollectionConfigReader.java


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