Java Code Examples for org.dom4j.DocumentHelper#createXPath()

The following examples show how to use org.dom4j.DocumentHelper#createXPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Update1To2.java    From jeveassets with GNU General Public License v2.0 6 votes vote down vote up
private void convertTableSettings(final Document doc) {
	XPath xpathSelector = DocumentHelper.createXPath("/settings/columns/column");
	List<?> results = xpathSelector.selectNodes(doc);
	List<String> tableColumnNames = new ArrayList<String>();
	List<String> tableColumnVisible = new ArrayList<String>();
	for (Iterator<?> iter = results.iterator(); iter.hasNext();) {
		Element element = (Element) iter.next();
		Attribute name = element.attribute("name");
		Attribute visible = element.attribute("visible");
		tableColumnNames.add(name.getText());
		if (visible.getText().equals("true")) {
			tableColumnVisible.add(name.getText());
		}
	}
	String mode = convertFlag(doc);
	writeTableSettings(doc, mode, tableColumnNames, tableColumnVisible);
}
 
Example 2
Source File: Update1To2.java    From jeveassets with GNU General Public License v2.0 6 votes vote down vote up
private String convertFlag(final Document doc) {
	XPath flagSelector = DocumentHelper.createXPath("/settings/flags/flag");
	List<?> flagResults = flagSelector.selectNodes(doc);
	boolean text = false;
	boolean window = false;
	for (Iterator<?> iter = flagResults.iterator(); iter.hasNext();) {
		Element element = (Element) iter.next();
		Attribute key = element.attribute("key");
		Attribute visible = element.attribute("enabled");
		if (key.getText().equals("FLAG_AUTO_RESIZE_COLUMNS_TEXT")) {
			text = visible.getText().equals("true");
			element.detach();
		}
		if (key.getText().equals("FLAG_AUTO_RESIZE_COLUMNS_WINDOW")) {
			window = visible.getText().equals("true");
			element.detach();
		}
	}
	if (text) {
		return "TEXT";
	}
	if (window) {
		return "WINDOW";
	}
	return "NONE";
}
 
Example 3
Source File: MeijoFormat.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private XPath makeFaceNeighbourXPath(int edgeID, int faceID) {
    String path = FACE_NEIGHBOUR_XPATH_STRING.replace("$edgeid", String.valueOf(edgeID)).replace("$faceid", String.valueOf(faceID));
    //        Logger.debug("Neighbour XPath: " + path);
    XPath result = DocumentHelper.createXPath(path);
    result.setNamespaceURIs(URIS);
    return result;
}
 
Example 4
Source File: Update1To2.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
private void convertModes(final Document doc) {
	XPath xpathSelector = DocumentHelper.createXPath("/settings/filters/filter/row");
	List<?> results = xpathSelector.selectNodes(doc);
	for (Iterator<?> iter = results.iterator(); iter.hasNext();) {
		Element elem = (Element) iter.next();
		Attribute attr = elem.attribute("mode");
		String currentValue = attr.getText();
		attr.setText(convertMode(currentValue));
	}
}
 
Example 5
Source File: Update1To2.java    From jeveassets with GNU General Public License v2.0 5 votes vote down vote up
private void convertDefaultPriceModes(final Document doc) {
	XPath xpathSelector = DocumentHelper.createXPath("/settings/marketstat");
	List<?> results = xpathSelector.selectNodes(doc);
	for (Iterator<?> iter = results.iterator(); iter.hasNext();) {
		Element elem = (Element) iter.next();
		Attribute attr = elem.attribute("defaultprice");
		if (attr != null) { //May not exist (in early versions)
			String currentValue = attr.getText();
			attr.setText(convertDefaultPriceMode(currentValue));
		}
	}
}