Class Yaml


  • public final class Yaml
    extends Object
    Yaml.
    Since:
    1.0.0
    Version:
    $Id: 05fe6d17c950270bc5ca401185a9d818c4977f77 $
    Author:
    Mihai Andronache (amihaiemil@gmail.com)
    • Method Detail

      • createYamlInput

        public static YamlInput createYamlInput​(File input,
                                                boolean guessIndentation)
                                         throws FileNotFoundException
        Create a YamlInput from a File.
        Parameters:
        input - File to read from.
        guessIndentation - If set to true, we will try to guess the correct indentation of misplaced lines. The default value is false and an exception is thrown if indentation is not correct.
        Returns:
        YamlInput, reader of Yaml.
        Throws:
        FileNotFoundException - If the file is not found.
      • createYamlInput

        public static YamlInput createYamlInput​(String input)
        Create a YamlInput from a String.
        Parameters:
        input - String to read from.
        Returns:
        YamlInput, reader of Yaml.
      • createYamlInput

        public static YamlInput createYamlInput​(String input,
                                                boolean guessIndentation)
        Create a YamlInput from a String.
        Parameters:
        input - String to read from.
        guessIndentation - If set to true, we will try to guess the correct indentation of misplaced lines. The default value is false and an exception is thrown if indentation is not correct.
        Returns:
        YamlInput, reader of Yaml.
      • createYamlInput

        public static YamlInput createYamlInput​(InputStream input)
        Create a YamlInput from an InputStream.
        Parameters:
        input - InputStream to read from.
        Returns:
        YamlInput, reader of Yaml.
      • createYamlInput

        public static YamlInput createYamlInput​(InputStream input,
                                                boolean guessIndentation)
        Create a YamlInput from an InputStream.
        Parameters:
        input - InputStream to read from.
        guessIndentation - If set to true, we will try to guess the correct indentation of misplaced lines. The default value is false and an exception is thrown if indentation is not correct.
        Returns:
        YamlInput, reader of Yaml.
      • createYamlPrinter

        public static YamlPrinter createYamlPrinter​(Writer destination)
        Create a YamlPrinter to write a YamlNode somewhere. If you want to print a YamlNode to String, just use YamlNode.toString() -- it is a convenience equivalent to:
           final YamlNode yaml = ...;
           final StringWriter stgWriter = new StringWriter();
           Yaml.createYamlPrinter(stgWriter).print(yaml);
           System.out.println(stgWriter.toString());
         
        Parameters:
        destination - Writer where the YamlNode will be printed.
        Returns:
        YamlPrinter.
      • createYamlDump

        public static YamlDump createYamlDump​(Object object)
        Create a YAML dump to represent the given object as YAML.
        Parameters:
        object - Object to dump.
        Returns:
        YamlDump.
      • fromJsonObject

        public static YamlMapping fromJsonObject​(javax.json.JsonObject object)
        Create a YAML mapping from a JsonObject.
        Parameters:
        object - JsonObject in question.
        Returns:
        YamlMapping.
      • fromJsonArray

        public static YamlSequence fromJsonArray​(javax.json.JsonArray array)
        Create a YAML sequence from a JsonArray.
        Parameters:
        array - JsonArray in question.
        Returns:
        YamlSequence.