Java Code Examples for com.fasterxml.jackson.dataformat.yaml.YAMLMapper#createObjectNode()

The following examples show how to use com.fasterxml.jackson.dataformat.yaml.YAMLMapper#createObjectNode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuestPackage.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
public void printEventsYaml(OutputStream out) throws IOException {
	YAMLFactory yf = new YAMLFactory();
	YAMLMapper mapper = new YAMLMapper();
	ObjectNode root = mapper.createObjectNode();
	for (Event event : events) {
		root.put(event.getId().get(), event.getInstruction().get());
	}
	yf.createGenerator(out).setCodec(mapper).writeObject(root);
}
 
Example 2
Source File: QuestPackage.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
public void printConditionsYaml(OutputStream out) throws IOException {
	YAMLFactory yf = new YAMLFactory();
	YAMLMapper mapper = new YAMLMapper();
	ObjectNode root = mapper.createObjectNode();
	for (Condition condition : conditions) {
		root.put(condition.getId().get(), condition.getInstruction().get());
	}
	yf.createGenerator(out).setCodec(mapper).writeObject(root);
}
 
Example 3
Source File: QuestPackage.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
public void printObjectivesYaml(OutputStream out) throws IOException {
	YAMLFactory yf = new YAMLFactory();
	YAMLMapper mapper = new YAMLMapper();
	ObjectNode root = mapper.createObjectNode();
	for (Objective objective : objectives) {
		root.put(objective.getId().get(), objective.getInstruction().get());
	}
	yf.createGenerator(out).setCodec(mapper).writeObject(root);
}
 
Example 4
Source File: QuestPackage.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
public void printItemsYaml(OutputStream out) throws IOException {
	YAMLFactory yf = new YAMLFactory();
	YAMLMapper mapper = new YAMLMapper();
	ObjectNode root = mapper.createObjectNode();
	for (Item item : items) {
		root.put(item.getId().get(), item.getInstruction().get());
	}
	yf.createGenerator(out).setCodec(mapper).writeObject(root);
}
 
Example 5
Source File: QuestPackage.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
public void printJournalYaml(OutputStream out) throws IOException {
	YAMLFactory yf = new YAMLFactory();
	YAMLMapper mapper = new YAMLMapper();
	ObjectNode root = mapper.createObjectNode();
	for (JournalEntry entry : journal) {
		addTranslatedNode(mapper, root, entry.getId().get(), entry.getText());
	}
	yf.createGenerator(out).setCodec(mapper).writeObject(root);
}
 
Example 6
Source File: QuestPackage.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
private void addTranslatedNode(YAMLMapper mapper, ObjectNode root, String name, TranslatableText text) {
	if (!text.hasMultipleLanguages()) {
		root.put(name, text.getDef().get());
	} else {
		ObjectNode node = mapper.createObjectNode();
		for (String lang : text.getLanguages()) {
			if (lang == null) {
				continue;
			}
			node.put(lang, text.getLang(lang).get());
		}
		root.set(name, node);
	}
}