當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLConfiguration.addProperty方法代碼示例

本文整理匯總了Java中org.apache.commons.configuration.XMLConfiguration.addProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLConfiguration.addProperty方法的具體用法?Java XMLConfiguration.addProperty怎麽用?Java XMLConfiguration.addProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.configuration.XMLConfiguration的用法示例。


在下文中一共展示了XMLConfiguration.addProperty方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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


注:本文中的org.apache.commons.configuration.XMLConfiguration.addProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。