当前位置: 首页>>代码示例>>Java>>正文


Java XMLConfiguration.save方法代码示例

本文整理汇总了Java中org.apache.commons.configuration.XMLConfiguration.save方法的典型用法代码示例。如果您正苦于以下问题:Java XMLConfiguration.save方法的具体用法?Java XMLConfiguration.save怎么用?Java XMLConfiguration.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.configuration.XMLConfiguration的用法示例。


在下文中一共展示了XMLConfiguration.save方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveIntermediateGMLFile

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
public void saveIntermediateGMLFile() throws IOException{ 
	XMLConfiguration configuration = getConfiguration();
	configuration.setRootElementName("gml");
	List<Path> instancePathCollection;
	for(int partitionId : _partitionedTemplates.keySet()){
		configuration.addProperty("partition(-1)[@id]", partitionId);
		configuration.addProperty("partition.template", _partitionedTemplates.get(partitionId).toFile().getAbsolutePath());

		instancePathCollection = _partitionedInstances.get(partitionId);
		for(Path instancePath : instancePathCollection){
			configuration.addProperty("partition.instances.instance(-1)", instancePath.toFile().getAbsolutePath());
		}
	}

	try {
		File partitionedGMLFileDir = _workingDirPath.resolve(_intermediateGMLInputFile).toFile();
		configuration.save(partitionedGMLFileDir);
		System.out.println("saving the partitioned gml information to " + partitionedGMLFileDir.getAbsolutePath());
	} catch (ConfigurationException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:dream-lab,项目名称:goffish_v2,代码行数:23,代码来源:GMLPartitionBuilder.java

示例2: testAdapterXmlConfigWithDefaultDelimiter

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
@Test
public void testAdapterXmlConfigWithDefaultDelimiter() throws Exception {
    final Settings4jRepository testSettings = createSimpleSettings4jConfig();

    // start test => create adapter and add to Settings4jRepository
    final XMLConfiguration configuration = addXmlConfiguration(//
        testSettings, "myXmlConfigConnector", "xmlConfigWithDefaultDelimiter.xml", "/");

    // configure some values
    configuration.setProperty(TEST_VALUE_KEY, "Hello Windows World");
    configuration.save();

    // validate result
    assertThat(testSettings.getSettings().getString(TEST_VALUE_KEY), is("Hello Windows World"));
    assertThat(testSettings.getSettings().getString("unknown/Value"), is(nullValue()));

}
 
开发者ID:brabenetz,项目名称:settings4j,代码行数:18,代码来源:ConfigurationToConnectorAdapterTest.java

示例3: writeBenchmarkConf

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
public void writeBenchmarkConf(PrintStream os) throws ConfigurationException {
    XMLConfiguration outputConf = (XMLConfiguration) expConf.clone();
    for (String key: IGNORE_CONF) {
        outputConf.clearProperty(key);
    }
    outputConf.save(os);
}
 
开发者ID:faclc4,项目名称:HTAPBench,代码行数:8,代码来源:ResultUploader.java

示例4: getString

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
/**
 * Return the string representation of the XMLConfig without header
 * and configuration element.
 *
 * @param cfg the XML to convert
 * @return the cfg string.
 */
public String getString(XMLConfiguration cfg) {
    StringWriter stringWriter = new StringWriter();
    try {
        cfg.save(stringWriter);
    } catch (ConfigurationException e) {
        log.error("Cannot convert configuration", e.getMessage());
    }
    String xml = stringWriter.toString();
    xml = xml.substring(xml.indexOf("\n"));
    xml = xml.substring(xml.indexOf(">") + 1);
    return xml;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:YangXmlUtils.java

示例5: createControllersConfig

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
public static String createControllersConfig(HierarchicalConfiguration cfg,
                                             HierarchicalConfiguration actualCfg,
                                             String target, String netconfOperation,
                                             String controllerOperation,
                                             List<ControllerInfo> controllers) {
    //cfg.getKeys().forEachRemaining(key -> System.out.println(key));
    cfg.setProperty("edit-config.target", target);
    cfg.setProperty("edit-config.default-operation", netconfOperation);
    cfg.setProperty("edit-config.config.capable-switch.id",
                    parseCapableSwitchId(actualCfg));
    cfg.setProperty("edit-config.config.capable-switch." +
                            "logical-switches.switch.id", parseSwitchId(actualCfg));
    List<ConfigurationNode> newControllers = new ArrayList<>();
    for (ControllerInfo ci : controllers) {
        XMLConfiguration controller = new XMLConfiguration();
        controller.setRoot(new HierarchicalConfiguration.Node("controller"));
        String id = ci.type() + ":" + ci.ip() + ":" + ci.port();
        controller.setProperty("id", id);
        controller.setProperty("ip-address", ci.ip());
        controller.setProperty("port", ci.port());
        controller.setProperty("protocol", ci.type());
        newControllers.add(controller.getRootNode());
    }
    cfg.addNodes("edit-config.config.capable-switch.logical-switches." +
                         "switch.controllers", newControllers);
    XMLConfiguration editcfg = (XMLConfiguration) cfg;
    StringWriter stringWriter = new StringWriter();
    try {
        editcfg.save(stringWriter);
    } catch (ConfigurationException e) {
        log.error("createControllersConfig()", e);
    }
    String s = stringWriter.toString()
            .replaceAll("<controller>",
                        "<controller nc:operation=\"" + controllerOperation + "\">");
    s = s.replace("<target>" + target + "</target>",
                  "<target><" + target + "/></target>");
    return s;

}
 
开发者ID:shlee89,项目名称:athena,代码行数:41,代码来源:XmlConfigParser.java

示例6: exportToFile

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
private void exportToFile(File file, List<ColumnLayout> columnLayouts) throws ConfigurationException, FileNotFoundException {
  FileOutputStream out = null;
  try {
    final XMLConfiguration xmlConfiguration = new XMLConfiguration();
    saveColumnLayouts(columnLayouts, xmlConfiguration);
    out = new FileOutputStream(file);
    xmlConfiguration.save(out);
    otrosApplication.getStatusObserver().updateStatus(String.format("Column layouts have been exported to %s", file.getAbsolutePath()));
  } finally {
    IOUtils.closeQuietly(out);
  }
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:13,代码来源:LogTableFormatConfigView.java

示例7: exportToClipBoard

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
private void exportToClipBoard(List<ColumnLayout> columnLayouts) throws ConfigurationException {
  final XMLConfiguration xmlConfiguration = new XMLConfiguration();
  saveColumnLayouts(columnLayouts, xmlConfiguration);
  final StringWriter writer = new StringWriter();
  xmlConfiguration.save(writer);
  StringSelection stringSelection = new StringSelection(writer.getBuffer().toString());
  Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
  clipboard.setContents(stringSelection, null);
  otrosApplication.getStatusObserver().updateStatus("Column layouts have been exported to clipboard");
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:11,代码来源:LogTableFormatConfigView.java

示例8: createClientConfig

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
private void createClientConfig(StartFloeInfo info, String managerHost, String coordinatorHost)
        throws IOException, ConfigurationException {

    XMLConfiguration config = new XMLConfiguration();
    config.setRootElementName("GopherConfiguration");

    config.setProperty(FLOE_MANAGER, managerHost + ":" + MANAGER_PORT);
    config.setProperty(FLOE_COORDINATOR, coordinatorHost + ":" + COORDINATOR_PORT);

    info.getSourceInfo().sourceNodeTransport.values();

    for (List<TransportInfoBase> b : info.getSourceInfo().sourceNodeTransport.values()) {
        for (TransportInfoBase base : b) {
            String host = base.getParams().get("hostAddress");
            int dataPort = Integer.parseInt(base.getParams().get("tcpListenerPort"));

            int controlPort = Integer.parseInt(base.getControlChannelInfo().getParams().
                    get("tcpListenerPort"));

            config.setProperty(DATA_FLOW_HOST, host);
            config.setProperty(DATA_FLOW_DATA_PORT, dataPort);
            config.setProperty(DATA_FLOW_CONTROL_PORT, controlPort);
            break;
        }
        break;
    }

    config.save(new FileWriter(CONFIG_FILE_PATH));

}
 
开发者ID:dream-lab,项目名称:goffish_v2,代码行数:31,代码来源:DeploymentTool.java

示例9: configureJob

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
/**
 * <p>
 * Configure the execution of the algorithm.
 * 
 * @param jobFilename Name of the KEEL file with properties of the execution
 *  </p>                  
 */

private static void configureJob(String jobFilename) {

	Properties props = new Properties();

	try {
		InputStream paramsFile = new FileInputStream(jobFilename);
		props.load(paramsFile);
		paramsFile.close();			
	}
	catch (IOException ioe) {
		ioe.printStackTrace();
		System.exit(0);
	}
	
	// Files training and test
	String trainFile;
	String testFile;
	StringTokenizer tokenizer = new StringTokenizer(props.getProperty("inputData"));
	tokenizer.nextToken();
	trainFile = tokenizer.nextToken();
	trainFile = trainFile.substring(1, trainFile.length()-1);
	testFile = tokenizer.nextToken();
	testFile = testFile.substring(1, testFile.length()-1);
	
	tokenizer = new StringTokenizer(props.getProperty("outputData"));
	String reportTrainFile = tokenizer.nextToken();
	reportTrainFile = reportTrainFile.substring(1, reportTrainFile.length()-1);
	String reportTestFile = tokenizer.nextToken();
	reportTestFile = reportTestFile.substring(1, reportTestFile.length()-1);	
	String reportRulesFile = tokenizer.nextToken();
	reportRulesFile = reportRulesFile.substring(1, reportRulesFile.length()-1);				
	
	// Algorithm auxiliar configuration
	XMLConfiguration algConf = new XMLConfiguration();
	algConf.setRootElementName("experiment");
	algConf.addProperty("process[@algorithm-type]", "net.sourceforge.jclec.problem.classification.freitas.FreitasAlgorithm");
	algConf.addProperty("process.rand-gen-factory[@type]", "net.sourceforge.jclec.util.random.RanecuFactory");
	algConf.addProperty("process.rand-gen-factory[@seed]", Integer.parseInt(props.getProperty("seed")));
	algConf.addProperty("process.population-size", Integer.parseInt(props.getProperty("population-size")));
	algConf.addProperty("process.max-of-generations", Integer.parseInt(props.getProperty("max-generations")));
	algConf.addProperty("process.max-deriv-size", Integer.parseInt(props.getProperty("max-deriv-size")));
	algConf.addProperty("process.dataset[@type]", "net.sourceforge.jclec.util.dataset.KeelDataSet");
	algConf.addProperty("process.dataset.train-data.file-name", trainFile);
	algConf.addProperty("process.dataset.test-data.file-name", testFile);
	algConf.addProperty("process.species[@type]", "net.sourceforge.jclec.problem.classification.freitas.FreitasSyntaxTreeSpecies");
	algConf.addProperty("process.evaluator[@type]", "net.sourceforge.jclec.problem.classification.freitas.FreitasEvaluator");
	algConf.addProperty("process.provider[@type]", "net.sourceforge.jclec.syntaxtree.SyntaxTreeCreator");
	algConf.addProperty("process.parents-selector[@type]", "net.sourceforge.jclec.selector.RouletteSelector");
	algConf.addProperty("process.recombinator[@type]", "net.sourceforge.jclec.syntaxtree.SyntaxTreeRecombinator");
	algConf.addProperty("process.recombinator[@rec-prob]", Double.parseDouble(props.getProperty("rec-prob")));
	algConf.addProperty("process.recombinator.base-op[@type]", "net.sourceforge.jclec.problem.classification.freitas.FreitasCrossover");
	algConf.addProperty("process.copy-prob", Double.parseDouble(props.getProperty("copy-prob")));
	algConf.addProperty("process.listener[@type]", "net.sourceforge.jclec.problem.classification.freitas.KeelFreitasPopulationReport");
	algConf.addProperty("process.listener.report-dir-name", "./");
	algConf.addProperty("process.listener.train-report-file", reportTrainFile);
	algConf.addProperty("process.listener.test-report-file", reportTestFile);
	algConf.addProperty("process.listener.rules-report-file", reportRulesFile);
	algConf.addProperty("process.listener.global-report-name", "resumen");
	algConf.addProperty("process.listener.report-frequency", 50);

	try {
		algConf.save(new File("configure.txt"));
	} catch (ConfigurationException e) {
		e.printStackTrace();
	}

	net.sourceforge.jclec.RunExperiment.main(new String [] {"configure.txt"});
}
 
开发者ID:triguero,项目名称:Keel3.0,代码行数:77,代码来源:Main.java

示例10: readConfig

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
/**
     * Constructor pulls file out of the jar or reads from disk and sets up refresh policy.
     * 
     * @param expressionEngine
     *            the expression engine to use. Null results in default expression engine
     */
    protected void readConfig() {
        try {
            ExpressionEngine expressionEngine = new XPathExpressionEngine();
            String configPath = getConfigName();
            FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();

            File dataDirConfigFile = new File(configPath);
//            LOG.info("Reading settings from " + dataDirConfigFile.getAbsolutePath());
            if (!dataDirConfigFile.exists()) {
                // Load a default from the classpath:
                // Note: we don't let new XMLConfiguration() lookup the resource
                // url directly because it may not be able to find the desired
                // classloader to load the URL from.
                URL configResourceUrl = this.getClass().getClassLoader().getResource(configPath);
                if (configResourceUrl == null) {
                    throw new RuntimeException("unable to load resource: " + configPath);
                }

                XMLConfiguration tmpConfig = new XMLConfiguration(configResourceUrl);
                // Copy over a default configuration since none exists:
                // Ensure data dir location exists:
                if (dataDirConfigFile.getParentFile() != null && !dataDirConfigFile.getParentFile().exists()
                        && !dataDirConfigFile.getParentFile().mkdirs()) {
                    throw new RuntimeException("could not create directories.");
                }
                tmpConfig.save(dataDirConfigFile);
                LOG.info("Saving settings file to " + dataDirConfigFile.getAbsolutePath());
            }

            if (dataDirConfigFile.exists()) {
                config = new XMLConfiguration(dataDirConfigFile);
            } else {
                // extract from jar and write to
                throw new IllegalStateException("Config file does not exist or cannot be created");
            }
            if (expressionEngine != null) {
                config.setExpressionEngine(expressionEngine);
            }
            configFile = dataDirConfigFile;
            // reload at most once per thirty seconds on configuration queries.
            config.setReloadingStrategy(reloadingStrategy);
            initConfig(config);
        } catch (ConfigurationException e) {
            LOG.error("Error reading settings file: " + e, e);
            throw new RuntimeException(e);
        }
    }
 
开发者ID:intuit,项目名称:Tank,代码行数:54,代码来源:BaseCommonsXmlConfig.java

示例11: save

import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
public static boolean save(int port, boolean followRedirect, String outputFile,
        Set<ConfigInclusionExclusionRule> inclusions,
        Set<ConfigInclusionExclusionRule> exclusions,
        Set<ConfigInclusionExclusionRule> bodyInclusions,
        Set<ConfigInclusionExclusionRule> bodyExclusions,
        String fileName) {

    ConfigurationNode node = getConfNode("recording-proxy-config", "", false);
    ConfigurationNode portNode = getConfNode("proxy-port", String.valueOf(port), false);
    ConfigurationNode followRedirectNode = getConfNode("follow-redirects", Boolean.toString(followRedirect), false);
    ConfigurationNode outputFileNode = getConfNode("output-file", outputFile, false);
    ConfigurationNode inclusionsNode = getConfNode("inclusions", "", false);
    ConfigurationNode exclusionsNode = getConfNode("exclusions", "", false);
    ConfigurationNode bodyInclusionsNode = getConfNode("body-inclusions", "", false);
    ConfigurationNode bodyExclusionsNode = getConfNode("body-exclusions", "", false);

    updateRuleParentNode(inclusions, inclusionsNode);
    updateRuleParentNode(exclusions, exclusionsNode);
    updateRuleParentNode(bodyInclusions, bodyInclusionsNode);
    updateRuleParentNode(bodyExclusions, bodyExclusionsNode);

    node.addChild(portNode);
    node.addChild(followRedirectNode);
    node.addChild(outputFileNode);
    node.addChild(inclusionsNode);
    node.addChild(exclusionsNode);
    node.addChild(bodyInclusionsNode);
    node.addChild(bodyExclusionsNode);

    HierarchicalConfiguration hc = new HierarchicalConfiguration();
    hc.setRootNode(node);
    XMLConfiguration xmlConfiguration = new XMLConfiguration(hc);
    xmlConfiguration.setRootNode(node);

    try {

        xmlConfiguration.save(new File(fileName));
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
    return true;

}
 
开发者ID:intuit,项目名称:Tank,代码行数:44,代码来源:CommonsProxyConfiguration.java


注:本文中的org.apache.commons.configuration.XMLConfiguration.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。