List of usage examples for org.dom4j.tree DefaultElement addElement
public Element addElement(String name)
From source file:com.rowtheboat.gui.OptionsSingleton.java
License:Open Source License
/** * This method saves the options to the options.xml file */// ww w .j a v a 2s . c om public void saveOptions() throws SAXException, IOException { /* Start the document */ OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(new FileWriter(optionsFile), format); writer.startDocument(); /* Add the main options section */ Document document = DocumentHelper.createDocument(); Element root = document.addElement("Options"); /* Standard options */ DefaultElement standardElement = new DefaultElement("Standard"); standardElement.addElement("FullStrokeData").addText(getFullStrokeData() + ""); standardElement.addElement("BoatSmoothing").addText(getBoatSmoothing() + ""); root.add(standardElement); /* Input options */ DefaultElement inputElement = new DefaultElement("Input"); inputElement.addElement("SerialPort").addText(getSerialPort()); root.add(inputElement); /* Race options */ DefaultElement raceElement = new DefaultElement("Race"); raceElement.addElement("Countdown").addText(getDelay() + ""); root.add(raceElement); /* End the document */ writer.write(root); writer.endDocument(); writer.close(); }
From source file:net.sourceforge.sqlexplorer.dbproduct.Alias.java
License:Open Source License
/** * Describes this alias in XML; the result can be passed to the Alias(Element) constructor to refabricate it * /* w w w . j a va 2 s .c om*/ * @return */ public Element describeAsXml() { DefaultElement root = new DefaultElement(ALIAS); root.addAttribute(AUTO_LOGON, Boolean.toString(autoLogon)); root.addAttribute(CONNECT_AT_STARTUP, Boolean.toString(connectAtStartup)); root.addAttribute(DRIVER_ID, driverId); root.addAttribute(HAS_NO_USER_NAME, Boolean.toString(hasNoUserName)); root.addElement(NAME).setText(name); root.addElement(URL).setText(url); root.addElement(FOLDER_FILTER_EXPRESSION).setText(folderFilterExpression); root.addElement(NAME_FILTER_EXPRESSION).setText(nameFilterExpression); root.addElement(SCHEMA_FILTER_EXPRESSION).setText(schemaFilterExpression); Element usersElem = root.addElement(USERS); for (User user : users.values()) { // user.setPassword(ALIAS) usersElem.add(user.describeAsXml()); } if (defaultUser != null) { root.addElement(DEFAULT_USER).setText(defaultUser.getUserName()); } return root; }
From source file:org.neo4j.neoclipse.connection.Alias.java
License:Apache License
/** * Describes this alias in XML; the result can be passed to the * Alias(Element) constructor to refabricate it * /*w w w. jav a 2s. com*/ * @return */ public Element describeAsXml() { DefaultElement root = new DefaultElement(ALIAS); root.addElement(NAME).setText(ApplicationUtil.returnEmptyIfBlank(name)); root.addElement(URI).setText(ApplicationUtil.returnEmptyIfBlank(uri)); root.addElement(USER_NAME).setText(ApplicationUtil.returnEmptyIfBlank(userName)); root.addElement(PASSWORD).setText(ApplicationUtil.returnEmptyIfBlank(password)); if (!configurationMap.isEmpty()) { Element configElement = root.addElement(CONFIGURATIONS); Set<Entry<String, String>> entrySet = configurationMap.entrySet(); for (Entry<String, String> entry : entrySet) { DefaultElement config = new DefaultElement(CONFIG); config.addAttribute(CONFIG_NAME, ApplicationUtil.returnEmptyIfBlank(entry.getKey())); config.addAttribute(CONFIG_VALUE, ApplicationUtil.returnEmptyIfBlank(entry.getValue())); configElement.add(config); } } return root; }