List of usage examples for org.dom4j Document clearContent
void clearContent();
Node
instances this branch may contain. From source file:com.ah.be.parameter.BeParaModuleDefImpl.java
public void insertDefaultCustomReportField() { try {/*from w w w . j av a 2s . c o m*/ long rowCount = QueryUtil.findRowCount(AhCustomReportField.class, null); if (rowCount > 0) { return; } List<AhCustomReportField> reportFields = new ArrayList<>(); SAXReader reader = new SAXReader(); String docName = AhDirTools.getHmRoot() + "resources" + File.separator + "customReport" + File.separator + "custom_report_table.xml"; Document doc = reader.read(new File(docName)); Element root = doc.getRootElement(); List<?> rootLst = root.elements(); for (Object obj : rootLst) { List<?> rowlst = ((Element) obj).elements(); AhCustomReportField reportField = new AhCustomReportField(); for (int j = 0; j < rowlst.size(); j++) { Element elm = (Element) rowlst.get(j); // String name = elm.attributeValue("name"); String value = elm.attributeValue("value"); if (j == 0) { reportField.setId(Long.parseLong(value)); } else if (j == 1) { reportField.setType(Integer.parseInt(value)); } else if (j == 2) { reportField.setDetailType(Integer.parseInt(value)); } else if (j == 3) { reportField.setTableName(value); } else if (j == 4) { reportField.setTableField(value); } else if (j == 5) { reportField.setFieldString(value); } else if (j == 6) { reportField.setStrUnit(value); } else if (j == 7) { reportField.setDescription(value); } } reportFields.add(reportField); } root.clearContent(); doc.clearContent(); QueryUtil.bulkCreateBos(reportFields); } catch (Exception e) { setDebugMessage("insert default custom report field: ", e); } }
From source file:com.beetle.framework.business.service.server.ServiceConfig.java
License:Apache License
private static void loadFromConfig(InputStream xmlFileInputStream) { SAXReader reader = new SAXReader(); Document doc = null; try {//from w w w .j a va2s. c om doc = reader.read(xmlFileInputStream); gendoc(doc); } catch (Exception de) { throw new AppRuntimeException(de); } finally { if (doc != null) { doc.clearContent(); doc = null; } reader = null; } }
From source file:com.beetle.framework.business.service.server.ServiceConfig.java
License:Apache License
private static void loadFromConfig(File f) { SAXReader reader = new SAXReader(); Document doc = null; try {/*from w w w . ja va 2 s . c o m*/ doc = reader.read(f); gendoc(doc); } catch (Exception de) { throw new AppRuntimeException(de); } finally { if (doc != null) { doc.clearContent(); doc = null; } reader = null; } }
From source file:com.beetle.framework.persistence.access.DBConfig.java
License:Apache License
public static List<String> getAllDatasourcename() { Document doc = null; try {// ww w. j a v a 2s .c om List<String> myList = new ArrayList<String>(); doc = XMLReader.getXmlDoc(AppProperties.getAppHome() + "DBConfig.xml"); Element root = doc.getRootElement(); for (Iterator<?> i = root.elementIterator("DataSources"); i.hasNext();) { Element e = (Element) i.next(); @SuppressWarnings("unchecked") Iterator<Node> n = e.nodeIterator(); while (n.hasNext()) { Node at = n.next(); if (at.getName() != null) { myList.add(at.getName()); } } } return myList; } catch (Exception e) { throw new AppRuntimeException(e); } finally { if (doc != null) { doc.clearContent(); } } }
From source file:com.beetle.framework.resource.dic.ReleBinder.java
License:Apache License
/** * ?//w ww .j av a2s . c o m * * @param xmlFileInputStream * --?? */ public void bindFromConfig(InputStream xmlFileInputStream) { SAXReader reader = new SAXReader(); Document doc = null; try { doc = reader.read(xmlFileInputStream); gendoc(doc); // bindProperties(); } catch (Exception de) { throw new AppRuntimeException(de); } finally { if (doc != null) { doc.clearContent(); doc = null; } reader = null; } }
From source file:com.beetle.framework.resource.dic.ReleBinder.java
License:Apache License
/** * ? XML?<br>/* ww w . j a v a 2 s. co m*/ * * <pre> * <binder> * <!-- * interface-????? * implement-??????interface * singleton-??implement?true * --> * <item interface= "com.beetle.framework.util.pattern.di.IService" implement= "com.beetle.framework.util.pattern.di.IServiceImp" singleton="true"/> * </binder> * </pre> * * <br> * * @param f * --? */ public void bindFromConfig(File f) { SAXReader reader = new SAXReader(); Document doc = null; try { doc = reader.read(f); gendoc(doc); // bindProperties(); } catch (Exception de) { throw new AppRuntimeException(de); } finally { if (doc != null) { doc.clearContent(); doc = null; } reader = null; } }
From source file:com.beetle.framework.util.file.XMLReader.java
License:Apache License
/** * /* w w w . j a va 2s .com*/ * @param xmlFileInputStream * @param itemPath * @param ElementName * @param keyName * @param valueName * @return */ public static Map<String, String> getProperties(InputStream xmlFileInputStream, String itemPath, String ElementName, String keyName, String valueName) { Map<String, String> map = new HashMap<String, String>(); if (xmlFileInputStream == null) { // System.out.println("WARN:the resource do not exist"); return map; } SAXReader reader = new SAXReader(); Document doc = null; try { doc = reader.read(xmlFileInputStream); // Document doc = reader.read(new File(xmlFileName)); Node node = doc.selectSingleNode(convertPath(itemPath)); if (node != null) { Iterator<?> it = node.selectNodes(ElementName).iterator(); while (it.hasNext()) { Element e = (Element) it.next(); map.put(e.valueOf("@" + keyName), e.valueOf("@" + valueName)); } } else { // throw new com.beetle.framework.AppRuntimeException( // "?????!"); // System.out.println("WARN:Can't find the paht[" + itemPath // + "],please check it!"); // throw new RuntimeException("{" + itemPath + // "}does not exist"); } } catch (Exception e) { e.printStackTrace(); } finally { if (doc != null) { doc.clearContent(); } reader = null; } // xmlFileInputStream.close(); return map; }
From source file:com.beetle.framework.util.file.XMLReader.java
License:Apache License
public static Map<String, String> getProperties(String xmlFileName, String itemPath, String ElementName, String keyName, String valueName) { Map<String, String> map = new HashMap<String, String>(); SAXReader reader = new SAXReader(); Document doc = null; try {/*w w w . j a v a2 s . c om*/ // // InputStream // in=ClassLoader.getSystemResourceAsStream(xmlFileName); // Document doc=reader.read(in); // doc = reader.read(new File(xmlFileName)); Node node = doc.selectSingleNode(convertPath(itemPath)); if (node != null) { Iterator<?> it = node.selectNodes(ElementName).iterator(); while (it.hasNext()) { Element e = (Element) it.next(); map.put(e.valueOf("@" + keyName), e.valueOf("@" + valueName)); } } else { // throw new com.beetle.framework.AppRuntimeException( // "?????!"); System.out.println("WARN:Can't find the paht[" + itemPath + "],please check it!"); } } catch (Exception e) { e.printStackTrace(); } finally { if (doc != null) { doc.clearContent(); } reader = null; } return map; }
From source file:com.beetle.framework.util.file.XMLReader.java
License:Apache License
public static String getTagContent(String xmlFileName, String TagPath) { String a = ""; SAXReader reader = new SAXReader(); Document doc = null; try {/*www . jav a 2s.c o m*/ doc = reader.read(new File(xmlFileName)); Node node = doc.selectSingleNode(convertPath(TagPath)); if (node != null) { a = node.getText(); } } catch (Exception e) { e.printStackTrace(); } finally { if (doc != null) { doc.clearContent(); } reader = null; } return a; }
From source file:com.beetle.framework.util.file.XMLReader.java
License:Apache License
/** * ???????/*from w ww. j a v a 2 s . c o m*/ * * * @param xmlFileInputStream * @param TagPath * @return */ public static String getTagContent(InputStream xmlFileInputStream, String TagPath) { String a = ""; if (xmlFileInputStream == null) { // System.out.println("WARN:the resource do not exist"); return a; } SAXReader reader = new SAXReader(); Document doc = null; try { doc = reader.read(xmlFileInputStream); Node node = doc.selectSingleNode(convertPath(TagPath)); if (node != null) { a = node.getText(); } } catch (Exception e) { e.printStackTrace(); } finally { if (doc != null) { doc.clearContent(); } reader = null; } return a; }