Class ParameterString

java.lang.Object
org.tentackle.common.ParameterString
All Implemented Interfaces:
Serializable

public class ParameterString extends Object implements Serializable
A string of parameters.

Holds parameters of the form:

 name1='value1', name2='value2', ...
 
Where name must be a valid name according to the Java convention for variables. The values are any kind of strings enclosed in single quotes. If the value contains a single quote, it is encoded as two consecutive single quotes. The parameters are separated by a comma. The empty string is encoded as nameX instead of nameX='' as a convenience to denote just the presence of a name (e.g. for booleans).
Author:
harald
See Also:
  • Constructor Details

    • ParameterString

      public ParameterString()
      Creates an empty parameter string.
    • ParameterString

      public ParameterString(String parameterString) throws ParseException
      Creates a parameter string from its string representation.
      Parameters:
      parameterString - the parameter string
      Throws:
      ParseException - if parsing the string failed
  • Method Details

    • setParameter

      public String setParameter(String name, String value)
      Sets a parameter.
      Parameters:
      name - the name of the parameter
      value - the value, null to remove
      Returns:
      the old value if replaced, null if new
    • getParameter

      public String getParameter(String name)
      Gets the value of a parameter.
      Parameters:
      name - the parameter name
      Returns:
      the value, null if no such parameter
    • getParameterNames

      public String[] getParameterNames()
      Gets the parameter names.
      Returns:
      the parameter names
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toProperties

      public Properties toProperties()
      Converts a parameter string to a property list.
      Returns:
      the property list
    • parse

      public void parse(String parameterString) throws ParseException
      Parses the external string representation.
      Parameters:
      parameterString - the parameter string
      Throws:
      ParseException - if parsing the string failed