List of usage examples for org.dom4j Element elements
List<Element> elements();
From source file:com.liferay.util.xml.XMLMerger.java
License:Open Source License
public Document merge(Document masterDoc, Document slaveDoc) { Document mergedDoc = (Document) masterDoc.clone(); Element root1 = mergedDoc.getRootElement(); Element root2 = slaveDoc.getRootElement(); List children1 = root1.elements(); List children2 = root2.elements(); for (int i = 0; i < children2.size(); i++) { Element el2 = (Element) children2.get(i); Element el2Clone = (Element) el2.clone(); el2Clone.detach();// www . jav a 2 s .c om root1.add(el2Clone); } organizeXML(mergedDoc); return mergedDoc; }
From source file:com.liferay.util.xml.XMLMerger.java
License:Open Source License
private void _addChildren(Element first, Collection childrenToJoin) { Collection clones = new Vector(); Iterator itr = childrenToJoin.iterator(); while (itr.hasNext()) { clones.add(((Element) itr.next()).clone()); }/*w w w . j a v a 2 s . c o m*/ first.elements().addAll(clones); }
From source file:com.liferay.util.xml.XMLMerger.java
License:Open Source License
private void _mergeDuplicateElements(Element el, ElementComparator comparator) { if (el.elements().size() > 0) { List children = el.elements(); List originals = new ArrayList(); List duplicates = new ArrayList(); for (int i = 0; i < children.size(); i++) { Element child = (Element) children.get(i); if (_containsObjectEqualTo(child, originals, comparator)) { if (comparator.shouldJoinChildren(child)) { Element first = _findObjectEqualTo(child, originals, comparator); Collection childrenToJoin = child.elements(); _addChildren(first, childrenToJoin); }/* ww w .java2 s .c o m*/ duplicates.add(child); } else { originals.add(child); } } for (int i = 0; i < duplicates.size(); i++) { Element duplicate = (Element) duplicates.get(i); duplicate.detach(); } Iterator itr = originals.iterator(); while (itr.hasNext()) { Element child = (Element) itr.next(); _mergeDuplicateElements(child, comparator); } } }
From source file:com.litt.core.security.license.gui.ConfigPanel.java
/** * Create the panel./*from w w w .j a v a 2 s . com*/ */ public ConfigPanel(final Gui gui) { GridBagLayout gbl_configPanel = new GridBagLayout(); gbl_configPanel.columnWidths = new int[] { 0, 0, 0, 0 }; gbl_configPanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; gbl_configPanel.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; gbl_configPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; this.setLayout(gbl_configPanel); JLabel label_18 = new JLabel("?"); GridBagConstraints gbc_label_18 = new GridBagConstraints(); gbc_label_18.insets = new Insets(0, 0, 5, 5); gbc_label_18.anchor = GridBagConstraints.EAST; gbc_label_18.gridx = 0; gbc_label_18.gridy = 0; this.add(label_18, gbc_label_18); comboBox_config = new JComboBox(); comboBox_config.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { try { LicenseConfig licenseConfig = (LicenseConfig) e.getItem(); File licenseFile = new File(licenseConfig.getLicenseFilePath()); currentLicenseConfig = licenseConfig; loadLicense(licenseFile); gui.setCurrentLicenseConfig(currentLicenseConfig); } catch (Exception e1) { JOptionPane.showMessageDialog(self, e1.getMessage()); } } } }); GridBagConstraints gbc_comboBox_config = new GridBagConstraints(); gbc_comboBox_config.insets = new Insets(0, 0, 5, 5); gbc_comboBox_config.fill = GridBagConstraints.HORIZONTAL; gbc_comboBox_config.gridx = 1; gbc_comboBox_config.gridy = 0; this.add(comboBox_config, gbc_comboBox_config); JButton button_3 = new JButton("?"); button_3.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { try { comboBox_config.removeAllItems(); File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml"); Document document = XmlUtils.readXml(configFile); Element rootE = document.getRootElement(); List productList = rootE.elements(); for (int i = 0; i < productList.size(); i++) { Element productE = (Element) productList.get(i); String productCode = productE.attributeValue("code"); List customerList = productE.elements(); for (int j = 0; j < customerList.size(); j++) { Element customerE = (Element) customerList.get(j); String customerCode = customerE.attributeValue("code"); LicenseConfig licenseConfig = new LicenseConfig(); licenseConfig.setProductCode(productCode); licenseConfig.setCustomerCode(customerCode); licenseConfig.setLicenseId(customerE.elementText("licenseId")); licenseConfig.setEncryptedLicense(customerE.elementText("encryptedLicense")); licenseConfig.setRootFilePath(Gui.HOME_PATH); licenseConfig.setLicenseFilePath(Gui.HOME_PATH + File.separator + productCode + File.separator + customerCode + File.separator + "license.xml"); licenseConfig.setPriKeyFilePath( Gui.HOME_PATH + File.separator + productCode + File.separator + "private.key"); licenseConfig.setPubKeyFilePath( Gui.HOME_PATH + File.separator + productCode + File.separator + "license.key"); comboBox_config.addItem(licenseConfig); if (i == 0 && j == 0) { File licenseFile = new File(licenseConfig.getLicenseFilePath()); currentLicenseConfig = licenseConfig; loadLicense(licenseFile); gui.setCurrentLicenseConfig(currentLicenseConfig); btnDelete.setEnabled(true); } } } } catch (Exception e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(self, e1.getMessage()); } } }); btnDelete = new JButton(); btnDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (currentLicenseConfig != null) { try { String productCode = currentLicenseConfig.getProductCode(); String customerCode = currentLicenseConfig.getCustomerCode(); //congfig.xml File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml"); Document document = XmlUtils.readXml(configFile); Element customerNode = (Element) document.selectSingleNode( "//product[@code='" + productCode + "']/customer[@code='" + customerCode + "']"); if (customerNode != null) { customerNode.detach(); XmlUtils.writeXml(configFile, document); } // File licensePathFile = new File(currentLicenseConfig.getLicenseFilePath()); if (licensePathFile.exists()) { FileUtils.deleteDirectory(licensePathFile.getParentFile()); } //comboboxitem comboBox_config.removeItemAt(comboBox_config.getSelectedIndex()); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (comboBox_config.getItemCount() <= 0) { btnDelete.setEnabled(false); } } } }); btnDelete.setEnabled(false); btnDelete.setIcon(new ImageIcon(ConfigPanel.class.getResource("/images/icon_delete.png"))); GridBagConstraints gbc_btnDelete = new GridBagConstraints(); gbc_btnDelete.insets = new Insets(0, 0, 5, 0); gbc_btnDelete.gridx = 2; gbc_btnDelete.gridy = 0; add(btnDelete, gbc_btnDelete); GridBagConstraints gbc_button_3 = new GridBagConstraints(); gbc_button_3.insets = new Insets(0, 0, 5, 5); gbc_button_3.gridx = 1; gbc_button_3.gridy = 1; this.add(button_3, gbc_button_3); JLabel lblid = new JLabel("?ID"); GridBagConstraints gbc_lblid = new GridBagConstraints(); gbc_lblid.anchor = GridBagConstraints.EAST; gbc_lblid.insets = new Insets(0, 0, 5, 5); gbc_lblid.gridx = 0; gbc_lblid.gridy = 2; this.add(lblid, gbc_lblid); textField_licenseId = new JTextField(); GridBagConstraints gbc_textField_licenseId = new GridBagConstraints(); gbc_textField_licenseId.insets = new Insets(0, 0, 5, 5); gbc_textField_licenseId.fill = GridBagConstraints.HORIZONTAL; gbc_textField_licenseId.gridx = 1; gbc_textField_licenseId.gridy = 2; this.add(textField_licenseId, gbc_textField_licenseId); textField_licenseId.setColumns(10); JLabel label = new JLabel("?"); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.anchor = GridBagConstraints.EAST; gbc_label.insets = new Insets(0, 0, 5, 5); gbc_label.gridx = 0; gbc_label.gridy = 3; add(label, gbc_label); comboBox_licenseType = new JComboBox(MapComboBoxModel.getLicenseTypeOptions().toArray()); GridBagConstraints gbc_comboBox_licenseType = new GridBagConstraints(); gbc_comboBox_licenseType.insets = new Insets(0, 0, 5, 5); gbc_comboBox_licenseType.fill = GridBagConstraints.HORIZONTAL; gbc_comboBox_licenseType.gridx = 1; gbc_comboBox_licenseType.gridy = 3; add(comboBox_licenseType, gbc_comboBox_licenseType); JLabel label_23 = new JLabel("???"); GridBagConstraints gbc_label_23 = new GridBagConstraints(); gbc_label_23.anchor = GridBagConstraints.EAST; gbc_label_23.insets = new Insets(0, 0, 5, 5); gbc_label_23.gridx = 0; gbc_label_23.gridy = 4; this.add(label_23, gbc_label_23); textField_productName = new JTextField(); GridBagConstraints gbc_textField_productName = new GridBagConstraints(); gbc_textField_productName.insets = new Insets(0, 0, 5, 5); gbc_textField_productName.fill = GridBagConstraints.HORIZONTAL; gbc_textField_productName.gridx = 1; gbc_textField_productName.gridy = 4; this.add(textField_productName, gbc_textField_productName); textField_productName.setColumns(10); JLabel label_24 = new JLabel("???"); GridBagConstraints gbc_label_24 = new GridBagConstraints(); gbc_label_24.anchor = GridBagConstraints.EAST; gbc_label_24.insets = new Insets(0, 0, 5, 5); gbc_label_24.gridx = 0; gbc_label_24.gridy = 5; this.add(label_24, gbc_label_24); textField_companyName = new JTextField(); GridBagConstraints gbc_textField_companyName = new GridBagConstraints(); gbc_textField_companyName.insets = new Insets(0, 0, 5, 5); gbc_textField_companyName.fill = GridBagConstraints.HORIZONTAL; gbc_textField_companyName.gridx = 1; gbc_textField_companyName.gridy = 5; this.add(textField_companyName, gbc_textField_companyName); textField_companyName.setColumns(10); JLabel label_25 = new JLabel("??"); GridBagConstraints gbc_label_25 = new GridBagConstraints(); gbc_label_25.anchor = GridBagConstraints.EAST; gbc_label_25.insets = new Insets(0, 0, 5, 5); gbc_label_25.gridx = 0; gbc_label_25.gridy = 6; this.add(label_25, gbc_label_25); textField_customerName = new JTextField(); GridBagConstraints gbc_textField_customerName = new GridBagConstraints(); gbc_textField_customerName.insets = new Insets(0, 0, 5, 5); gbc_textField_customerName.fill = GridBagConstraints.HORIZONTAL; gbc_textField_customerName.gridx = 1; gbc_textField_customerName.gridy = 6; this.add(textField_customerName, gbc_textField_customerName); textField_customerName.setColumns(10); JLabel label_26 = new JLabel(""); GridBagConstraints gbc_label_26 = new GridBagConstraints(); gbc_label_26.anchor = GridBagConstraints.EAST; gbc_label_26.insets = new Insets(0, 0, 5, 5); gbc_label_26.gridx = 0; gbc_label_26.gridy = 7; this.add(label_26, gbc_label_26); textField_version = new JTextField(); GridBagConstraints gbc_textField_version = new GridBagConstraints(); gbc_textField_version.insets = new Insets(0, 0, 5, 5); gbc_textField_version.fill = GridBagConstraints.HORIZONTAL; gbc_textField_version.gridx = 1; gbc_textField_version.gridy = 7; this.add(textField_version, gbc_textField_version); textField_version.setColumns(10); JLabel label_27 = new JLabel(""); GridBagConstraints gbc_label_27 = new GridBagConstraints(); gbc_label_27.insets = new Insets(0, 0, 5, 5); gbc_label_27.gridx = 0; gbc_label_27.gridy = 8; this.add(label_27, gbc_label_27); datePicker_expiredDate = new DatePicker(new Date(), "yyyy-MM-dd", null, null); //datePicker_expiredDate.setTimePanleVisible(false); GridBagConstraints gbc_datePicker_expiredDate = new GridBagConstraints(); gbc_datePicker_expiredDate.anchor = GridBagConstraints.WEST; gbc_datePicker_expiredDate.insets = new Insets(0, 0, 5, 5); gbc_datePicker_expiredDate.gridx = 1; gbc_datePicker_expiredDate.gridy = 8; this.add(datePicker_expiredDate, gbc_datePicker_expiredDate); JButton button_5 = new JButton(""); button_5.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (currentLicenseConfig != null) { try { File priKeyFile = new File(currentLicenseConfig.getPriKeyFilePath()); File licenseFile = new File(currentLicenseConfig.getLicenseFilePath()); //?? License license = new License(); license.setLicenseId(textField_licenseId.getText()); license.setLicenseType( ((MapComboBoxModel) comboBox_licenseType.getSelectedItem()).getValue().toString()); license.setProductName(textField_productName.getText()); license.setCompanyName(textField_companyName.getText()); license.setCustomerName(textField_customerName.getText()); license.setVersion(Version.parseVersion(textField_version.getText())); license.setCreateDate(new Date()); license.setExpiredDate(Utility.parseDate(datePicker_expiredDate.getText())); //???? DigitalSignatureTool utils = new DigitalSignatureTool("DSA"); utils.readPriKey(priKeyFile.getAbsolutePath()); //?? String signedData = utils.sign(license.toString()); //?????? license.setSignature(signedData); LicenseManager.writeLicense(license, licenseFile); //config.xml String licenseContent = XmlUtils.readXml(licenseFile).asXML(); //DES ISecurity security = new DESTool(currentLicenseConfig.getLicenseId(), Algorithm.BLOWFISH); licenseContent = security.encrypt(licenseContent); txt_encryptContent.setText(licenseContent); currentLicenseConfig.setEncryptedLicense(licenseContent); System.out.println(licenseContent); File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml"); XMLConfiguration config = new XMLConfiguration(configFile); config.setAutoSave(true); config.setProperty("product.customer.encryptedLicense", licenseContent); //??zip? File customerPath = licenseFile.getParentFile(); //???license????? File licensePath = new File(customerPath.getParent(), "license"); if (!licensePath.exists() && !licensePath.isDirectory()) { licensePath.mkdir(); } else { FileUtils.cleanDirectory(licensePath); } //? FileUtils.copyDirectory(customerPath, licensePath); String currentTime = FormatDateTime.formatDateTimeNum(new Date()); ZipUtils.zip(licensePath, new File(licensePath.getParentFile(), currentLicenseConfig.getCustomerCode() + "-" + currentTime + ".zip")); //license FileUtils.deleteDirectory(licensePath); JOptionPane.showMessageDialog(self, "??"); } catch (Exception e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(self, e1.getMessage()); } } else { JOptionPane.showMessageDialog(self, "???"); } } }); GridBagConstraints gbc_button_5 = new GridBagConstraints(); gbc_button_5.insets = new Insets(0, 0, 5, 5); gbc_button_5.gridx = 1; gbc_button_5.gridy = 9; this.add(button_5, gbc_button_5); JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.insets = new Insets(0, 0, 0, 5); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 1; gbc_scrollPane.gridy = 10; this.add(scrollPane, gbc_scrollPane); txt_encryptContent = new JTextArea(); txt_encryptContent.setLineWrap(true); scrollPane.setViewportView(txt_encryptContent); // txt_encryptContent = new JTextArea(20, 20); // GridBagConstraints gbc_6 = new GridBagConstraints(); // gbc_6.gridx = 1; // gbc_6.gridy = 10; // this.add(txt_encryptContent, gbc_6); }
From source file:com.litt.core.security.license.gui.CustomerPanel.java
private void initProduct() { try {//from ww w . j av a2 s.com //??? comboBoxProduct.removeAllItems(); comboBoxProduct.addItem("..."); File configFile = new File(Gui.HOME_PATH, "config.xml"); Document document = XmlUtils.readXml(configFile); Element rootE = document.getRootElement(); List<Element> productNodeList = rootE.elements(); for (Element productNode : productNodeList) { String productCode = productNode.attributeValue("code"); String productName = productNode.attributeValue("name"); comboBoxProduct.addItem(productCode + "-" + productName); } } catch (Exception e) { JOptionPane.showMessageDialog(this, e.getMessage()); } }
From source file:com.lzw.work.cms.manager.PreCarRegisterManager.java
public void getCarInfoByCarNumber() { try {/*from w ww . j a v a2 s . c om*/ TmriJaxRpcOutAccessServiceStub trias = new TmriJaxRpcOutAccessServiceStub(); TmriJaxRpcOutAccessServiceStub.QueryObjectOut qo = new TmriJaxRpcOutAccessServiceStub.QueryObjectOut(); HttpServletRequest request = ServletActionContext.getRequest(); String hpzl = request.getParameter("hpzl"); String hphm = request.getParameter("hphm"); if (hpzl == null || "".equals(hpzl.trim()) || hphm == null || "".equals(hphm.trim())) { return; } qo.setJkid("01C21"); qo.setJkxlh( "7F1C0909010517040815E3FF83F5F3E28BCC8F9B818DE7EA88DFD19EB8C7D894B9B9BCE0BFD8D6D0D0C4A3A8D0C5CFA2BCE0B9DCCFB5CDB3A3A9"); qo.setUTF8XmlDoc("<root><QueryCondition><hphm>" + hphm + "</hphm><hpzl>" + hpzl + "</hpzl></QueryCondition></root>"); qo.setXtlb("01"); String returnXML = trias.queryObjectOut(qo).getQueryObjectOutReturn(); String xml = URLCodeUtil.urlDecode(returnXML); Document doc = DocumentHelper.parseText(xml); Element root = doc.getRootElement(); Element dataElecmet = root.element("body").element("veh"); if (dataElecmet != null) { Map<String, String> dataMap = new HashMap<String, String>(); for (Object o : dataElecmet.elements()) { Element element = (Element) o; String key = element.getName(); String value = element.getText(); dataMap.put(key, value); } pw.print(JSONObject.fromObject(dataMap)); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.lzw.work.cms.manager.PreCarRegisterManager.java
public void getCarInfoByCarNumberConvert() { try {/* ww w . j av a 2 s . c o m*/ TmriJaxRpcOutAccessServiceStub trias = new TmriJaxRpcOutAccessServiceStub(); TmriJaxRpcOutAccessServiceStub.QueryObjectOut qo = new TmriJaxRpcOutAccessServiceStub.QueryObjectOut(); HttpServletRequest request = ServletActionContext.getRequest(); String hpzl = request.getParameter("hpzl"); String hphm = request.getParameter("hphm"); if (hpzl == null || "".equals(hpzl.trim()) || hphm == null || "".equals(hphm.trim())) { return; } qo.setJkid("01C21"); qo.setJkxlh( "7F1C0909010517040815E3FF83F5F3E28BCC8F9B818DE7EA88DFD19EB8C7D894B9B9BCE0BFD8D6D0D0C4A3A8D0C5CFA2BCE0B9DCCFB5CDB3A3A9"); qo.setUTF8XmlDoc("<root><QueryCondition><hphm>" + hphm + "</hphm><hpzl>" + hpzl + "</hpzl></QueryCondition></root>"); qo.setXtlb("01"); String returnXML = trias.queryObjectOut(qo).getQueryObjectOutReturn(); String xml = URLCodeUtil.urlDecode(returnXML); Document doc = DocumentHelper.parseText(xml); Element root = doc.getRootElement(); Element dataElecmet = root.element("body").element("veh"); if (dataElecmet != null) { Map<String, String> dataMap = new HashMap<String, String>(); for (Object o : dataElecmet.elements()) { Element element = (Element) o; String key = element.getName(); String value = element.getText(); dataMap.put(key, CommonUtil.convertCode(key, value)); } String clxh = (String) dataMap.get("clxh"); if (clxh != null) { String ggbh = trafficDBManager.getFirstGGBH(clxh); dataMap.put("ggbh", ggbh); } pw.print(JSONObject.fromObject(dataMap)); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.lzw.work.cms.manager.PreCarRegisterManager.java
public void getCarInfo2ByCarNumber() { try {/*from w w w .ja va2 s . co m*/ TmriJaxRpcOutAccessServiceStub trias = new TmriJaxRpcOutAccessServiceStub(); TmriJaxRpcOutAccessServiceStub.QueryObjectOut qo = new TmriJaxRpcOutAccessServiceStub.QueryObjectOut(); HttpServletRequest request = ServletActionContext.getRequest(); String hpzl = request.getParameter("hpzl"); String hphm = request.getParameter("hphm"); String sf = request.getParameter("sf"); System.out.println("sf" + sf); if (sf != null) { sf = URLEncoder.encode(sf, "UTF-8"); } System.out.println("sf" + sf); if (hpzl == null || "".equals(hpzl.trim()) || hphm == null || "".equals(hphm.trim())) { return; } qo.setJkid("01C49"); qo.setJkxlh( "7F1C0909010517040815E3FF83F5F3E28BCC8F9B818DE7EA88DFD19EB8C7D894B9B9BCE0BFD8D6D0D0C4A3A8D0C5CFA2BCE0B9DCCFB5CDB3A3A9"); qo.setUTF8XmlDoc("<root><QueryCondition><hphm>" + hphm + "</hphm><hpzl>" + hpzl + "</hpzl><sf>" + sf + "</sf></QueryCondition></root>"); qo.setXtlb("01"); String returnXML = trias.queryObjectOut(qo).getQueryObjectOutReturn(); String xml = URLCodeUtil.urlDecode(returnXML); Document doc = DocumentHelper.parseText(xml); Element root = doc.getRootElement(); System.out.println(root.asXML()); Element dataElecmet = root.element("body").element("veh"); if (dataElecmet != null) { Map<String, String> dataMap = new HashMap<String, String>(); for (Object o : dataElecmet.elements()) { Element element = (Element) o; String key = element.getName(); String value = element.getText(); dataMap.put(key, CommonUtil.convertCode(key, value)); } String clxh = (String) dataMap.get("clxh"); if (clxh != null) { String ggbh = trafficDBManager.getFirstGGBH(clxh); dataMap.put("ggbh", ggbh); } pw.print(JSONObject.fromObject(dataMap)); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.magicpwd.v.app.MenuPtn.java
License:Open Source License
public boolean getToolBar(String toolId, javax.swing.JToolBar toolBar, javax.swing.JComponent component, AppView viewPtn) {//from w w w .ja va2 s .c o m if (!Char.isValidate(toolId) || document == null) { return false; } Node node = document.getRootElement().selectSingleNode(Char.format("/magicpwd/toolbar[@id='{0}']", toolId)); if (node == null || !(node instanceof Element)) { return false; } Element element = (Element) node; java.util.List elementList = element.elements(); if (elementList == null || elementList.size() < 1) { return false; } toolBar.setName(toolId); Element tmp; for (Object obj : elementList) { if (!(obj instanceof Element)) { continue; } tmp = (Element) obj; if ("item".equals(tmp.getName())) { toolBar.add(createButton(tmp, component, viewPtn)); continue; } if ("seperator".equals(tmp.getName())) { toolBar.addSeparator(); continue; } } return true; }
From source file:com.magicpwd.v.app.MenuPtn.java
License:Open Source License
public boolean getPopMenu(String menuId, javax.swing.JPopupMenu menuPop) { if (!Char.isValidate(menuId) || document == null) { return false; }/*from w w w. ja va 2 s .c o m*/ Node node = document.getRootElement().selectSingleNode(Char.format("/magicpwd/popmenu[@id='{0}']", menuId)); if (node == null || !(node instanceof Element)) { return false; } Element element = (Element) node; java.util.List elementList = element.elements(); if (elementList == null || elementList.size() < 1) { return false; } menuPop.setName(menuId); Element tmp; for (Object obj : elementList) { if (!(obj instanceof Element)) { continue; } tmp = (Element) obj; if ("menu".equals(tmp.getName())) { menuPop.add(createMenu(tmp, null, null)); continue; } if ("item".equals(tmp.getName())) { menuPop.add(createItem(tmp, null, null)); continue; } if ("seperator".equals(tmp.getName())) { menuPop.addSeparator(); continue; } } return true; }