Java Code Examples for org.yaml.snakeyaml.serializer.Serializer#close()
The following examples show how to use
org.yaml.snakeyaml.serializer.Serializer#close() .
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: VersionedYamlDoc.java From onedev with MIT License | 5 votes |
public String toYaml() { StringWriter writer = new StringWriter(); DumperOptions dumperOptions = new DumperOptions(); Serializer serializer = new Serializer(new Emitter(writer, dumperOptions), new Resolver(), dumperOptions, Tag.MAP); try { serializer.open(); serializer.serialize(this); serializer.close(); return writer.toString(); } catch (IOException e) { throw new RuntimeException(e); } }
Example 2
Source File: SoyDirectives.java From deploymentmanager-autogen with Apache License 2.0 | 5 votes |
@Override public SoyValue applyForJava(SoyValue value, List<SoyValue> args) { Preconditions.checkArgument( value instanceof PrimitiveData || value instanceof SanitizedContent, "|yamlprimitive directive only supports primitive types"); Node node; if (value instanceof BooleanData) { node = representer.represent(value.booleanValue()); } else if (value instanceof FloatData) { node = representer.represent(value.floatValue()); } else if (value instanceof IntegerData) { node = representer.represent(value.integerValue()); } else { node = representer.represent(value.coerceToString()); } int indent = args.get(0).integerValue(); StringWriter writer = new StringWriter(); Serializer serializer = new Serializer( new Emitter(writer, dumperOptions), resolver, dumperOptions, null); try { serializer.open(); serializer.serialize(node); serializer.close(); return StringData.forValue(indentLines(writer.toString().trim(), indent)); } catch (IOException e) { // Should not happen. throw new RuntimeException(e); } }
Example 3
Source File: ConfigurationAsCode.java From configuration-as-code-plugin with MIT License | 5 votes |
@VisibleForTesting @Restricted(NoExternalUse.class) public static void serializeYamlNode(Node root, Writer writer) throws IOException { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(BLOCK); options.setDefaultScalarStyle(PLAIN); options.setSplitLines(true); options.setPrettyFlow(true); Serializer serializer = new Serializer(new Emitter(writer, options), new Resolver(), options, null); serializer.open(); serializer.serialize(root); serializer.close(); }
Example 4
Source File: Yaml.java From orion.server with Eclipse Public License 1.0 | 5 votes |
private void dumpAll(Iterator<? extends Object> data, Writer output, Tag rootTag) { Serializer serializer = new Serializer(new Emitter(output, dumperOptions), resolver, dumperOptions, rootTag); try { serializer.open(); while (data.hasNext()) { Node node = representer.represent(data.next()); serializer.serialize(node); } serializer.close(); } catch (java.io.IOException e) { throw new YAMLException(e); } }
Example 5
Source File: Yaml.java From orion.server with Eclipse Public License 1.0 | 5 votes |
/** * Serialize the representation tree into Events. * * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a> * @param data * representation tree * @return Event list */ public List<Event> serialize(Node data) { SilentEmitter emitter = new SilentEmitter(); @SuppressWarnings("deprecation") Serializer serializer = new Serializer(emitter, resolver, dumperOptions, dumperOptions.getExplicitRoot()); try { serializer.open(); serializer.serialize(data); serializer.close(); } catch (java.io.IOException e) { throw new YAMLException(e); } return emitter.getEvents(); }
Example 6
Source File: Yaml.java From snake-yaml with Apache License 2.0 | 5 votes |
private void dumpAll(Iterator<? extends Object> data, Writer output, Tag rootTag) { Serializer serializer = new Serializer(new Emitter(output, dumperOptions), resolver, dumperOptions, rootTag); try { serializer.open(); while (data.hasNext()) { Node node = representer.represent(data.next()); serializer.serialize(node); } serializer.close(); } catch (IOException e) { throw new YAMLException(e); } }
Example 7
Source File: Yaml.java From snake-yaml with Apache License 2.0 | 5 votes |
/** * Serialize the representation tree into Events. * * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a> * @param data * representation tree * @return Event list */ public List<Event> serialize(Node data) { SilentEmitter emitter = new SilentEmitter(); Serializer serializer = new Serializer(emitter, resolver, dumperOptions, null); try { serializer.open(); serializer.serialize(data); serializer.close(); } catch (IOException e) { throw new YAMLException(e); } return emitter.getEvents(); }
Example 8
Source File: Yaml.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
private void dumpAll(Iterator<? extends Object> data, Writer output, Tag rootTag) { Serializer serializer = new Serializer(new Emitter(output, dumperOptions), resolver, dumperOptions, rootTag); try { serializer.open(); while (data.hasNext()) { Node node = representer.represent(data.next()); serializer.serialize(node); } serializer.close(); } catch (IOException e) { throw new YAMLException(e); } }
Example 9
Source File: Yaml.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
/** * Serialize the representation tree into Events. * * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a> * @param data * representation tree * @return Event list */ public List<Event> serialize(Node data) { SilentEmitter emitter = new SilentEmitter(); Serializer serializer = new Serializer(emitter, resolver, dumperOptions, null); try { serializer.open(); serializer.serialize(data); serializer.close(); } catch (IOException e) { throw new YAMLException(e); } return emitter.getEvents(); }