edu.northwestern.at.utils

## Class UTF8Properties

- java.lang.Object
- - java.util.Dictionary<K,V>
  - - java.util.Hashtable<java.lang.Object,java.lang.Object>
    - - java.util.Properties
      - - edu.northwestern.at.utils.UTF8Properties

- All Implemented Interfaces:
    TaggedStrings, java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

      public class UTF8Properties
      extends java.util.Properties
      implements TaggedStrings, java.io.Serializable

  UTF8Properties -- A UTF8 compatible version of Java Properties.

  Regular Java Properties must be read and written using the ISO8859-1 character encoding. UTF8Properties reads and writes the properties using the utf-8 character encoding instead.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.lang.String` | `keyValueSeparators` Allowed separators between key and value of a property.

    - ### Fields inherited from class java.util.Properties

      `defaults`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UTF8Properties()` Create empty property list with no default values.
    `UTF8Properties(java.util.Properties defaults)` Create empty property list with specified defaults.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `containsString(java.lang.String string)` See if list contains specified string.
    `static java.lang.String` | `convertInputString(java.lang.String line)` Replace all characters preceded by a '\' with the corresponding special character and convert unicode escape sequences to normal characterS.
    `protected java.lang.String` | `formatStringForOutput(java.lang.String line)` Format string for output.
    `java.util.Set<java.lang.String>` | `getAllStrings()` Get set of all unique strings.
    `java.util.Set<java.lang.String>` | `getAllTags()` Get set of all unique tags.
    `int` | `getStringCount()` Get number of strings.
    `java.lang.String` | `getTag(java.lang.String string)` Get the tag value associated with a string.
    `protected boolean` | `isContinued(java.lang.String line)` Check if property continues on the next line.
    `void` | `load(java.io.InputStream inputStream)` Reads a property list (key and element pairs) from a utf-8 encoded input stream.
    `void` | `load(java.io.InputStream inputStream, java.lang.String defaultValue)` Reads a property list (key and element pairs) from a utf-8 encoded input stream.
    `void` | `putTag(java.lang.String string, java.lang.String tag)` Set the tag value associated with a string.
    `static java.lang.String` | `removeLeadingWhiteSpace(java.lang.String line)` Remove leading white space from a string.
    `void` | `save(java.io.OutputStream outputStream, java.lang.String header)` Deprecated. Use `store( OutputStream , String )` instead.
    `void` | `store(java.io.OutputStream outputStream, java.lang.String header)` Store properties to a file.
    `void` | `store(java.io.OutputStream outputStream, java.lang.String header, boolean outputOnlyKeys)` Store properties to a file.

    - ### Methods inherited from class java.util.Properties

      `getProperty, getProperty, list, list, load, loadFromXML, propertyNames, setProperty, store, storeToXML, storeToXML, stringPropertyNames`

    - ### Methods inherited from class java.util.Hashtable

      `clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values`

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

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### keyValueSeparators

          protected static final java.lang.String keyValueSeparators

      Allowed separators between key and value of a property.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### UTF8Properties

          public UTF8Properties()

      Create empty property list with no default values.

    - #### UTF8Properties

          public UTF8Properties(java.util.Properties defaults)

      Create empty property list with specified defaults.
      Parameters:
        `defaults` - Default property values.

  - ### Method Detail

    - #### load

          public void load(java.io.InputStream inputStream,
                  java.lang.String defaultValue)
                    throws java.io.IOException

      Reads a property list (key and element pairs) from a utf-8 encoded input stream.
      Parameters:
        `inputStream` - The input stream.
        `defaultValue` - The default value when none specified.
      Throws:
        `java.io.IOException` - When an error occurs while reading from the input stream.
        `java.lang.IllegalArgumentException` - When the input stream contains an invalid Unicode escape sequence.

        The default value is assigned to any key which does not have a value. Assume the default value is the string "missing". Then the input line

        `x=1`

        returns a key of "x" with value of "1", while the input line

        `x`

        returns a key of "x" with value of "missing" .

    - #### load

          public void load(java.io.InputStream inputStream)
                    throws java.io.IOException

      Reads a property list (key and element pairs) from a utf-8 encoded input stream.
      Overrides:
        `load` in class `java.util.Properties`
      Parameters:
        `inputStream` - The input stream.
      Throws:
        `java.io.IOException` - When an error occurs while reading from the input stream.
        `java.lang.IllegalArgumentException` - When the input stream contains an invalid Unicode escape sequence.

        Null is used as the default value for any key without a specified value.

    - #### removeLeadingWhiteSpace

          public static java.lang.String removeLeadingWhiteSpace(java.lang.String line)

      Remove leading white space from a string.
      Parameters:
        `line` - The string from which to remove leading white space.
      Returns:
        String with leading while space removed.

    - #### convertInputString

          public static java.lang.String convertInputString(java.lang.String line)

      Replace all characters preceded by a '\' with the corresponding special character and convert unicode escape sequences to normal characterS.
      Parameters:
        `line` - String for which to process escape sequences.
      Returns:
        The processed string.

    - #### formatStringForOutput

          protected java.lang.String formatStringForOutput(java.lang.String line)

      Format string for output.
      Parameters:
        `line` - String to convert to output format.
      Returns:
        Output formatted string .

    - #### isContinued

          protected boolean isContinued(java.lang.String line)

      Check if property continues on the next line.
      Parameters:
        `line` - Beginning of the property that might be continued on the next line.
      Returns:
        true if property continues on the following line.

        A trailing "\" character indicates a property value is continued on the next line.

    - #### save

          public void save(java.io.OutputStream outputStream,
                  java.lang.String header)

      Deprecated. Use `store( OutputStream , String )` instead.
      Store properties to a file ignoring any I/O errors.
      Overrides:
        `save` in class `java.util.Properties`
      Parameters:
        `outputStream` - Stream to which to save properties.
        `header` - Optionl description of the property list.
      Throws:
        `java.lang.ClassCastException` - If any key or value is not a String.

    - #### store

          public void store(java.io.OutputStream outputStream,
                   java.lang.String header,
                   boolean outputOnlyKeys)
                     throws java.io.IOException

      Store properties to a file.
      Parameters:
        `outputStream` - Output stream.
        `header` - Optional description of property list.
        `outputOnlyKeys` - True to output only the keys, false to output both the keys and the values.
      Throws:
        `java.io.IOException` - When an error occurs while writing to the output stream.

    - #### store

          public void store(java.io.OutputStream outputStream,
                   java.lang.String header)
                     throws java.io.IOException

      Store properties to a file.
      Overrides:
        `store` in class `java.util.Properties`
      Parameters:
        `outputStream` - Output stream.
        `header` - Optional description of the property list.
      Throws:
        `java.io.IOException` - When an error occurs while writing to the output stream.

    - #### containsString

          public boolean containsString(java.lang.String string)

      See if list contains specified string.
      Specified by:
        `containsString` in interface `TaggedStrings`
      Parameters:
        `string` - The string.
      Returns:
        True if list contains specified string.

    - #### getTag

          public java.lang.String getTag(java.lang.String string)

      Get the tag value associated with a string.
      Specified by:
        `getTag` in interface `TaggedStrings`
      Parameters:
        `string` - The string.
      Returns:
        The tag value associated with the string. May be null.

    - #### putTag

          public void putTag(java.lang.String string,
                    java.lang.String tag)

      Set the tag value associated with a string.
      Specified by:
        `putTag` in interface `TaggedStrings`
      Parameters:
        `string` - The string.
        `tag` - The tag.

    - #### getStringCount

          public int getStringCount()

      Get number of strings.
      Specified by:
        `getStringCount` in interface `TaggedStrings`
      Returns:
        Number of strings.

    - #### getAllStrings

          public java.util.Set<java.lang.String> getAllStrings()

      Get set of all unique strings.
      Specified by:
        `getAllStrings` in interface `TaggedStrings`
      Returns:
        Set of all unique strings.

    - #### getAllTags

          public java.util.Set<java.lang.String> getAllTags()

      Get set of all unique tags.
      Specified by:
        `getAllTags` in interface `TaggedStrings`
      Returns:
        Set of all unique tags