Class ParameterParser


  • @NotThreadSafe
    public class ParameterParser
    extends Object
    A simple parser intended to parse sequences of name/value pairs. Parameter values are expected to be enclosed in quotes if they contain unsafe characters, such as '=' characters or separators. Parameter values are optional and can be omitted.

    param1 = value; param2 = "anything goes; really"; param3

    Author:
    Oleg Kalnichevski
    • Constructor Detail

      • ParameterParser

        public ParameterParser()
        Default ParameterParser constructor.
    • Method Detail

      • isLowerCaseNames

        public boolean isLowerCaseNames()
        Returns true if parameter names are to be converted to lower case when name/value pairs are parsed.
        Returns:
        true if parameter names are to be converted to lower case when name/value pairs are parsed. Otherwise returns false
      • setLowerCaseNames

        @Nonnull
        public ParameterParser setLowerCaseNames​(boolean bLowerCaseNames)
        Sets the flag if parameter names are to be converted to lower case when name/value pairs are parsed.
        Parameters:
        bLowerCaseNames - true if parameter names are to be converted to lower case when name/value pairs are parsed. false otherwise.
        Returns:
        this
      • parse

        @Nonnull
        @ReturnsMutableCopy
        public com.helger.commons.collection.impl.ICommonsMap<String,​String> parse​(@Nullable
                                                                                         String sStr,
                                                                                         @Nullable
                                                                                         char[] aSeparators)
        Extracts a map of name/value pairs from the given string. Names are expected to be unique. Multiple separators may be specified and the earliest found in the input string is used.
        Parameters:
        sStr - the string that contains a sequence of name/value pairs
        aSeparators - the name/value pairs separators
        Returns:
        a map of name/value pairs
      • parse

        @Nonnull
        @ReturnsMutableCopy
        public com.helger.commons.collection.impl.ICommonsMap<String,​String> parse​(@Nullable
                                                                                         String sStr,
                                                                                         char cSeparator)
        Extracts a map of name/value pairs from the given string. Names are expected to be unique.
        Parameters:
        sStr - the string that contains a sequence of name/value pairs
        cSeparator - the name/value pairs separator
        Returns:
        a map of name/value pairs