List of usage examples for org.dom4j.io SAXReader SAXReader
public SAXReader()
From source file:ch.epfl.codimsd.qep.QEPFactory.java
License:Open Source License
/** * Reads a qep file in xml or string format, and build the hashtable of opNode structures * representing the operators./*from www.java 2 s . c o m*/ * * If this method is called remotly, the parameter "type" should be set to Constants.qepAccessTypeRemote; * in order to read from a string file. * * @param qepFile path to QEP file. * @param type type of access (remote mode or centralized mode). * @param qep this qep. It is send in order to be filled with corresponding hashtable. * @return hashtable containing opNode structures. * @throws QEPInitializationException */ public static Hashtable<String, OpNode> loadQEP(String qepFile, String type, QEP qep) throws QEPInitializationException { // Initializations. Hashtable<String, OpNode> operatorList = null; Document document = null; try { // Call Sax reader in order to parse the xml document. SAXReader reader = new SAXReader(); document = reader.read(qepFile); qep.setDocument(document); // Build the hashtable of opNodes. operatorList = buildOpNodeTable(document); } catch (DocumentException ex) { ex.printStackTrace(); throw new QEPInitializationException( "DocumentException error while loadind the XML QEP : " + ex.getMessage()); } return operatorList; }
From source file:ch.javasoft.metabolic.efm.config.DistributedConfig.java
License:BSD License
private static final Element getDistConfigFromPackage() throws XmlConfigException, IOException { final String xmlName = "config/metabolic-efm.xml"; InputStream xmlIn = DistributedConfig.class.getClassLoader().getResourceAsStream(xmlName); if (xmlIn == null) { throw new IOException("cannot find resource: " + xmlName); }//from w w w. j a va2 s . co m try { final SAXReader reader = new SAXReader(); final Document doc = reader.read(xmlIn); final Element root = doc.getRootElement(); final Element elDist = root.elementByID(XmlElement.distribute.getXmlName()); // final String defName = root.attributeValue("default", "default"); // final Element elConfig = XmlUtil.getChildElementByAttributeValue(root, ch.javasoft.xml.config.XmlConfig.XmlElement.config, XmlAttribute.name, defName, true /*throwExceptionIfNull*/); // final Element elMetEfm = XmlUtil.getRequiredSingleChildElement(elConfig, ch.javasoft.metabolic.efm.main.CalculateFluxModes.XmlElement.metabolic_efm); // final Element elImpl = XmlUtil.getRequiredSingleChildElement(elMetEfm, ch.javasoft.metabolic.efm.main.CalculateFluxModes.XmlElement.efm_impl); // final Element elImplCfg = XmlUtil.getRequiredSingleChildElement(elImpl, ch.javasoft.metabolic.efm.main.CalculateFluxModes.XmlElement.config); // final Element elDist = XmlUtil.getRequiredSingleChildElement(elImplCfg, XmlElement.distribute); return elDist; } catch (DocumentException e) { throw ExceptionUtil.toIOException("cannot parse " + xmlName + ", e=" + e, e); } finally { xmlIn.close(); } }
From source file:ch.javasoft.xml.config.XmlConfig.java
License:BSD License
public static XmlConfig getXmlConfig(String appName, File xmlFile) throws DocumentException { return getXmlConfig(appName, new SAXReader().read(xmlFile)); }
From source file:ch.javasoft.xml.config.XmlConfig.java
License:BSD License
public static XmlConfig getXmlConfig(String appName, Reader xmlFile) throws DocumentException { return getXmlConfig(appName, new SAXReader().read(xmlFile)); }
From source file:ch.javasoft.xml.config.XmlConfig.java
License:BSD License
public static XmlConfig getXmlConfig(String appName, InputStream xmlFile) throws DocumentException { return getXmlConfig(appName, new SAXReader().read(xmlFile)); }
From source file:ch.javasoft.xml.config.XmlConfig.java
License:BSD License
public static XmlConfig getXmlConfig(String appName, File xmlFile, String[] args) throws DocumentException { return new XmlConfig(appName, new SAXReader().read(xmlFile), args); }
From source file:ch.javasoft.xml.config.XmlConfig.java
License:BSD License
public static XmlConfig getXmlConfig(String appName, InputStream xmlFile, String[] args) throws DocumentException { return new XmlConfig(appName, new SAXReader().read(xmlFile), args); }
From source file:ch.javasoft.xml.config.XmlConfig.java
License:BSD License
/** * Parses the given document and returns an XmlConfig instance. Note that * this document is expected to contain an application element (direct child * of root element) with a name attribute and possible with arg child nodes. * Such a document is usually received by calling {@link #toXmlDocument()}. * /* w w w . j a v a 2s. c om*/ * @throws DocumentException if a dom4j xml exception occurs */ public static XmlConfig fromXmlDocument(File file) throws DocumentException { return fromXmlDocument(new SAXReader().read(file)); }
From source file:ch.javasoft.xml.config.XmlConfig.java
License:BSD License
/** * Parses the given document and returns an XmlConfig instance. Note that * this document is expected to contain an application element (direct child * of root element) with a name attribute and possible with arg child nodes. * Such a document is usually received by calling {@link #toXmlDocument()}. * @throws DocumentException if a dom4j xml exception occurs */// w w w .j av a 2 s.co m public static XmlConfig fromXmlDocument(Reader reader) throws DocumentException { return fromXmlDocument(new SAXReader().read(reader)); }
From source file:cinnamon.global.Conf.java
License:Open Source License
public Conf(String configName) { String separator = File.separator; File configFile = null;// w w w .j a v a2 s .c om try { String currentDir = new File(".").getAbsolutePath(); configPath = currentDir.substring(0, currentDir.length() - 1) + "webapps" + separator + "cinnamon" + separator + configName; configFile = new File(configPath); if (!configFile.exists()) { log.debug("Config file not found in " + configPath); log.debug("Will try in CINNAMON_HOME_DIR='" + System.getenv().get("CINNAMON_HOME_DIR") + "'"); } } catch (AccessControlException ace) { log.error("AccessControlException: " + ace.getLocalizedMessage(), ace); } finally { if (configFile == null || !configFile.exists()) { // try do instantiate the configuration via environment var: String path = System.getenv().get("CINNAMON_HOME_DIR"); setConfigPath(path + separator + configName); log.debug("ConfigPath: " + getConfigPath()); configFile = new File(getConfigPath()); } } log.debug("ConfigPath: " + configPath); SAXReader reader = new SAXReader(); try { File cfg = new File(configPath); xml = reader.read(cfg); configureUseSessionLogging(xml); } catch (Exception ex) { log.debug("", ex); emergencyLog("Failure loading config file: " + ex.getMessage()); throw new RuntimeException(ex); } }