Interface PropertiesParser

  • All Known Implementing Classes:
    DefaultPropertiesParser

    public interface PropertiesParser
    Parses a .properties source (string, file, stream, etc) and returns a Map<String,String> that reflects the parsed properties.

    This implementation differs from default Java property loading behavior in that the returned Map's iteration order is guaranteed to be the same as the order in which the properties are read. This can be beneficial if it is desired to assign meaning to property definition order.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.Map<java.lang.String,​java.lang.String> parse​(Resource resource)
      Parses the specified .properties resource and returns a map of the parsed properties or an empty map if no properties were found.
      java.util.Map<java.lang.String,​java.lang.String> parse​(java.lang.String source)
      Parses the specified .properties-formatted String and returns a map of the parsed properties or an empty map if no properties were found.
      java.util.Map<java.lang.String,​java.lang.String> parse​(java.util.Scanner source)
      Parses the scanned content according to .properties formatting rules and returns a map of the parsed properties or an empty map if no properties were found.
    • Method Detail

      • parse

        java.util.Map<java.lang.String,​java.lang.String> parse​(java.lang.String source)
        Parses the specified .properties-formatted String and returns a map of the parsed properties or an empty map if no properties were found.
        Parameters:
        source - the String to parse
        Returns:
        a map of the parsed properties or an empty map if no properties were found.
      • parse

        java.util.Map<java.lang.String,​java.lang.String> parse​(Resource resource)
                                                              throws java.io.IOException
        Parses the specified .properties resource and returns a map of the parsed properties or an empty map if no properties were found.
        Parameters:
        resource - the resource to parse.
        Returns:
        a map of the parsed properties or an empty map if no properties were found.
        Throws:
        java.io.IOException - if unable to obtain the resource's inputStream.
      • parse

        java.util.Map<java.lang.String,​java.lang.String> parse​(java.util.Scanner source)
        Parses the scanned content according to .properties formatting rules and returns a map of the parsed properties or an empty map if no properties were found.
        Parameters:
        source - the Scanner to use to parse the content
        Returns:
        a map of the parsed properties or an empty map if no properties were found.