Jumpi v1.2.0

org.jumpi.impl.util
Class Properties

java.lang.Object
  |
  +--org.jumpi.impl.util.Properties
All Implemented Interfaces:
Properties

public class Properties
extends java.lang.Object
implements Properties

A Hashtable of String, key-value pairs. Properties are added by calling set and retrieved by calling get. A property can be removed by calling the remove method. A Properties instance can be made invariant by calling setReadOnly.


Constructor Summary
Properties()
          Creates a new Properties object.
Properties(java.util.Hashtable props)
          Creates a new Properties object.
 
Method Summary
 java.lang.String get(java.lang.String name)
          Get the value of the named property.
 java.lang.String get(java.lang.String name, java.lang.String def)
          Get the value of the named property if existing otherwise return the provided default value.
 boolean isReadOnly()
          Whether the instance is read only or not.
 java.util.Enumeration keys()
          Return all the property names.
 void remove(java.lang.String name)
          Remove the named property.
 void set(java.lang.String name, java.lang.String value)
          Add the named property.
 void setReadOnly()
          Make the properties invariant.
 int size()
          Return the number of properties in the collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Properties

public Properties()
Creates a new Properties object. The instance is not read only and has no name value pairs set.


Properties

public Properties(java.util.Hashtable props)
Creates a new Properties object. The instance is not read only and uses the given Hashtable as source of the properties. The provided Hashtable is not cloned.

Parameters:
props - a Hashtable of properties to use internally as the name value pairs.
Throws:
java.lang.IllegalArgumentException - if props is null.
Method Detail

set

public void set(java.lang.String name,
                java.lang.String value)
Add the named property. Overwrite the property value if the name already exists.

Specified by:
set in interface Properties
Parameters:
name - the name of the property.
value - the value of the property.
Throws:
java.lang.IllegalArgumentException - if either name or value are null.
java.lang.IllegalStateException - if read only.
See Also:
get(java.lang.String), setReadOnly()

get

public java.lang.String get(java.lang.String name)
Get the value of the named property.

Specified by:
get in interface Properties
Parameters:
name - the name of the property.
Returns:
the value of the property or null if the property doesn't exist.
Throws:
java.lang.IllegalArgumentException - if name is null.
See Also:
set(java.lang.String, java.lang.String)

get

public java.lang.String get(java.lang.String name,
                            java.lang.String def)
Get the value of the named property if existing otherwise return the provided default value.

Specified by:
get in interface Properties
Parameters:
name - the name of the property.
def - the default value of the property
Returns:
the property value or default value provided if the property does not exist.
Throws:
java.lang.IllegalArgumentException - if name is null.
See Also:
set(java.lang.String, java.lang.String)

remove

public void remove(java.lang.String name)
Remove the named property. Has no effect if the property does not exist.

Specified by:
remove in interface Properties
Parameters:
name - the name of the property to remove.
Throws:
java.lang.IllegalArgumentException - if name is null.
java.lang.IllegalStateException - if read only.
See Also:
setReadOnly()

setReadOnly

public void setReadOnly()
Make the properties invariant. Calling set or remove throws IllegalStateExceptions if the instance is read-only.

Specified by:
setReadOnly in interface Properties
See Also:
isReadOnly(), set(java.lang.String, java.lang.String), remove(java.lang.String)

keys

public java.util.Enumeration keys()
Return all the property names.

Specified by:
keys in interface Properties
Returns:
all the property names.
Throws:
java.lang.IllegalStateException - when not read only.

isReadOnly

public boolean isReadOnly()
Whether the instance is read only or not.

Returns:
whether the instance is read only or not.
See Also:
setReadOnly()

size

public int size()
Return the number of properties in the collection.

Specified by:
size in interface Properties
Returns:
the number of properties in the collection.

Jumpi v1.2.0

Copyright © 2003, Peter Jonathan Klauser.