use of com.esotericsoftware.yamlbeans.YamlWriter in project audit4j-core by audit4j.
the class YAMLConfigProvider method generateConfig.
/**
* {@inheritDoc}
*/
@Override
public void generateConfig(T config, String filePath) throws ConfigurationException {
YamlWriter writer;
try {
writer = new YamlWriter(new FileWriter(filePath));
writer.getConfig().setClassTag(clazz.getSimpleName(), clazz);
writer.write(Configuration.DEFAULT);
writer.close();
} catch (IOException e) {
throw new ConfigurationException("Configuration Exception", "CONF_002");
}
}
use of com.esotericsoftware.yamlbeans.YamlWriter in project audit4j-core by audit4j.
the class URLConfigurationIntTest method before.
@Before
public void before() {
configFileLocation = System.getProperty("user.home") + "/audit4j.conf.yml";
System.out.println(configFileLocation);
YamlWriter writer;
try {
writer = new YamlWriter(new FileWriter(configFileLocation));
writer.getConfig().setClassTag("Configuration", Configuration.class);
writer.write(Configuration.DEFAULT);
writer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.esotericsoftware.yamlbeans.YamlWriter in project ASCIIGenome by dariober.
the class ASCIIGenomeHistory method write.
public void write(File outYaml) throws IOException {
Map<String, Object> asciigenome_history = new HashMap<String, Object>();
// List of commands
List<String> lastCommands = new ArrayList<String>();
int max_cmds = MAX_CMDS;
for (String cmd : this.getCommands()) {
if (max_cmds == 0) {
break;
}
max_cmds--;
lastCommands.add(cmd.trim());
}
asciigenome_history.put("commands", lastCommands);
// List of files
List<String> lastFiles = this.getFiles();
lastFiles = lastFiles.subList(Math.max(0, lastFiles.size() - MAX_FILES), lastFiles.size());
// Convert ArrayList#subList to List so the yaml file does show an odd data type.
asciigenome_history.put("files", new ArrayList<String>(lastFiles));
// Positions
List<String> lastPos = this.getPositions();
asciigenome_history.put("positions", lastPos);
// Reference
List<String> ref = this.getReference();
if (ref != null && ref.size() > 0 && ref.get(0) != null && !ref.get(0).trim().isEmpty()) {
asciigenome_history.put("reference", new ArrayList<String>(ref));
}
// Write yaml
YamlWriter writer = new YamlWriter(new FileWriter(outYaml));
writer.write(asciigenome_history);
writer.close();
}
Aggregations