Package org.tomlj

Class Toml


  • @DefaultQualifier(value=org.checkerframework.checker.nullness.qual.NonNull.class,
                      locations={RETURN,PARAMETER,FIELD})
    public final class Toml
    extends java.lang.Object
    Methods for parsing data stored in Tom's Obvious, Minimal Language (TOML).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.regex.Pattern simpleKeyPattern  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Toml()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String canonicalDottedKey​(java.lang.String dottedKey)
      Get the canonical form of the dotted key.
      static boolean equals​(TomlArray array1, TomlArray array2)
      Performs a deep comparison between two arrays to determine if they are equivalent.
      static boolean equals​(TomlTable table1, TomlTable table2)
      Performs a deep comparison between two tables to determine if they are equivalent.
      static java.lang.String joinKeyPath​(java.util.List<java.lang.String> path)
      Join a list of keys into a single dotted key string.
      static TomlParseResult parse​(java.io.InputStream is)
      Parse a TOML input stream.
      static TomlParseResult parse​(java.io.InputStream is, TomlVersion version)
      Parse a TOML input stream.
      static TomlParseResult parse​(java.io.Reader reader)
      Parse a TOML reader.
      static TomlParseResult parse​(java.io.Reader reader, TomlVersion version)
      Parse a TOML input stream.
      static TomlParseResult parse​(java.lang.String input)
      Parse a TOML string.
      static TomlParseResult parse​(java.lang.String input, TomlVersion version)
      Parse a TOML string.
      static TomlParseResult parse​(java.nio.channels.ReadableByteChannel channel)
      Parse a TOML reader.
      static TomlParseResult parse​(java.nio.channels.ReadableByteChannel channel, TomlVersion version)
      Parse a TOML input stream.
      static TomlParseResult parse​(java.nio.file.Path file)
      Parse a TOML file.
      static TomlParseResult parse​(java.nio.file.Path file, TomlVersion version)
      Parse a TOML file.
      static java.util.List<java.lang.String> parseDottedKey​(java.lang.String dottedKey)
      Parse a dotted key into individual parts.
      static java.lang.StringBuilder tomlEscape​(java.lang.String text)
      Escape a text string using the TOML escape sequences.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • simpleKeyPattern

        private static final java.util.regex.Pattern simpleKeyPattern
    • Constructor Detail

      • Toml

        private Toml()
    • Method Detail

      • parse

        public static TomlParseResult parse​(java.lang.String input)
        Parse a TOML string.
        Parameters:
        input - The input to parse.
        Returns:
        The parse result.
      • parse

        public static TomlParseResult parse​(java.lang.String input,
                                            TomlVersion version)
        Parse a TOML string.
        Parameters:
        input - The input to parse.
        version - The version level to parse at.
        Returns:
        The parse result.
      • parse

        public static TomlParseResult parse​(java.nio.file.Path file)
                                     throws java.io.IOException
        Parse a TOML file.
        Parameters:
        file - The input file to parse.
        Returns:
        The parse result.
        Throws:
        java.io.IOException - If an IO error occurs.
      • parse

        public static TomlParseResult parse​(java.nio.file.Path file,
                                            TomlVersion version)
                                     throws java.io.IOException
        Parse a TOML file.
        Parameters:
        file - The input file to parse.
        version - The version level to parse at.
        Returns:
        The parse result.
        Throws:
        java.io.IOException - If an IO error occurs.
      • parse

        public static TomlParseResult parse​(java.io.InputStream is)
                                     throws java.io.IOException
        Parse a TOML input stream.
        Parameters:
        is - The UTF-8 encoded input stream to read the TOML document from.
        Returns:
        The parse result.
        Throws:
        java.io.IOException - If an IO error occurs.
      • parse

        public static TomlParseResult parse​(java.io.InputStream is,
                                            TomlVersion version)
                                     throws java.io.IOException
        Parse a TOML input stream.
        Parameters:
        is - The UTF-8 encoded input stream to read the TOML document from.
        version - The version level to parse at.
        Returns:
        The parse result.
        Throws:
        java.io.IOException - If an IO error occurs.
      • parse

        public static TomlParseResult parse​(java.io.Reader reader)
                                     throws java.io.IOException
        Parse a TOML reader.
        Parameters:
        reader - The reader to obtain the TOML document from.
        Returns:
        The parse result.
        Throws:
        java.io.IOException - If an IO error occurs.
      • parse

        public static TomlParseResult parse​(java.io.Reader reader,
                                            TomlVersion version)
                                     throws java.io.IOException
        Parse a TOML input stream.
        Parameters:
        reader - The reader to obtain the TOML document from.
        version - The version level to parse at.
        Returns:
        The parse result.
        Throws:
        java.io.IOException - If an IO error occurs.
      • parse

        public static TomlParseResult parse​(java.nio.channels.ReadableByteChannel channel)
                                     throws java.io.IOException
        Parse a TOML reader.
        Parameters:
        channel - The channel to read the TOML document from.
        Returns:
        The parse result.
        Throws:
        java.io.IOException - If an IO error occurs.
      • parse

        public static TomlParseResult parse​(java.nio.channels.ReadableByteChannel channel,
                                            TomlVersion version)
                                     throws java.io.IOException
        Parse a TOML input stream.
        Parameters:
        channel - The UTF-8 encoded channel to read the TOML document from.
        version - The version level to parse at.
        Returns:
        The parse result.
        Throws:
        java.io.IOException - If an IO error occurs.
      • parseDottedKey

        public static java.util.List<java.lang.String> parseDottedKey​(java.lang.String dottedKey)
        Parse a dotted key into individual parts.
        Parameters:
        dottedKey - A dotted key (e.g. server.address.port).
        Returns:
        A list of individual keys in the path.
        Throws:
        java.lang.IllegalArgumentException - If the dotted key cannot be parsed.
      • joinKeyPath

        public static java.lang.String joinKeyPath​(java.util.List<java.lang.String> path)
        Join a list of keys into a single dotted key string.
        Parameters:
        path - The list of keys that form the path.
        Returns:
        The path string.
      • canonicalDottedKey

        public static java.lang.String canonicalDottedKey​(java.lang.String dottedKey)
        Get the canonical form of the dotted key.
        Parameters:
        dottedKey - A dotted key (e.g. server.address.port).
        Returns:
        The canonical form of the dotted key.
        Throws:
        java.lang.IllegalArgumentException - If the dotted key cannot be parsed.
      • tomlEscape

        public static java.lang.StringBuilder tomlEscape​(java.lang.String text)
        Escape a text string using the TOML escape sequences.
        Parameters:
        text - The text string to escape.
        Returns:
        A StringBuilder holding the results of escaping the text.
      • equals

        public static boolean equals​(TomlArray array1,
                                     TomlArray array2)
        Performs a deep comparison between two arrays to determine if they are equivalent.
        Parameters:
        array1 - First array
        array2 - Second array
        Returns:
        Returns true if the arrays are equivalent, else false.
      • equals

        public static boolean equals​(TomlTable table1,
                                     TomlTable table2)
        Performs a deep comparison between two tables to determine if they are equivalent.
        Parameters:
        table1 - First table
        table2 - Second table
        Returns:
        Returns true if the tables are equivalent, else false.