org.apache.derby.iapi.services.property
Class PropertyUtil

java.lang.Object
  extended byorg.apache.derby.iapi.services.property.PropertyUtil

public class PropertyUtil
extends java.lang.Object

There are 5 property objects within a JBMS system. 1) JVM - JVM set - those in System.getProperties 2) APP - Application set - derby.properties file 3) SRV - Persistent Service set - Those stored in service.properties 4) TRAN - Persistent Transactional set - Those stored via the AccessManager interface 5) BOOT - Set by a boot method (rare) This class has a set of static methods to find a property using a consistent search order from the above set.
getSystem*() methods use the search order.

  1. JVM
  2. APP

getService* methods use the search order
  1. JVM
  2. TRAN
  3. SRV
  4. APP


Field Summary
static int NOT_SET
          Property is not set.
static java.lang.String[] servicePropertyList
           
static int SET_IN_APPLICATION
          Property is set in APPLICATION (derby.properties) set
static int SET_IN_DATABASE
          Property is set in DATABASE set
static int SET_IN_JVM
          Property is set in JVM set
 
Constructor Summary
PropertyUtil()
           
 
Method Summary
static boolean booleanProperty(java.lang.String p, java.io.Serializable v, boolean defaultValue)
          Parse and validate and return a boolean property value.
static java.lang.String getDatabaseProperty(PersistentSet set, java.lang.String key)
          Get a property only looking in the Persistent Transactional (database) set.
static java.io.Serializable getPropertyFromSet(boolean dbOnly, java.util.Dictionary set, java.lang.String key)
           
static java.lang.String getPropertyFromSet(boolean dbOnly, java.util.Properties set, java.lang.String key)
           
static java.io.Serializable getPropertyFromSet(java.util.Dictionary set, java.lang.String key)
           
static java.lang.String getPropertyFromSet(java.util.Properties set, java.lang.String key)
          Get a property from the passed in set.
static boolean getServiceBoolean(PersistentSet set, java.lang.String key, boolean defValue)
          Get a service wide property as a boolean.
static int getServiceInt(PersistentSet set, java.util.Properties props, java.lang.String key, int min, int max, int defaultValue)
          Get a service wide property as a int.
static int getServiceInt(PersistentSet set, java.lang.String key, int min, int max, int defaultValue)
          Get a service wide property as a int.
static java.lang.String getServiceProperty(PersistentSet set, java.lang.String key)
          Find a service wide property.
static java.lang.String getServiceProperty(PersistentSet set, java.lang.String key, java.lang.String defaultValue)
          Find a service wide property with a default.
static boolean getSystemBoolean(java.lang.String key)
          Get a system wide property as a boolean.
static int getSystemInt(java.lang.String key, int defaultValue)
          Get a system wide property as a int.
static int getSystemInt(java.lang.String key, int min, int max, int defaultValue)
          s Get a system wide property as a int.
static java.lang.String getSystemProperty(java.lang.String key)
          Find a system wide property.
static java.lang.String getSystemProperty(java.lang.String key, java.lang.String defaultValue)
          Find a system wide property with a default.
static int handleInt(java.lang.String value, int min, int max, int defaultValue)
          Parse an string as an int based property value.
static int intPropertyValue(java.lang.String p, java.io.Serializable v, int minValue, int maxValue, int defaultValue)
          Parse, validate and return an integer property value.
static boolean isDBOnly(java.util.Dictionary set)
           
static boolean isDBOnly(java.util.Properties set)
           
static boolean isServiceProperty(java.lang.String key)
          Return true iff the key is the name of a database property that is stored in services.properties.
(package private) static int whereSet(java.lang.String key, java.util.Dictionary set)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

servicePropertyList

public static final java.lang.String[] servicePropertyList

SET_IN_JVM

public static final int SET_IN_JVM
Property is set in JVM set

See Also:
Constant Field Values

SET_IN_DATABASE

public static final int SET_IN_DATABASE
Property is set in DATABASE set

See Also:
Constant Field Values

SET_IN_APPLICATION

public static final int SET_IN_APPLICATION
Property is set in APPLICATION (derby.properties) set

See Also:
Constant Field Values

NOT_SET

public static final int NOT_SET
Property is not set.

See Also:
Constant Field Values
Constructor Detail

PropertyUtil

public PropertyUtil()
Method Detail

whereSet

static int whereSet(java.lang.String key,
                    java.util.Dictionary set)

isDBOnly

public static boolean isDBOnly(java.util.Dictionary set)

isDBOnly

public static boolean isDBOnly(java.util.Properties set)

getSystemProperty

public static java.lang.String getSystemProperty(java.lang.String key)
Find a system wide property. Search order is

Returns:
the value of the property or null if it does not exist.

getSystemProperty

public static java.lang.String getSystemProperty(java.lang.String key,
                                                 java.lang.String defaultValue)
Find a system wide property with a default. Search order is
  1. JVM property
  2. derby.properties

This method can be used by a system that is not running Cloudscape, just to maintain the same lookup logic and security manager concerns for finding derby.properties and reading system properties.

Returns:
the value of the property or defaultValue if it does not exist.

getPropertyFromSet

public static java.lang.String getPropertyFromSet(java.util.Properties set,
                                                  java.lang.String key)
Get a property from the passed in set. The passed in set is either:
This method uses the same search order as the getService() calls.


getPropertyFromSet

public static java.io.Serializable getPropertyFromSet(java.util.Dictionary set,
                                                      java.lang.String key)

getPropertyFromSet

public static java.io.Serializable getPropertyFromSet(boolean dbOnly,
                                                      java.util.Dictionary set,
                                                      java.lang.String key)

getPropertyFromSet

public static java.lang.String getPropertyFromSet(boolean dbOnly,
                                                  java.util.Properties set,
                                                  java.lang.String key)

getDatabaseProperty

public static java.lang.String getDatabaseProperty(PersistentSet set,
                                                   java.lang.String key)
                                            throws StandardException
Get a property only looking in the Persistent Transactional (database) set.

Throws:
StandardException - Standard Cloudscape error handling.

getServiceProperty

public static java.lang.String getServiceProperty(PersistentSet set,
                                                  java.lang.String key,
                                                  java.lang.String defaultValue)
                                           throws StandardException
Find a service wide property with a default. Search order is The service is the persistent service associated with the current context stack.

Returns:
the value of the property or defaultValue if it does not exist.
Throws:
StandardException - Standard Cloudscape error handling.

getServiceProperty

public static java.lang.String getServiceProperty(PersistentSet set,
                                                  java.lang.String key)
                                           throws StandardException
Find a service wide property. The service is the persistent service associated with the current context stack.

Returns:
the value of the property or null if it does not exist.
Throws:
StandardException - Standard Cloudscape error handling.

getSystemBoolean

public static boolean getSystemBoolean(java.lang.String key)
Get a system wide property as a boolean.

Returns:
true of the property is set to 'true, TRUE', false otherwise

getServiceBoolean

public static boolean getServiceBoolean(PersistentSet set,
                                        java.lang.String key,
                                        boolean defValue)
                                 throws StandardException
Get a service wide property as a boolean.

Returns:
true of the property is set to 'true, TRUE', false otherwise
Throws:
StandardException - Standard Cloudscape error handling.

getSystemInt

public static int getSystemInt(java.lang.String key,
                               int min,
                               int max,
                               int defaultValue)
s Get a system wide property as a int.

Returns:
value of the property if set subject to min and max, defaultValue if it is not set or set to a non-integer value.

getServiceInt

public static int getServiceInt(PersistentSet set,
                                java.lang.String key,
                                int min,
                                int max,
                                int defaultValue)
                         throws StandardException
Get a service wide property as a int.

Returns:
value of the property if set subject to min and max, defaultValue if it is not set or set to a non-integer value.
Throws:
StandardException - Standard Cloudscape error handling.

getServiceInt

public static int getServiceInt(PersistentSet set,
                                java.util.Properties props,
                                java.lang.String key,
                                int min,
                                int max,
                                int defaultValue)
                         throws StandardException
Get a service wide property as a int. The passed in Properties set overrides any system, applcation or per-database properties.

Returns:
value of the property if set subject to min and max, defaultValue if it is not set or set to a non-integer value.
Throws:
StandardException - Standard Cloudscape error handling.

getSystemInt

public static int getSystemInt(java.lang.String key,
                               int defaultValue)
Get a system wide property as a int.

Returns:
value of the property if, defaultValue if it is not set or set to a non-integer value.

handleInt

public static int handleInt(java.lang.String value,
                            int min,
                            int max,
                            int defaultValue)
Parse an string as an int based property value.


booleanProperty

public static boolean booleanProperty(java.lang.String p,
                                      java.io.Serializable v,
                                      boolean defaultValue)
                               throws StandardException
Parse and validate and return a boolean property value. If the value is invalid raise an exception.

The following are valid property values.

Throws:
StandardException - Oops

intPropertyValue

public static int intPropertyValue(java.lang.String p,
                                   java.io.Serializable v,
                                   int minValue,
                                   int maxValue,
                                   int defaultValue)
                            throws StandardException
Parse, validate and return an integer property value. If the value is invalid raise an exception. If the value passed in is null return a default value.

Throws:
StandardException - Oops

isServiceProperty

public static boolean isServiceProperty(java.lang.String key)
Return true iff the key is the name of a database property that is stored in services.properties.


Built on Tue 2006-10-10 19:23:47+0200, from revision exported

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.