net.sf.okapi.common

## Class ParametersString

- java.lang.Object
- - net.sf.okapi.common.ParametersString

-     public class ParametersString
      extends java.lang.Object

  String-based representation of a set of parameters.
  - The string or file should start with "#v1\n"
  - Each parameter is saved in a format: key=value
  - Keys and values are case-sensitive.
  - Keys should not contain periods (.) as this character is reserved for group handling.
  - The character \r should be escaped as $0d$
  - The character \n should be escaped as $0a$
  - The suffix .i and .b should be used for integer and boolean entries.
  - Commented lines are denoted by a character '#' as the first character of the line.
  - White-spaces are significant after '=' for string entries.
  Example:

      #v1
      paramKey1.b=true
      paramKey2.i = 123
      paramStr  =value for paramStr

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ParametersString()`
    `ParametersString(java.lang.String data)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `fromString(java.lang.String data)`
    `void` | `fromString(java.lang.String data, boolean clearBuffer)` Deserialize the specified data into this object.
    `boolean` | `getBoolean(java.lang.String name)`
    `boolean` | `getBoolean(java.lang.String name, boolean defaultValue)`
    `java.lang.String` | `getEncodedString(java.lang.String name, java.lang.String defaultValue)` Gets the string value for a given parameter after decoding it if necessary.
    `java.lang.String` | `getGroup(java.lang.String name)`
    `java.lang.String` | `getGroup(java.lang.String name, java.lang.String defaultValue)`
    `int` | `getInteger(java.lang.String name)`
    `int` | `getInteger(java.lang.String name, int defaultValue)`
    `java.lang.String` | `getString(java.lang.String name)`
    `java.lang.String` | `getString(java.lang.String name, java.lang.String defaultValue)`
    `void` | `remove(java.lang.String name)`
    `void` | `removeGroup(java.lang.String groupName)`
    `void` | `reset()`
    `void` | `setBoolean(java.lang.String name, boolean value)`
    `void` | `setEncodedString(java.lang.String name, java.lang.String value)` Sets the string value of a given parameter and encode it.
    `void` | `setGroup(java.lang.String name, ParametersString params)`
    `void` | `setGroup(java.lang.String name, java.lang.String data)`
    `void` | `setInteger(java.lang.String name, int value)`
    `void` | `setParameter(java.lang.String name, boolean value)`
    `void` | `setParameter(java.lang.String name, int value)`
    `void` | `setParameter(java.lang.String name, java.lang.String value)`
    `void` | `setString(java.lang.String name, java.lang.String value)`
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ParametersString

          public ParametersString()

    - #### ParametersString

          public ParametersString(java.lang.String data)

  - ### Method Detail

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### fromString

          public void fromString(java.lang.String data)

    - #### fromString

          public void fromString(java.lang.String data,
                        boolean clearBuffer)

      Deserialize the specified data into this object. Optionally reset the internal parameter set before doing so.
      Parameters:
        `data` - data to deserialize
        `clearBuffer` - if true, the internal parameters list will be cleared before loading the data. if false, any existing parameters will be left intact unless they are overridden by the data.

    - #### reset

          public void reset()

    - #### remove

          public void remove(java.lang.String name)

    - #### removeGroup

          public void removeGroup(java.lang.String groupName)

    - #### getGroup

          public java.lang.String getGroup(java.lang.String name,
                                  java.lang.String defaultValue)

    - #### getGroup

          public java.lang.String getGroup(java.lang.String name)

    - #### setGroup

          public void setGroup(java.lang.String name,
                      java.lang.String data)

    - #### setGroup

          public void setGroup(java.lang.String name,
                      ParametersString params)

    - #### getString

          public java.lang.String getString(java.lang.String name,
                                   java.lang.String defaultValue)

    - #### getString

          public java.lang.String getString(java.lang.String name)

    - #### setString

          public void setString(java.lang.String name,
                       java.lang.String value)

    - #### getBoolean

          public boolean getBoolean(java.lang.String name,
                           boolean defaultValue)

    - #### getBoolean

          public boolean getBoolean(java.lang.String name)

    - #### setBoolean

          public void setBoolean(java.lang.String name,
                        boolean value)

    - #### getInteger

          public int getInteger(java.lang.String name,
                       int defaultValue)

    - #### getInteger

          public int getInteger(java.lang.String name)

    - #### setInteger

          public void setInteger(java.lang.String name,
                        int value)

    - #### setParameter

          public void setParameter(java.lang.String name,
                          java.lang.String value)

    - #### setParameter

          public void setParameter(java.lang.String name,
                          boolean value)

    - #### setParameter

          public void setParameter(java.lang.String name,
                          int value)

    - #### getEncodedString

          public java.lang.String getEncodedString(java.lang.String name,
                                          java.lang.String defaultValue)

      Gets the string value for a given parameter after decoding it if necessary.
      Parameters:
        `name` - the name of the parameter.
        `defaultValue` - the default (not encoded) value to use.
      Returns:
        the string value of the given parameter, decoded if necessary.

    - #### setEncodedString

          public void setEncodedString(java.lang.String name,
                              java.lang.String value)

      Sets the string value of a given parameter and encode it. The encoding applied is only a basic first level of security protecting the value from being casually read by a human, it is not an encryption.
      Parameters:
        `name` - the name of the parameter.
        `value` - the value to set and encode.