List of usage examples for org.dom4j Element addElement
Element addElement(String name);
Element
node with the given name to this branch and returns a reference to the new node. From source file:XmlTestBuilder.java
License:Open Source License
protected Element createElement(Element parent, AST node) { Element result = parent.addElement("ast"); int type = node.getType(); String typeName = (String) tokens.get(new Integer(type)); if (typeName == null) { result.addAttribute("type", Integer.toString(type)); } else {//from w w w .ja v a 2 s . c om result.addAttribute("name", typeName); } String text = node.getText(); if (text != null) { if (text.indexOf('\n') == -1) { result.addAttribute("text", node.getText()); } else { result.addCDATA(text); } } return result; }
From source file:Main2.java
License:Open Source License
public static void main(String[] args) throws IOException { boolean printTokens = false; boolean showTree = false; boolean produceXml = false; boolean produceSource = false; for (int i = 2; i < args.length; i++) { if (args[i].length() == 2) { switch (args[i].charAt(1)) { case 't': printTokens = true;/*from w ww .j a va 2s .com*/ break; case 'v': showTree = true; break; case 'x': produceXml = true; break; case 's': produceSource = true; break; } } } ASTWindow window = showTree ? new ASTWindow("AST") : null; Document doc = null; if (produceXml) { doc = DocumentHelper.createDocument(DocumentHelper.createElement("asp")); } try { File f = new File(args[0]); File base = new File(args[1]); if (printTokens) { AspStreamSelector selector = new AspStreamSelector(f, base); printApsTokens(selector); if (!(showTree || produceXml)) { return; } } AspParser asp = new AspParser(base, new File("out")); asp.setGenerateCode(produceSource); Map vbTokens = null; Map jsTokens = null; Map tokens = null; List astList = asp.parseFile(f, true); for (Iterator it = astList.iterator(); it.hasNext();) { Object[] val = (Object[]) it.next(); boolean isVb = ((Boolean) val[0]).booleanValue(); if (showTree) { if (isVb) { window.addAST("Original VB", createRoot("VB ASP", (AST) val[1])); if (val.length > 2) { window.addAST("VB Generated", createRoot("VB", (AST) val[2])); } } else { window.addAST("ASP JS", createRoot("JS", (AST) val[1])); window.addAST("JS Generated", createRoot("JS", (AST) val[2])); } } if (produceXml) { String rootName; if (isVb) { rootName = "vb"; if (vbTokens == null) { vbTokens = new HashMap(); putTokens(new VbsTree(), vbTokens); } tokens = vbTokens; } else { rootName = "js"; if (jsTokens == null) { jsTokens = new HashMap(); putTokens(new JsTree(), jsTokens); } tokens = jsTokens; } Element nodeEl = doc.getRootElement().addElement(rootName); Element orig = nodeEl.addElement("original"); new XmlTestBuilder(orig, tokens).visit((AST) val[1]); Element trans = nodeEl.addElement("translated"); new XmlTestBuilder(trans, tokens).visit((AST) val[2]); } } if (produceXml) { OutputFormat of = OutputFormat.createPrettyPrint(); of.setEncoding("ISO-8859-7"); XMLWriter xwriter = new XMLWriter(new FileWriter("asp.xml"), of); xwriter.write(doc); xwriter.close(); } if (showTree && window.hasAST()) { window.pack(); window.setVisible(true); window.setExtendedState(Frame.MAXIMIZED_BOTH); } } catch (Exception ex) { ex.printStackTrace(System.out); System.err.println("Error"); } }
From source file:adr.main.AlcorAdrSettings.java
/** * ? ?? ? .xml //from w w w . jav a 2 s .c om */ public void SaveSettings() { try { Document document = DocumentHelper.createDocument(); Element root = document.addElement("Settings"); root.addElement("COM_Port").addText(m_pCOMPortSettings.GetPort()); root.addElement("COM_Baudrate").addText(Integer.toString(m_pCOMPortSettings.GetBaudRate())); if (m_pCOMPortSettings.GetDataBits() == SerialPort.DATABITS_5) root.addElement("COM_DataBits").addText("5"); else if (m_pCOMPortSettings.GetDataBits() == SerialPort.DATABITS_6) root.addElement("COM_DataBits").addText("6"); else if (m_pCOMPortSettings.GetDataBits() == SerialPort.DATABITS_7) root.addElement("COM_DataBits").addText("7"); else if (m_pCOMPortSettings.GetDataBits() == SerialPort.DATABITS_8) root.addElement("COM_DataBits").addText("8"); else { logger.warn( "Unknown COM_DataBits value '" + m_pCOMPortSettings.GetDataBits() + "'! Saving default!"); root.addElement("COM_DataBits").addText("8"); } switch (m_pCOMPortSettings.GetParity()) { case SerialPort.PARITY_NONE: root.addElement("COM_Parity").addText("None"); break; case SerialPort.PARITY_ODD: root.addElement("COM_Parity").addText("Odd"); break; case SerialPort.PARITY_EVEN: root.addElement("COM_Parity").addText("Even"); break; case SerialPort.PARITY_MARK: root.addElement("COM_Parity").addText("Mark"); break; case SerialPort.PARITY_SPACE: root.addElement("COM_Parity").addText("Space"); break; default: logger.warn("Unknown COM_Parity value '" + m_pCOMPortSettings.GetParity() + "'! Saving default!"); root.addElement("COM_Parity").addText("None"); break; } switch (m_pCOMPortSettings.GetStopBits()) { case SerialPort.STOPBITS_1: root.addElement("COM_StopBits").addText("1"); break; case SerialPort.STOPBITS_2: root.addElement("COM_StopBits").addText("2"); break; default: logger.warn( "Unknown COM_StopBits value '" + m_pCOMPortSettings.GetStopBits() + "'! Saving default!"); root.addElement("COM_StopBits").addText("1"); break; } OutputFormat format = OutputFormat.createPrettyPrint(); //TODO String strSettingsXmlFile = "alcor.adr.settings.xml";//System.getenv( "AMS_ROOT") + "/etc/settings.ams.xml"; XMLWriter writer = new XMLWriter(new FileWriter(strSettingsXmlFile), format); writer.write(document); writer.close(); } catch (IOException ex) { logger.error("IOException caught while saving settings!", ex); } }
From source file:ams.AMSDevSerialNumbers.java
/** * Saves entered numbers to XML file/*w w w . j ava 2 s . c o m*/ */ public void SaveDevNumsToXML() { try { Document document = DocumentHelper.createDocument(); Element root = document.addElement("Settings"); root.addElement("Device1").addText(m_strDev1SerialNumber); root.addElement("Device2").addText(m_strDev2SerialNumber); root.addElement("Device3").addText(m_strDev3SerialNumber); root.addElement("Device4").addText(m_strDev4SerialNumber); root.addElement("Device5").addText(m_strDev5SerialNumber); root.addElement("Device6").addText(m_strDev6SerialNumber); root.addElement("Device7").addText(m_strDev7SerialNumber); root.addElement("Device8").addText(m_strDev8SerialNumber); OutputFormat format = OutputFormat.createPrettyPrint(); String strSerialsXmlFile = System.getenv("AMS_ROOT") + "/serials.xml"; XMLWriter writer = new XMLWriter(new FileWriter(strSerialsXmlFile), format); writer.write(document); writer.close(); } catch (IOException ex) { logger.error("IOException caught while saving serials!", ex); } }
From source file:ams.AMSSettings.java
/** * ? ?? ? .xml /*from w w w.j a v a2 s.c om*/ */ public void SaveSettings() { try { Document document = DocumentHelper.createDocument(); Element root = document.addElement("Settings"); root.addElement("COM_Port").addText(m_pCOMPortSettings.GetPort()); root.addElement("COM_Baudrate").addText(Integer.toString(m_pCOMPortSettings.GetBaudRate())); if (m_pCOMPortSettings.GetDataBits() == SerialPort.DATABITS_5) root.addElement("COM_DataBits").addText("5"); else if (m_pCOMPortSettings.GetDataBits() == SerialPort.DATABITS_6) root.addElement("COM_DataBits").addText("6"); else if (m_pCOMPortSettings.GetDataBits() == SerialPort.DATABITS_7) root.addElement("COM_DataBits").addText("7"); else if (m_pCOMPortSettings.GetDataBits() == SerialPort.DATABITS_8) root.addElement("COM_DataBits").addText("8"); else { logger.warn( "Unknown COM_DataBits value '" + m_pCOMPortSettings.GetDataBits() + "'! Saving default!"); root.addElement("COM_DataBits").addText("8"); } switch (m_pCOMPortSettings.GetParity()) { case SerialPort.PARITY_NONE: root.addElement("COM_Parity").addText("None"); break; case SerialPort.PARITY_ODD: root.addElement("COM_Parity").addText("Odd"); break; case SerialPort.PARITY_EVEN: root.addElement("COM_Parity").addText("Even"); break; case SerialPort.PARITY_MARK: root.addElement("COM_Parity").addText("Mark"); break; case SerialPort.PARITY_SPACE: root.addElement("COM_Parity").addText("Space"); break; default: logger.warn("Unknown COM_Parity value '" + m_pCOMPortSettings.GetParity() + "'! Saving default!"); root.addElement("COM_Parity").addText("None"); break; } switch (m_pCOMPortSettings.GetStopBits()) { case SerialPort.STOPBITS_1: root.addElement("COM_StopBits").addText("1"); break; case SerialPort.STOPBITS_2: root.addElement("COM_StopBits").addText("2"); break; default: logger.warn( "Unknown COM_StopBits value '" + m_pCOMPortSettings.GetStopBits() + "'! Saving default!"); root.addElement("COM_StopBits").addText("1"); break; } Element adams = root.addElement("Devices"); adams.addElement("ADC1").addText(m_strADC1Address); adams.addElement("ADC2").addText(m_strADC2Address); adams.addElement("DAC1").addText(m_strDAC1Address); adams.addElement("DAC2").addText(m_strDAC2Address); adams.addElement("REL1").addText(m_strREL1Address); adams.addElement("ADC3").addText(m_strADC3Address); adams.addElement("ADC4").addText(m_strADC4Address); adams.addElement("DAC3").addText(m_strDAC3Address); adams.addElement("DAC4").addText(m_strDAC4Address); adams.addElement("REL2").addText(m_strREL2Address); // ***** ***** ***** ***** ***** // //Iterator it = AMSConstants.getInstance().T_DEVICES.iterator(); //while( it.hasNext()) { for (int nDevice = AMSConstants.T_DEVICE1; nDevice <= AMSConstants.T_DEVICE8; nDevice++) { //int nDevice = ( int) it.next(); Element device = root.addElement("Device" + nDevice + "_channels"); Element devAn = device.addElement("anode"); devAn.addElement("ADC_V_DEV") .addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetAnoAdcVoltDev()); devAn.addElement("ADC_V_CHAN") .addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetAnoAdcVoltChan()); devAn.addElement("ADC_C_DEV") .addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetAnoAdcCurrDev()); devAn.addElement("ADC_C_CHAN") .addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetAnoAdcCurrChan()); devAn.addElement("DAC_DEV").addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetAnoDacDev()); devAn.addElement("DAC_CHAN") .addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetAnoDacChan()); devAn.addElement("REL_DEV").addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetAnoRelDev()); devAn.addElement("REL_CHAN") .addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetAnoRelChan()); Element devTu = device.addElement("tubulation"); devTu.addElement("ADC_V_DEV") .addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetTubAdcVoltDev()); devTu.addElement("ADC_V_CHAN") .addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetTubAdcVoltChan()); devTu.addElement("ADC_C_DEV") .addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetTubAdcCurrDev()); devTu.addElement("ADC_C_CHAN") .addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetTubAdcCurrChan()); devTu.addElement("DAC_DEV").addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetTubDacDev()); devTu.addElement("DAC_CHAN") .addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetTubDacChan()); devTu.addElement("REL_DEV").addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetTubRelDev()); devTu.addElement("REL_CHAN") .addText("" + ((AMSSettingsTDev) m_mapDevs.get(nDevice)).GetTubRelChan()); } OutputFormat format = OutputFormat.createPrettyPrint(); String strSettingsXmlFile = System.getenv("AMS_ROOT") + "/settings.xml"; XMLWriter writer = new XMLWriter(new FileWriter(strSettingsXmlFile), format); writer.write(document); writer.close(); } catch (IOException ex) { logger.error("IOException caught while saving settings!", ex); } }
From source file:ams.devices.AMSCalibration.java
public void SaveCalibration() { try {/*from w ww. j a v a2 s . c o m*/ Document document = DocumentHelper.createDocument(); Element root = document.addElement("Calibration"); AMSCalibrationUnit unit = (AMSCalibrationUnit) m_mapCalibrationUnits.get(AMSConstants.ADC1); Element anodes = root.addElement("ADC1"); anodes.addElement("ADC1_0_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL1))); anodes.addElement("ADC1_0_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL1))); anodes.addElement("ADC1_1_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL2))); anodes.addElement("ADC1_1_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL2))); anodes.addElement("ADC1_2_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL3))); anodes.addElement("ADC1_2_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL3))); anodes.addElement("ADC1_3_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL4))); anodes.addElement("ADC1_3_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL4))); anodes.addElement("ADC1_4_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL5))); anodes.addElement("ADC1_4_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL5))); anodes.addElement("ADC1_5_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL6))); anodes.addElement("ADC1_5_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL6))); anodes.addElement("ADC1_6_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL7))); anodes.addElement("ADC1_6_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL7))); anodes.addElement("ADC1_7_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL8))); anodes.addElement("ADC1_7_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL8))); unit = (AMSCalibrationUnit) m_mapCalibrationUnits.get(AMSConstants.ADC2); anodes = root.addElement("ADC2"); anodes.addElement("ADC2_0_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL1))); anodes.addElement("ADC2_0_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL1))); anodes.addElement("ADC2_1_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL2))); anodes.addElement("ADC2_1_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL2))); anodes.addElement("ADC2_2_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL3))); anodes.addElement("ADC2_2_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL3))); anodes.addElement("ADC2_3_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL4))); anodes.addElement("ADC2_3_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL4))); anodes.addElement("ADC2_4_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL5))); anodes.addElement("ADC2_4_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL5))); anodes.addElement("ADC2_5_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL6))); anodes.addElement("ADC2_5_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL6))); anodes.addElement("ADC2_6_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL7))); anodes.addElement("ADC2_6_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL7))); anodes.addElement("ADC2_7_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL8))); anodes.addElement("ADC2_7_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL8))); unit = (AMSCalibrationUnit) m_mapCalibrationUnits.get(AMSConstants.ADC3); anodes = root.addElement("ADC3"); anodes.addElement("ADC3_0_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL1))); anodes.addElement("ADC3_0_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL1))); anodes.addElement("ADC3_1_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL2))); anodes.addElement("ADC3_1_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL2))); anodes.addElement("ADC3_2_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL3))); anodes.addElement("ADC3_2_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL3))); anodes.addElement("ADC3_3_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL4))); anodes.addElement("ADC3_3_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL4))); anodes.addElement("ADC3_4_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL5))); anodes.addElement("ADC3_4_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL5))); anodes.addElement("ADC3_5_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL6))); anodes.addElement("ADC3_5_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL6))); anodes.addElement("ADC3_6_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL7))); anodes.addElement("ADC3_6_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL7))); anodes.addElement("ADC3_7_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL8))); anodes.addElement("ADC3_7_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL8))); unit = (AMSCalibrationUnit) m_mapCalibrationUnits.get(AMSConstants.ADC4); anodes = root.addElement("ADC4"); anodes.addElement("ADC4_0_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL1))); anodes.addElement("ADC4_0_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL1))); anodes.addElement("ADC4_1_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL2))); anodes.addElement("ADC4_1_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL2))); anodes.addElement("ADC4_2_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL3))); anodes.addElement("ADC4_2_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL3))); anodes.addElement("ADC4_3_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL4))); anodes.addElement("ADC4_3_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL4))); anodes.addElement("ADC4_4_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL5))); anodes.addElement("ADC4_4_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL5))); anodes.addElement("ADC4_5_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL6))); anodes.addElement("ADC4_5_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL6))); anodes.addElement("ADC4_6_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL7))); anodes.addElement("ADC4_6_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL7))); anodes.addElement("ADC4_7_A").addText(String.format("%.3f", unit.GetSlope(AMSConstants.CHANNEL8))); anodes.addElement("ADC4_7_B").addText(String.format("%.3f", unit.GetShift(AMSConstants.CHANNEL8))); OutputFormat format = OutputFormat.createPrettyPrint(); String strCalibrationFilePathName = System.getenv("AMS_ROOT") + "/calibration.xml"; XMLWriter writer = new XMLWriter(new FileWriter(strCalibrationFilePathName), format); writer.write(document); writer.close(); } catch (IOException ex) { logger.error("IOException caught while saving calibration!", ex); } }
From source file:android.apn.androidpn.server.xmpp.push.NotificationManager.java
License:Open Source License
/** * Creates a new notification IQ and returns it. *///from w ww .j av a 2s.c o m private IQ createNotificationIQ(String apiKey, String title, String message, String uri) { Random random = new Random(); String id = Integer.toHexString(random.nextInt()); // String id = String.valueOf(System.currentTimeMillis()); Element notification = DocumentHelper.createElement(QName.get("notification", NOTIFICATION_NAMESPACE)); notification.addElement("id").setText(id); notification.addElement("apiKey").setText(apiKey); notification.addElement("title").setText(title); notification.addElement("message").setText(message); notification.addElement("uri").setText(uri); IQ iq = new IQ(); iq.setType(IQ.Type.set); iq.setChildElement(notification); return iq; }
From source file:architecture.common.license.io.LicenseWriter.java
License:Apache License
public LicenseWriter(License license, LicenseSigner signer) throws LicenseException { this.license = license; try {//from ww w.j a va2s .c o m document = DocumentHelper.parseText(license.toXML()); Element root = document.getRootElement(); signer.sign(license); Element sig = root.addElement("signature"); sig.setText(license.getSignature()); } catch (Exception e) { log.fatal(e.getMessage(), e); throw new LicenseException(L10NUtils.format("002101", e.getMessage()), e); } }
From source file:architecture.common.license.License.java
License:Apache License
public String toXML() { DocumentFactory factory = DocumentFactory.getInstance(); Document document = factory.createDocument(); Element root = document.addElement("license"); root.addAttribute("id", String.valueOf(getLicenseId())); root.addAttribute("name", getName()); if (edition != null) root.addAttribute("edition", getEdition()); root.addAttribute("creationDate", formatDate(getCreationDate())); root.addAttribute("version", getVersion().getVersionString()); root.addAttribute("type", getType().name()); if (getClient() != null) { Element client = root.addElement("client"); if (getClient().getName() != null) client.addAttribute("name", getClient().getName()); if (getClient().getCompany() != null) client.addAttribute("company", getClient().getCompany()); }/*from www . ja v a 2 s .com*/ for (Module m : getModules()) { Element me = root.addElement("module"); me.addAttribute("name", m.getName()); } for (java.util.Map.Entry<String, String> entry : getProperties().entrySet()) { Element prop = root.addElement("property"); prop.addAttribute("name", (String) entry.getKey()); prop.setText((String) entry.getValue()); } return document.asXML(); }
From source file:architecture.common.lifecycle.internal.XmlApplicationPropertiesOld.java
License:Apache License
public synchronized String put(String name, String value) { propertyCache.put(name, value);/*from w w w .ja v a 2s . co m*/ String propName[] = parsePropertyName(name); Element element = doc.getRootElement(); for (String n : propName) { if (element.element(n) == null) element.addElement(n); element = element.element(n); } element.setText(value); saveProperties(); return null; }