Class PropsRS

java.lang.Object
  extended by PropsRS

public class PropsRS
extends java.lang.Object

Inspired by the J2SE Properties class, this one uses RecordStores to store properties.

Author:
Michel Deriaz

Constructor Summary
PropsRS(java.lang.String name)
          Creates a new PropsRS object to access the record store whose name is specified by the parameter.
 
Method Summary
static boolean delete(java.lang.String name)
          Deletes a record store.
 java.lang.String get(java.lang.String key)
          Gets the property that matches the given key.
 int getInt(java.lang.String key)
          Gets the property the matches the given key, assuming that the property represents an integer.
 boolean save()
          Saves the properties entered via the set methods in the record store.
 boolean set(java.lang.String key, int value)
          Sets a new property, described by an integer.
 boolean set(java.lang.String key, java.lang.String value)
          Sets a new property.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropsRS

public PropsRS(java.lang.String name)
Creates a new PropsRS object to access the record store whose name is specified by the parameter.

Parameters:
name - the name of the record store
Method Detail

get

public java.lang.String get(java.lang.String key)
Gets the property that matches the given key.

Parameters:
key - the key
Returns:
the property that matches the given key, or null if the property does not exist

getInt

public int getInt(java.lang.String key)
Gets the property the matches the given key, assuming that the property represents an integer.

Parameters:
key - the key
Returns:
the property that matches the given key, or Integer.MIN_VALUE if the property does not exist or does not represent a valid integer

set

public boolean set(java.lang.String key,
                   java.lang.String value)
Sets a new property. If a property with the same key already exists, the old one is replaced by the new one. The key cannot contain the \t character because this class uses it as a separator.

Parameters:
key - the key
value - the value of the property
Returns:
true if the property is set successfully, false if the key is null, the key contains the \t character, or if the value is null

set

public boolean set(java.lang.String key,
                   int value)
Sets a new property, described by an integer. If a property with the same key already exists, the old one is replaced by the new one. The key cannot contain the \t character because this class uses it as a separator.

Parameters:
key - the key
value - the value of the property
Returns:
true if the property is set successfully, false if the key is null, or if the key contains the \t character

save

public boolean save()
Saves the properties entered via the set methods in the record store.

Returns:
true if the record store is saved successfully, false otherwise

delete

public static boolean delete(java.lang.String name)
Deletes a record store. Midlets suites are only allowed to delete their own record stores.

Parameters:
name - the name of the record store
Returns:
true if the record store is deleted successfully, false if the record store can not be deleted