com.metamatrix.toolbox.preference
Class UserPreferences

java.lang.Object
  extended by com.metamatrix.toolbox.preference.UserPreferences
All Implemented Interfaces:
PropertiedObject

public class UserPreferences
extends java.lang.Object
implements PropertiedObject


Field Summary
static java.lang.String LOG_CONTEXT
           
static java.lang.String PROPERTY_PREFIX
           
static java.lang.String USER_PREFERENCES_DEFINITION_FILE_PROPERTY_NAME
           
 
Method Summary
 void clearChanges()
           
 boolean getBooleanValue(java.lang.String propName)
          Convenience method for determining if a property value is "true" or "false"
static UserPreferences getInstance()
           
 PropertiedObject getPropertiedObject()
           
 PropertiedObjectEditor getPropertiedObjectEditor()
           
 java.util.Properties getProperties()
          Return an unmodifiable Properties object containing all user preference properties.
 java.util.Properties getProperties(java.lang.String filter)
          Return an unmodifiable Properties object that contains only those properties that match the specified filter.
 java.util.Properties getProperties(java.lang.String filter, boolean ignoreCase)
          Return an unmodifiable Properties object that contains only those properties that match the specified filter.
 java.util.Properties getPropertiesBranch(java.lang.String prefix)
          Return an unmodifiable Properties object containing all user preference properties that exist beneath the specified property name prefix.
 java.lang.Object getValue(java.lang.String propName)
           
 java.util.Collection getValues(java.lang.String propName, char delimiter)
          return an collection of String values tokenized buy the specified delimiter
 boolean hasChanges()
           
 boolean isReadOnly()
           
static void main(java.lang.String[] args)
           
 void removeValue(java.lang.String propName)
           
 void saveChanges()
           
 void setConfigProperties(java.util.Properties properties)
          Set the configuration properties used to initialize this.
 void setValue(java.lang.String propName, java.lang.Object value)
          set this entity's value for the specified property name.
 void setValues(java.lang.String propName, java.util.Collection values, char delimiter)
          Store an array of values as their toString returns, delimited by the specified delimiter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_CONTEXT

public static final java.lang.String LOG_CONTEXT
See Also:
Constant Field Values

PROPERTY_PREFIX

public static final java.lang.String PROPERTY_PREFIX
See Also:
Constant Field Values

USER_PREFERENCES_DEFINITION_FILE_PROPERTY_NAME

public static final java.lang.String USER_PREFERENCES_DEFINITION_FILE_PROPERTY_NAME
See Also:
Constant Field Values
Method Detail

getInstance

public static UserPreferences getInstance()

setConfigProperties

public void setConfigProperties(java.util.Properties properties)
Set the configuration properties used to initialize this. Useful for testing.

Parameters:
properties -

hasChanges

public boolean hasChanges()

saveChanges

public void saveChanges()

clearChanges

public void clearChanges()

isReadOnly

public boolean isReadOnly()

getPropertiedObjectEditor

public PropertiedObjectEditor getPropertiedObjectEditor()

getPropertiedObject

public PropertiedObject getPropertiedObject()

getValue

public java.lang.Object getValue(java.lang.String propName)

getBooleanValue

public boolean getBooleanValue(java.lang.String propName)
Convenience method for determining if a property value is "true" or "false"


setValue

public void setValue(java.lang.String propName,
                     java.lang.Object value)
set this entity's value for the specified property name.

Parameters:
propName - the name of the property
value - the object to store for this property name. If the value is null or a zero-length String, then the specified propName will be removed from this entity's list of properties.

setValues

public void setValues(java.lang.String propName,
                      java.util.Collection values,
                      char delimiter)
Store an array of values as their toString returns, delimited by the specified delimiter

Parameters:
propName - the name of the property
values - a Collection of objects to store for this property name. If the collection is either null or empty, then the specified propName will be removed from this entity's list of properties.

removeValue

public void removeValue(java.lang.String propName)

getValues

public java.util.Collection getValues(java.lang.String propName,
                                      char delimiter)
return an collection of String values tokenized buy the specified delimiter


getProperties

public java.util.Properties getProperties()
Return an unmodifiable Properties object containing all user preference properties.

Returns:
all properties beneath the specified node, plus an additional property named PROPERTY_PREFIX with the value of the specified prefix. Will not return null.

getPropertiesBranch

public java.util.Properties getPropertiesBranch(java.lang.String prefix)
Return an unmodifiable Properties object containing all user preference properties that exist beneath the specified property name prefix.

Parameters:
prefix - the string filter that identifies the root of the property names to be returned; if null or zero-length, all properties are returned.
Returns:
all properties beneath the specified node, plus an additional property named PROPERTY_PREFIX with the value of the specified prefix. Will not return null.

getProperties

public java.util.Properties getProperties(java.lang.String filter)
Return an unmodifiable Properties object that contains only those properties that match the specified filter. The filter is a string that may contain the '*' character as a wildcard one or more times in the string. For example, the following filter:

       *metamatrix.*

finds all properties that contain somewhere in the property name the string "metamatrix.".

The filter is case sensitive.

Parameters:
filter - the string filter that will be used to narrow the set of properties returned; all properties are returned if the filter is null, zero-length or equal to "*".
Returns:
all properties specified with the filter pattern; never null

getProperties

public java.util.Properties getProperties(java.lang.String filter,
                                          boolean ignoreCase)
Return an unmodifiable Properties object that contains only those properties that match the specified filter. The filter is a string that may contain the '*' character as a wildcard one or more times in the string. For example, the following filter:

       *metamatrix.*

finds all properties that contain somewhere in the property name the string "metamatrix.".

Parameters:
filter - the string filter that will be used to narrow the set of properties returned; all properties are returned if the filter is null, zero-length or equal to "*".
ignoreCase - true if the case of the property names is to be ignored when using the filter.
Returns:
all properties specified with the filter pattern; never null

main

public static void main(java.lang.String[] args)


Copyright © 2009. All Rights Reserved.