org.springframework.roo.classpath.preferences
Class Preferences

java.lang.Object
  extended by org.springframework.roo.classpath.preferences.Preferences

public class Preferences
extends Object

A node in the user's tree of preferences.

Since:
1.2.0
Author:
Andrew Swan

Constructor Summary
Preferences(Preferences preferences)
          Constructor for delegating to a Java Preferences instance.
 
Method Summary
 void flush()
          Flushes any changes in these preferences to the persistent storage.
 byte[] getByteArray(String key)
          Returns the byte array with the given key, or if none, an empty array.
 byte[] getByteArray(String key, String defaultValue, String characterSetName)
          Returns the byte array with the given key, or if none, the given default value.
 int getInt(String key, int defaultValue)
          Returns the int with the given key, or if none, the given default value.
 void putByteArray(String key, byte[] value)
          Adds the given byte array under the given key.
 void putInt(String key, int value)
          Adds the given int value under the given key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Preferences

public Preferences(Preferences preferences)
Constructor for delegating to a Java Preferences instance.

Parameters:
preferences - the preferences to read and write (required)
Method Detail

flush

public void flush()
Flushes any changes in these preferences to the persistent storage.

Throws:
IllegalStateException - if there was a problem

getByteArray

public byte[] getByteArray(String key)
Returns the byte array with the given key, or if none, an empty array.

Parameters:
key - the key whose value to retrieve (can be null)
Returns:
null iff a null key is given

getByteArray

public byte[] getByteArray(String key,
                           String defaultValue,
                           String characterSetName)
Returns the byte array with the given key, or if none, the given default value.

Parameters:
key - the key whose value to retrieve (can be null)
defaultValue - can be null to default to an empty array
characterSetName - the name of the character set into which to encode the given default value
Returns:
null iff a null key is given
Throws:
UnsupportedOperationException - if the given character set is not supported

getInt

public int getInt(String key,
                  int defaultValue)
Returns the int with the given key, or if none, the given default value.

Parameters:
key - the key whose value to retrieve (can be null)
defaultValue - see above

putByteArray

public void putByteArray(String key,
                         byte[] value)
Adds the given byte array under the given key.

Parameters:
key -
value -

putInt

public void putInt(String key,
                   int value)
Adds the given int value under the given key.

Parameters:
key -
value -


Copyright © 2009–2015. All rights reserved.