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

    Modifier and Type
    Method
    Description
    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.
    parse(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.
    parse(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 Details

    • parse

      Map<String,String> parse(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

      Map<String,String> parse(Resource resource) throws 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:
      IOException - if unable to obtain the resource's inputStream.
    • parse

      Map<String,String> parse(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.