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

## gecco.server.core
Class TypedProperties

    java.lang.Object
      gecco.server.core.TypedProperties

All Implemented Interfaces:
  Map

public class TypedProperties
extends Object
implements Map

Maintains a mapping between names and values. The names are always Strings, but the values can be any kind of object. This class keeps track of the type of the object, and provides convenient get/set methods for certain popular types, avoiding the inconvenience and hazard of explicit type casting.

Author:
  Karl Hasselström

Nested Class Summary

Nested classes inherited from class java.util.Map
`Map.Entry`

Field Summary
`static String` | `TYPE_DOUBLE` Predefined property type corresponding to the primitive data type `double`
`static String` | `TYPE_INT` Predefined property type corresponding to the primitive data type `int`
`static String` | `TYPE_STRING` Predefined property type corresponding to the class `String`
`static String` | `TYPE_UNDEFINED` Property type assigned when none was specified

Constructor Summary
`TypedProperties()` Constructor for the `TypedProperties` object.
`TypedProperties(TypedProperties other)` Constructor for the `TypedProperties` object.

Method Summary
`void` | `clear()` Removes all properties
`boolean` | `containsKey(Object key)` Checks whether an `Object` is a key in a mapping, that is, if there is a property of that name.
`boolean` | `containsValue(Object value)` Checks whether an `Object` is a value in a mapping, that is, if there is a property with that value.
`Set` | `entrySet()` Returns the set of mappings.
`boolean` | `equals(Object o)` Tests the given `Object` for equality with this one.
`Object` | `get(Object key)` Retrieves the value associated with a name, without regard of its type.
`double` | `getDoubleProperty(String name)` Retrieves the `double` value associated with a name
`int` | `getIntProperty(String name)` Retrieves the `int` value associated with a name
`Object` | `getProperty(String name)` Retrieves the value associated with a name, without regard of its type.
`String` | `getPropertyType(String name)` Retrieves the type of a property
`String` | `getStringProperty(String name)` Retrieves the `String` value associated with a name
`int` | `hashCode()` Computes a hash code for this object.
`boolean` | `isEmpty()` Checks if any properties are defined or not.
`Set` | `keySet()` Returns the set of all names of properties that have been defined
`void` | `loadProperties(TypedProperties other)` Copies all properties (and their types) from the given `TypedProperties` to this one.
`Object` | `put(Object key, Object value)` Creates or replaces a property.
`void` | `putAll(Map t)` Copies all the key/value pairs from a map as properties in this mapping.
`Object` | `remove(Object key)` Removes a property This method exists only because the `Map` interface requires it.
`Object` | `removeProperty(String name)` Removes a property
`void` | `setProperty(String name, double value)` Creates or replaces a property.
`void` | `setProperty(String name, int value)` Creates or replaces a property.
`void` | `setProperty(String name, Object value, String type)` Creates or replaces a property.
`void` | `setProperty(String name, String value)` Creates or replaces a property.
`int` | `size()` Calculates the number of properties stored in this mapping
`Collection` | `values()` Returns a `Collection` view of all values stored in this mapping

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

Field Detail

### TYPE_DOUBLE

    public static final String TYPE_DOUBLE

  Predefined property type corresponding to the primitive data type `double`

  See Also:
    Constant Field Values

### TYPE_INT

    public static final String TYPE_INT

  Predefined property type corresponding to the primitive data type `int`

  See Also:
    Constant Field Values

### TYPE_STRING

    public static final String TYPE_STRING

  Predefined property type corresponding to the class `String`

  See Also:
    Constant Field Values

### TYPE_UNDEFINED

    public static final String TYPE_UNDEFINED

  Property type assigned when none was specified

  See Also:
    Constant Field Values

Constructor Detail

### TypedProperties

    public TypedProperties()

  Constructor for the `TypedProperties` object. Creates an empty mapping.

### TypedProperties

    public TypedProperties(TypedProperties other)

  Constructor for the `TypedProperties` object. Creates an exact duplicate of the given `TypedProperties` .

Parameters:
  `other` - The `TypedProperties` object to be duplicated

Method Detail

### setProperty

    public void setProperty(String name,
                            double value)

  Creates or replaces a property. The value is a `double` .

  Parameters:
    `name` - The name of the property
    `value` - The value

### setProperty

    public void setProperty(String name,
                            int value)

  Creates or replaces a property. The value is an `int` .

  Parameters:
    `name` - The name of the property
    `value` - The value

### setProperty

    public void setProperty(String name,
                            String value)

  Creates or replaces a property. The value is a `String` .

  Parameters:
    `name` - The name of the property
    `value` - The value

### setProperty

    public void setProperty(String name,
                            Object value,
                            String type)

  Creates or replaces a property. `null` values are not permitted.

  Parameters:
    `name` - The name of the property
    `value` - The value
    `type` - The type

### getProperty

    public Object getProperty(String name)

  Retrieves the value associated with a name, without regard of its type.

  Parameters:
    `name` - The name
  Returns:
    The associated property value

### getPropertyType

    public String getPropertyType(String name)

  Retrieves the type of a property

  Parameters:
    `name` - The name of the property
  Returns:
    The type

### getDoubleProperty

    public double getDoubleProperty(String name)

  Retrieves the `double` value associated with a name

  Parameters:
    `name` - The name
  Returns:
    The value

### getIntProperty

    public int getIntProperty(String name)

  Retrieves the `int` value associated with a name

  Parameters:
    `name` - The name
  Returns:
    The value

### getStringProperty

    public String getStringProperty(String name)

  Retrieves the `String` value associated with a name

  Parameters:
    `name` - The name
  Returns:
    The value

### get

    public Object get(Object key)

  Retrieves the value associated with a name, without regard of its type. This method exists only because the `Map` interface requires it. It is recommended that you use `getProperty()` instead.

  Specified by:
    `get` in interface `Map`
  Parameters:
    `key` - The object whose `toString()` method will provide the name
  Returns:
    The associated property value

### isEmpty

    public boolean isEmpty()

  Checks if any properties are defined or not.

  Specified by:
    `isEmpty` in interface `Map`
  Returns:
    `true` if no mappings are defined

### loadProperties

    public void loadProperties(TypedProperties other)

  Copies all properties (and their types) from the given `TypedProperties` to this one. Existing properties with the same name are overwritten, as usual.

  Parameters:
    `other` - The `TypedProperties` containing the properties to be copied

### removeProperty

    public Object removeProperty(String name)

  Removes a property

  Parameters:
    `name` - The name of the property to be removed
  Returns:
    The value previously associated with the name, or `null` if the name was not bound

### clear

    public void clear()

  Removes all properties

  Specified by:
    `clear` in interface `Map`

### containsKey

    public boolean containsKey(Object key)

  Checks whether an `Object` is a key in a mapping, that is, if there is a property of that name.

  Specified by:
    `containsKey` in interface `Map`
  Parameters:
    `key` - The object whose `toString()` method will provide the name
  Returns:
    `true` if the name is mapped to a value

### containsValue

    public boolean containsValue(Object value)

  Checks whether an `Object` is a value in a mapping, that is, if there is a property with that value.

  Specified by:
    `containsValue` in interface `Map`
  Parameters:
    `value` - The value
  Returns:
    `true` if any name is mapped to that value

### entrySet

    public Set entrySet()

  Returns the set of mappings.

  Specified by:
    `entrySet` in interface `Map`
  Returns:
    The set of mappings.

### equals

    public boolean equals(Object o)

  Tests the given `Object` for equality with this one.

  Specified by:
    `equals` in interface `Map`
  Parameters:
    `o` - The other object
  Returns:
    `true` if and only if the other object is a `TypedProperties` containing the exact same properties as this one.

### hashCode

    public int hashCode()

  Computes a hash code for this object.

  Specified by:
    `hashCode` in interface `Map`
  Returns:
    An integer suitable for hashing this object

### keySet

    public Set keySet()

  Returns the set of all names of properties that have been defined

  Specified by:
    `keySet` in interface `Map`
  Returns:
    The set of names

### put

    public Object put(Object key,
                      Object value)

  Creates or replaces a property. Its type is marked as undefined. This method exists only because the `Map` interface requires it. It is recommended that you use one of the `setProperty()` methods instead.

  Specified by:
    `put` in interface `Map`
  Parameters:
    `key` - The object whose `toString()` method will provide the name
    `value` - The value
  Returns:
    The value previously associated with the name, or `null` if the name was unbound

### putAll

    public void putAll(Map t)

  Copies all the key/value pairs from a map as properties in this mapping. The names are given by the keys' `toString()` methods. The types are marked as undefined.

  Specified by:
    `putAll` in interface `Map`
  Parameters:
    `t` - The map with the properties to insert

### remove

    public Object remove(Object key)

  Removes a property This method exists only because the `Map` interface requires it. It is recommended that you use `removeProperty()` instead.

  Specified by:
    `remove` in interface `Map`
  Parameters:
    `key` - The object whose `toString()` method will provide the name
  Returns:
    The value previously associated with the name, or `null` if the name was not bound

### size

    public int size()

  Calculates the number of properties stored in this mapping

  Specified by:
    `size` in interface `Map`
  Returns:
    The number of properties

### values

    public Collection values()

  Returns a `Collection` view of all values stored in this mapping

  Specified by:
    `values` in interface `Map`
  Returns:
    A collection of values

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