Java Code Examples for org.dom4j.Element.clearContent()

The following are Jave code examples for showing how to use clearContent() of the org.dom4j.Element class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: joai-project   File: DcsDataRecord.java   View Source Code Vote up 6 votes
/**
 *  Constructor for DcsDataRecord.
 *
 * @param  dcsDataFile       file on disk containing xml source
 * @param  framework         this record's framework
 * @param  collectionConfig  this record's collection
 * @param  dcsDataManager    manager for all dcsDataRecords
 */
public DcsDataRecord(File dcsDataFile, MetaDataFramework framework, CollectionConfig collectionConfig, DcsDataManager dcsDataManager) {
	this.dcsDataManager = dcsDataManager;
	this.collectionConfig = collectionConfig;
	this.source = dcsDataFile;
	this.framework = framework;
	try {
		this.doc = getDocument();
	} catch (Throwable e) {
		prtlnErr("failed to create document: " + e.getMessage());
	}
	if (!source.exists()) { // this is a new DcsDataRecord
		setValidationReport(Constants.UNKNOWN_VALIDITY);
		// an empty or null value means the record is valid
		String dateString = RepositoryService.getDateString();
		setLastTouchDate(dateString);

		// clear the currentStatusEntry - it is initialized when the record is indexed
		// (in RepositoryService.saveNewRecord)
		Element currentEntry = (Element) getNode("/dcsDataRecord/statusEntries");
		currentEntry.clearContent();
	}
	else {
		normalizeStatus();
	}
}
 
Example 2
Project: joai-project   File: CollectionConfigReader.java   View Source Code Vote up 6 votes
/**
 *  NOTE: if we edit the config record via schemedit, the record is
 *  automatically updated and then we have to reload it. But if we edit the
 *  statusMap via another editor, then this method is necessary to update the
 *  config file
 *
 * @param  sMap           The new statusMap value
 * @exception  Exception  NOT YET DOCUMENTED
 */
public void setStatusMap(Map sMap) throws Exception {
	// prtln ("setStatusMap()");
	Node statusFlagsNode = getNode(statusFlagsPath);
	if (statusFlagsNode == null) {
		statusFlagsNode = getDocMap().createNewNode(statusFlagsPath);
		if (statusFlagsNode == null)
			throw new Exception("statusMap node could not found or created");
	}
	Element statusFlagsElement = (Element) statusFlagsNode;
	statusFlagsElement.clearContent();
	statusMap = null;

	for (Iterator i = sMap.keySet().iterator(); i.hasNext(); ) {
		String status = (String) i.next();
		String description = (String) sMap.get(status);

		Element statusFlag = statusFlagsElement.addElement("statusFlag");

		Element statusElement = statusFlag.addElement("status");
		statusElement.setText(status);

		Element descriptionElement = statusFlag.addElement("description");
		descriptionElement.setText(description);
	}
}
 
Example 3
Project: joai-project   File: CollectionConfigReader.java   View Source Code Vote up 6 votes
/**
 *  Sets the tupleMap attribute of the CollectionConfigReader object
 *
 * @param  tMap           The new tupleMap value
 * @exception  Exception  NOT YET DOCUMENTED
 */
public void setTupleMap(Map tMap) throws Exception {
	Node tuplesNode = getNode(tuplesPath);
	if (tuplesNode == null) {
		tuplesNode = getDocMap().createNewNode(tuplesPath);
		if (tuplesNode == null)
			throw new Exception("tupleMap node could not found or created");
	}
	Element tuplesElement = (Element) tuplesNode;
	tuplesElement.clearContent();
	tupleMap = null;

	for (Iterator i = tMap.keySet().iterator(); i.hasNext(); ) {
		String name = (String) i.next();
		String value = (String) tMap.get(name);

		Element tuple = tuplesElement.addElement("tuple");

		Element statusElement = tuple.addElement("name");
		statusElement.setText(name);

		Element descriptionElement = tuple.addElement("value");
		descriptionElement.setText(value);
	}
}
 
Example 4
Project: joai-project   File: DcsDataRecord.java   View Source Code Vote up 5 votes
/**  Clear the ndrInfo element  */
public void clearNdrInfo() {
	Element ndrInfo = getNdrInfo();
	if (ndrInfo != null) {
		ndrInfo.clearContent();
	}
}
 
Example 5
Project: joai-project   File: CollectionConfigReader.java   View Source Code Vote up 5 votes
/**  
* Remove all ndrInfo from the CollectionConfig and set "authority" to "dcs".
*/
public void clearNdrInfo() {
	Element ndrInfo = (Element) getNode(ndrInfoPath);
	if (ndrInfo != null) {
		ndrInfo.clearContent();
	}
	setAuthority("dcs");
}