Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.maryanovsky.gwtutils.client
Class Properties

    java.lang.Object
      com.maryanovsky.gwtutils.client.Properties

    public class Properties

extends Object

Parses and provides access to a set of properties mapped to string keys. This is quite similar to the `Properties` class, but provides a little more functionality for accessing and parsing the properties.

Author:
  Maryanovsky Alexander

Constructor Summary
`Properties(Map<String,String> props)` Creates a new `Properties` object with the specified map of actual, unparsed properties.
`Properties(Map<String,String> props, Properties delegate)` Creates a new `Properties` object with the specified map of actual, unparsed properties, and a backup `Properties` object which is consulted if a certain property is not found locally.

Method Summary
`String` | `get(String propertyName)` Returns the value of specified property.
`String` | `get(String propertyName, String defaultValue)` Returns the value of the specified property, or the specified default value if there is no property with the specified name.
`boolean` | `getBoolean(String propertyName)` Returns the value of the specified property, parsed as a boolean value.
`boolean` | `getBoolean(String propertyName, boolean defaultValue)` Returns the value of the specified property, parsed as a boolean value, or the specified default value if there is no such property.
`char` | `getChar(String propertyName)` Returns the value of the specified property, parsed as a character.
`char` | `getChar(String propertyName, char defaultValue)` Returns the value of the specified property, parsed as a character, or the specfied default value if there is no such property.
`double` | `getDouble(String propertyName)` Returns the value of the specified property, parsed as a floating point value.
`double` | `getDouble(String propertyName, double defaultValue)` Returns the value of the specified property, parsed as a floating point value, or the specified default value if there is no property with the specified name.
`int` | `getInt(String propertyName)` Returns the value of the specified property, parsed as an integer.
`int` | `getInt(String propertyName, int defaultValue)` Returns the value of the specified property, parsed as an integer, or the specified default value if there is no property with the specified name.
`String[]` | `getStringList(String propertyName)` Returns the value of the specified property, parsed a list of comma-separated strings.
`String[]` | `getStringList(String propertyName, String[] defaultValue)` Returns the value of the specified property, parsed as a list of comma-separated strings, or the specified default value if there is no property with the specified name.
`protected RuntimeException` | `invalidPropertyException(String propertyName, String propertyValue)` Returns the exception to throw when encountering an invalid property.
`protected RuntimeException` | `missingPropertyException(String propertyName)` Returns the exception to throw when encountering a missing property.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Properties

    public Properties(Map<String,String> props,
                      Properties delegate)

  Creates a new `Properties` object with the specified map of actual, unparsed properties, and a backup `Properties` object which is consulted if a certain property is not found locally.

### Properties

    public Properties(Map<String,String> props)

  Creates a new `Properties` object with the specified map of actual, unparsed properties.

Method Detail

### missingPropertyException

    protected RuntimeException missingPropertyException(String propertyName)

  Returns the exception to throw when encountering a missing property. The default implementation returns an `IllegalArgumentException` with a short message and the name of the property.

### invalidPropertyException

    protected RuntimeException invalidPropertyException(String propertyName,
                                                        String propertyValue)

  Returns the exception to throw when encountering an invalid property. The default implementation returns an `IllegalArgumentException` with a short message and the name and value of the property.

### get

    public String get(String propertyName,
                      String defaultValue)

  Returns the value of the specified property, or the specified default value if there is no property with the specified name.

### get

    public String get(String propertyName)

  Returns the value of specified property. Throws `missingPropertyException(String)` if there is no property with the specified name.

### getInt

    public int getInt(String propertyName)

  Returns the value of the specified property, parsed as an integer. Throws `missingPropertyException(String)` if there is no property with the specified name, or `invalidPropertyException(String, String)` if the property value can't be parsed as an integer.

### getInt

    public int getInt(String propertyName,
                      int defaultValue)

  Returns the value of the specified property, parsed as an integer, or the specified default value if there is no property with the specified name. Throws `invalidPropertyException(String, String)` if the property value can't be parsed as an integer.

### getDouble

    public double getDouble(String propertyName)

  Returns the value of the specified property, parsed as a floating point value. Throws `missingPropertyException(String)` if there is no property with the specified name, or `invalidPropertyException(String, String)` if the property value can't be parsed as a floating point value.

### getDouble

    public double getDouble(String propertyName,
                            double defaultValue)

  Returns the value of the specified property, parsed as a floating point value, or the specified default value if there is no property with the specified name. Throws `invalidPropertyException(String, String)` if the property value can't be parsed as a floating point value.

### getBoolean

    public boolean getBoolean(String propertyName)

  Returns the value of the specified property, parsed as a boolean value. All strings equal, ignoring case, to `"true"` are considered as `true` values, and all strings equal, ignoring case, to `"false"` are considered as `false`. Throws `missingPropertyException(String)` if there is no property with the specified name, or `invalidPropertyException(String, String)` if the property value can't be parsed as a boolean.

### getBoolean

    public boolean getBoolean(String propertyName,
                              boolean defaultValue)

  Returns the value of the specified property, parsed as a boolean value, or the specified default value if there is no such property. All strings equal, ignoring case, to `"true"` are considered as `true` values, and all strings equal, ignoring case, to `"false"` are considered as `false`. Throws `invalidPropertyException(String, String)` if the property value can't be parsed as a boolean.

### getChar

    public char getChar(String propertyName)

  Returns the value of the specified property, parsed as a character. Throws `missingPropertyException(String)` if there is no property with the specified name, or `invalidPropertyException(String, String)` if the property value can't be parsed as a character.

### getChar

    public char getChar(String propertyName,
                        char defaultValue)

  Returns the value of the specified property, parsed as a character, or the specfied default value if there is no such property. Throws `invalidPropertyException(String, String)` if the property value can't be parsed as a character.

### getStringList

    public String[] getStringList(String propertyName)

  Returns the value of the specified property, parsed a list of comma-separated strings. Throws `missingPropertyException(String)` if there is no property with the specified name.

### getStringList

    public String[] getStringList(String propertyName,
                                  String[] defaultValue)

  Returns the value of the specified property, parsed as a list of comma-separated strings, or the specified default value if there is no property with the specified name.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD