ERXProperties Class Reference

Inherits java::util::Properties, and com::webobjects::foundation::NSKeyValueCoding.

Collaboration diagram for ERXProperties:

Collaboration graph
[legend]

List of all members.

Classes

class  _Properties
class  EncryptedOperator
class  InRangeOperator
interface  Operator
class  Property

Public Member Functions

String getProperty (String key)
void takeValueForKey (Object anObject, String aKey)
Object toExternalForm () throws IOException
Object valueForKey (String aKey)

Static Public Member Functions

static NSArray< PropertyallProperties ()
static Map< String, StringallPropertiesMap (boolean protectValues)
static String applicationDeveloperProperties ()
static String applicationMachinePropertiesPath (String fileName)
static String applicationUserProperties ()
static Properties applyConfiguration (Properties source, Properties commandLine)
static NSArray arrayForKey (String s)
static NSArray arrayForKeyWithDefault (final String s, final NSArray defaultValue)
static BigDecimal bigDecimalForKey (String s)
static BigDecimal bigDecimalForKeyWithDefault (String s, BigDecimal defaultValue)
static boolean booleanForKey (String s)
static boolean booleanForKeyWithDefault (final String s, final boolean defaultValue)
static NSArray< StringcomponentsSeparatedByString (String key, String separator)
static NSArray< StringcomponentsSeparatedByStringWithDefault (String key, String separator, NSArray< String > defaultValue)
static String decryptedStringForKey (String propertyName)
static String decryptedStringForKeyWithDefault (String propertyName, String defaultValue)
static String decryptedStringForKeyWithEncryptedDefault (String propertyName, String defaultValue)
static NSDictionary dictionaryForKey (String s)
static NSDictionary dictionaryForKeyWithDefault (final String s, final NSDictionary defaultValue)
static double doubleForKey (String s)
static double doubleForKeyWithDefault (final String s, final double defaultValue)
static void evaluatePropertyOperators (Properties originalProperties, Properties destinationProperties)
static float floatForKey (String s)
static float floatForKeyWithDefault (final String s, final float defaultValue)
static ERXProperties fromExternalForm (String string)
static String getActualPath (String path)
static int intForKey (String s)
static int intForKeyWithDefault (final String s, final int defaultValue)
static String logString (Properties properties)
static long longForKey (String s)
static long longForKeyWithDefault (final String s, final long defaultValue)
static NSArray optionalConfigurationFiles ()
static String pathForPropertiesUnderProjectPath (String projectPath)
static NSArray pathsForUserAndBundleProperties (boolean reportLoggingEnabled)
static NSArray pathsForUserAndBundleProperties ()
static void populateSystemProperties ()
static Properties propertiesFromArgv (String[] argv)
static Properties propertiesFromFile (File file) throws java.io.IOException
static Properties propertiesFromPath (String path)
static Map< String, StringpropertiesMap (Properties properties, boolean protectValues)
static void removeKey (String key)
static void setArrayForKey (NSArray array, String key)
static void setCommandLineArguments (String[] argv)
static void setDictionaryForKey (NSDictionary dictionary, String key)
static void setOperatorForKey (ERXProperties.Operator operator, String key)
static void setStringForKey (String string, String key)
static String sourceVersionString ()
static String stringForKey (String s)
static String stringForKeyWithDefault (final String s, final String defaultValue)
static void systemPropertiesChanged ()
static void transferPropertiesFromSourceToDest (Properties source, Properties dest)
static String variantPropertiesInBundle (String userName, String bundleName)
static String versionStringForApplication ()
static String versionStringForFrameworkNamed (String frameworkName)
static String webObjectsVersion ()
static double webObjectsVersionAsDouble ()
static boolean webObjectsVersionIs522OrHigher ()
static boolean webObjectsVersionIs52OrHigher ()

Static Public Attributes

static final String DefaultString = "Default"
static final Logger log = Logger.getLogger(ERXProperties.class)

Protected Member Functions

String applicationNameForAppending ()

Protected Attributes

String applicationNameForAppending

Static Private Member Functions

static void addIfPresent (String info, String path, NSMutableArray< String > propertiesPaths, NSMutableArray< String > projectsInfo)
static String getApplicationSpecificPropertyName (final String propertyName)
static boolean retainDefaultsEnabled ()

Static Private Attributes

static Map _cache = Collections.synchronizedMap(new HashMap())
static String _webObjectsVersion
static double _webObjectsVersionDouble
static final Map AppSpecificPropertyNames = new HashMap(128)
static final
NSMutableDictionary< String,
ERXProperties.Operator > 
operators = new NSMutableDictionary<String, ERXProperties.Operator>()
static Boolean RetainDefaultsEnabled
static String UndefinedMarker = "-undefined-"


Member Function Documentation

static void addIfPresent ( String  info,
String  path,
NSMutableArray< String propertiesPaths,
NSMutableArray< String projectsInfo 
) [static, private]

static NSArray<Property> allProperties (  )  [static]

static Map<String, String> allPropertiesMap ( boolean  protectValues  )  [static]

Returns all of the properties in the system mapped to their evaluated values, sorted by key.

Parameters:
protectValues if true, keys with the word "password" in them will have their values removed
Returns:
all of the properties in the system mapped to their evaluated values, sorted by key

static String applicationDeveloperProperties (  )  [static]

Returns the application-specific user properties.

static String applicationMachinePropertiesPath ( String  fileName  )  [static]

Returns the path to the application-specific system-wide file "fileName". By default this path is /etc/WebObjects, and the application name will be appended. For instance, if you are asking for the MyApp Properties file for the system, it would go in /etc/WebObjects/MyApp/Properties.

Returns:
the path, or null if the path does not exist

String applicationNameForAppending (  )  [protected]

Caches the application name for appending to the key. Note that for a period when the application is starting up application() will be null and name() will be null.

Returns:
application name used for appending, for example ".ERMailer" Note: this is redundant with the scheme checked in on March 21, 2005 by clloyd (ben holt did checkin). This scheme requires the user to swizzle the existing properties file with a new one of this type.

static String applicationUserProperties (  )  [static]

Returns the application-specific user properties.

static Properties applyConfiguration ( Properties  source,
Properties  commandLine 
) [static]

Apply the current configuration to the supplied properties.

Parameters:
source 
commandLine 

static NSArray arrayForKey ( String  s  )  [static]

Cover method for returning an NSArray for a given system property.

Parameters:
s system property
Returns:
array de-serialized from the string in the system properties

static NSArray arrayForKeyWithDefault ( final String  s,
final NSArray  defaultValue 
) [static]

Cover method for returning an NSArray for a given system property and set a default value if not given.

Parameters:
s system property
defaultValue default value
Returns:
array de-serialized from the string in the system properties or default value

static BigDecimal bigDecimalForKey ( String  s  )  [static]

Cover method for returning a BigDecimal for a given system property. This method uses the method bigDecimalValueWithDefault from ERXValueUtilities.

Parameters:
s system property
Returns:
bigDecimal value of the string in the system properties. Scale is controlled by the string, ie "4.400" will have a scale of 3.

static BigDecimal bigDecimalForKeyWithDefault ( String  s,
BigDecimal  defaultValue 
) [static]

Cover method for returning a BigDecimal for a given system property or a default value. This method uses the method bigDecimalValueWithDefault from ERXValueUtilities.

Parameters:
s system property
defaultValue default value
Returns:
BigDecimal value of the string in the system properties. Scale is controlled by the string, ie "4.400" will have a scale of 3.

static boolean booleanForKey ( String  s  )  [static]

Cover method for returning a boolean for a given system property. This method uses the method booleanValue from ERXUtilities.

Parameters:
s system property
Returns:
boolean value of the string in the system properties.

static boolean booleanForKeyWithDefault ( final String  s,
final boolean  defaultValue 
) [static]

Cover method for returning a boolean for a given system property or a default value. This method uses the method booleanValue from ERXUtilities.

Parameters:
s system property
defaultValue default value
Returns:
boolean value of the string in the system properties.

static NSArray<String> componentsSeparatedByString ( String  key,
String  separator 
) [static]

Returns an array of strings separated with the given separator string.

Parameters:
key the key to lookup
separator the separator (",")
Returns:
the array of strings or NSArray.EmptyArray if not found

static NSArray<String> componentsSeparatedByStringWithDefault ( String  key,
String  separator,
NSArray< String defaultValue 
) [static]

Returns an array of strings separated with the given separator string.

Parameters:
key the key to lookup
separator the separator (",")
defaultValue the default array to return if there is no value
Returns:
the array of strings

static String decryptedStringForKey ( String  propertyName  )  [static]

Returns the decrypted value for the given property name using the default crypter if the property propertyName.encrypted=true. For instance, if you are requesting my.password, if my.password.encrypted=true the value of my.password will be passed to the default crypter's decrypt method.

Parameters:
propertyName the property name to retrieve and optionally decrypt
Returns:
the decrypted property value

static String decryptedStringForKeyWithDefault ( String  propertyName,
String  defaultValue 
) [static]

If the propertyName.encrypted property is set to true, returns the plain text value of the given property name, after decrypting it with the ERXCrypto.defaultCrypter. For instance, if you are requesting my.password and my.password.encrypted is set to true, the value of my.password will be sent to the default crypter's decrypt() method.

Parameters:
propertyName the property name to retrieve and optionally decrypt
defaultValue the default value to return if there is no password
Returns:
the decrypted property value

static String decryptedStringForKeyWithEncryptedDefault ( String  propertyName,
String  defaultValue 
) [static]

Returns the decrypted value for the given property name using the ERXCrypto.defaultCrypter. This is slightly different than decryptedStringWithKeyWithDefault in that it does not require the encrypted property to be set.

Parameters:
propertyName the name of the property to decrypt
defaultValue the default encrypted value
Returns:
the decrypted value

static NSDictionary dictionaryForKey ( String  s  )  [static]

Cover method for returning an NSDictionary for a given system property.

Parameters:
s system property
Returns:
dictionary de-serialized from the string in the system properties

static NSDictionary dictionaryForKeyWithDefault ( final String  s,
final NSDictionary  defaultValue 
) [static]

Cover method for returning an NSDictionary for a given system property or the default value.

Parameters:
s system property
defaultValue default value
Returns:
dictionary de-serialized from the string in the system properties

static double doubleForKey ( String  s  )  [static]

Cover method for returning a double for a given system property.

Parameters:
s system property
Returns:
double value of the system property or 0

static double doubleForKeyWithDefault ( final String  s,
final double  defaultValue 
) [static]

Cover method for returning a double for a given system property with a default value.

Parameters:
s system property
defaultValue default value
Returns:
double value of the system property or the default value

static void evaluatePropertyOperators ( Properties  originalProperties,
Properties  destinationProperties 
) [static]

For each property in originalProperties, process the keys and avlues with the registered property operators and stores the converted value into destinationProperties.

Parameters:
originalProperties the properties to convert
destinationProperties the properties to copy into

static float floatForKey ( String  s  )  [static]

Cover method for returning a float for a given system property.

Parameters:
s system property
Returns:
float value of the system property or 0

static float floatForKeyWithDefault ( final String  s,
final float  defaultValue 
) [static]

Cover method for returning a float for a given system property with a default value.

Parameters:
s system property
defaultValue default value
Returns:
float value of the system property or the default value

static ERXProperties fromExternalForm ( String  string  )  [static]

Load the properties from a String in Property file format. Useful when you use them as custom value types, you would set this as the factory method name.

Parameters:
string 

static String getActualPath ( String  path  )  [static]

Returns actual full path to the given file system path that could contain symbolic links. For example: /Resources will be converted to /Versions/A/Resources when /Resources is a symbolic link.

Parameters:
path path string to a resource that could contain symbolic links
Returns:
actual path to the resource

static String getApplicationSpecificPropertyName ( final String  propertyName  )  [static, private]

Converts the standard propertyName into one with a .<AppName> on the end, if the property is defined with that suffix. If not, then this caches the standard propertyName. A cache is maintained to avoid concatenating strings frequently, but may be overkill since most usage of this system doesn't involve frequent access.

Parameters:
propertyName 

String getProperty ( String  key  ) 

Overriding the default getProperty method to first check: key.<ApplicationName> before checking for key. If nothing is found then key.Default is checked.

Parameters:
key to check
Returns:
property value

static int intForKey ( String  s  )  [static]

Cover method for returning an int for a given system property.

Parameters:
s system property
Returns:
int value of the system property or 0

static int intForKeyWithDefault ( final String  s,
final int  defaultValue 
) [static]

Cover method for returning an int for a given system property with a default value.

Parameters:
s system property
defaultValue default value
Returns:
int value of the system property or the default value

static String logString ( Properties  properties  )  [static]

Returns a string suitable for logging.

Parameters:
properties 

static long longForKey ( String  s  )  [static]

Cover method for returning a long for a given system property.

Parameters:
s system property
Returns:
long value of the system property or 0

static long longForKeyWithDefault ( final String  s,
final long  defaultValue 
) [static]

Cover method for returning a long for a given system property with a default value.

Parameters:
s system property
defaultValue default value
Returns:
long value of the system property or the default value

static NSArray optionalConfigurationFiles (  )  [static]

Gets an array of optionally defined configuration files. For each file, if it does not exist as an absolute path, ERXProperties will attempt to resolve it as an application resource and use that instead.

Returns:
array of configuration file names

static String pathForPropertiesUnderProjectPath ( String  projectPath  )  [static]

Returns the full path to the Properties file under the given project path. At the current implementation, it looks for /Properties and /Resources/Properties. If the Properties file doesn't exist, returns null.

Parameters:
projectPath string to the project root directory
Returns:
the path to the Properties file if it exists

static NSArray pathsForUserAndBundleProperties ( boolean  reportLoggingEnabled  )  [static]

Properties.dev -- per-Framework-dev properties This adds support for Properties.dev in your Frameworks new load order will be

Properties.<userName> -- per-Framework-per-User properties

/etc/WebObjects/AppName/Properties -- per-Application-per-Machine properties

Properties.dev -- per-Application-dev properties

Properties.<userName> -- per-Application-per-User properties

static NSArray pathsForUserAndBundleProperties (  )  [static]

Returns an array of paths to the Properties and WebObjects.properties files contained in the application/framework bundles and home directory.

If ProjectBuilder (for Mac OS X) has the project opened, it will attempt to get the path to the one in the project directory instead of the one in the bundle.

This opened project detection feature is pretty fragile and will change between versions of the dev-tools.

Returns:
paths to Properties files

static void populateSystemProperties (  )  [static]

Puts handy properties such as com.webobjects.version into the system properties. This method is called when the framework is initialized (when WOApplication.ApplicationWillFinishLaunchingNotification is posted.)

static Properties propertiesFromArgv ( String[]  argv  )  [static]

Sets and returns properties object with the values from the given command line arguments string array.

Parameters:
argv string array typically provided by the command line arguments
Returns:
properties object with the values from the argv

static Properties propertiesFromFile ( File  file  )  throws java.io.IOException [static]

Gets the properties for a given file.

Parameters:
file the properties file
Returns:
properties from the given file
Exceptions:
java.io.IOException if the file is not found or cannot be read

static Properties propertiesFromPath ( String  path  )  [static]

Reads a Java properties file at the given path and returns a Properties object as the result. If the file does not exist, returns an empty properties object.

Parameters:
path file path to the properties file
Returns:
properties object with the values from the file specified.

static Map<String, String> propertiesMap ( Properties  properties,
boolean  protectValues 
) [static]

Returns all of the properties in the system mapped to their evaluated values, sorted by key.

Parameters:
protectValues if true, keys with the word "password" in them will have their values removed
Returns:
all of the properties in the system mapped to their evaluated values, sorted by key

static void removeKey ( String  key  )  [static]

static boolean retainDefaultsEnabled (  )  [static, private]

static void setArrayForKey ( NSArray  array,
String  key 
) [static]

Sets an array in the System properties for a particular key.

Parameters:
array to be set in the System properties
key to be used to get the value

static void setCommandLineArguments ( String[]  argv  )  [static]

static void setDictionaryForKey ( NSDictionary  dictionary,
String  key 
) [static]

Sets a dictionary in the System properties for a particular key.

Parameters:
dictionary to be set in the System properties
key to be used to get the value

static void setOperatorForKey ( ERXProperties.Operator  operator,
String  key 
) [static]

Registers a property operator for a particular key.

Parameters:
operator the operator to register
key the key name of the operator

static void setStringForKey ( String  string,
String  key 
) [static]

Sets a string in the System properties for another string.

Parameters:
string to be set in the System properties
key to be used to get the value

static String sourceVersionString (  )  [static]

Returns the version string of the given framework. It checks SourceVersion property in the version.plist resource and returns a trimmed version of the value.

Returns:
version number as string; can be null-string when the framework is not found or the framework doesn't have the value of SourceVersion in its info.plist resource.
See also:
versionStringForApplication

webObjectsVersion

static String stringForKey ( String  s  )  [static]

Returning an string for a given system property. This is a cover method of java.lang.System#getProperty

Parameters:
s system property
Returns:
string value of the system propery or null

static String stringForKeyWithDefault ( final String  s,
final String  defaultValue 
) [static]

Returning an string for a given system property. This is a cover method of java.lang.System#getProperty

Parameters:
s system property
Returns:
string value of the system propery or null

static void systemPropertiesChanged (  )  [static]

void takeValueForKey ( Object  anObject,
String  aKey 
)

KVC implementation.

Parameters:
anObject 
aKey 

Object toExternalForm (  )  throws IOException

Returns the properties as a String in Property file format. Useful when you use them as custom value types, you would set this as the conversion method name.

Exceptions:
IOException 

static void transferPropertiesFromSourceToDest ( Properties  source,
Properties  dest 
) [static]

Copies all properties from source to dest.

Parameters:
source properties copied from
dest properties copied to

Object valueForKey ( String  aKey  ) 

KVC implementation.

Parameters:
aKey 

static String variantPropertiesInBundle ( String  userName,
String  bundleName 
) [static]

Returns the application-specific variant properties for the given bundle.

static String versionStringForApplication (  )  [static]

Returns the version string of the application. It checks CFBundleShortVersionString property in the info.plist resource and returns a trimmed version of the value.

Returns:
version number as string; can be a null-string when the applicaiton doesn't have the value of CFBundleShortVersionString in its info.plist resource.
See also:
versionStringForFrameworkNamed

webObjectsVersion

static String versionStringForFrameworkNamed ( String  frameworkName  )  [static]

Returns the version string of the given framework. It checks CFBundleShortVersionString property in the info.plist resource and returns a trimmed version of the value.

Parameters:
frameworkName name
Returns:
version number as string; can be null-string when the framework is not found or the framework doesn't have the value of CFBundleShortVersionString in its info.plist resource.
See also:
versionStringForApplication

webObjectsVersion

ERXStringUtilities.removeExtraDotsFromVersionString

static String webObjectsVersion (  )  [static]

Returns WebObjects version as string. If it's one of those version 5.1s (5.1, 5.1.1, 5.1.2...), this method will only return 5.1. If it's 5.2s, this mothod will return more precise version numbers such as 5.2.1. Note that version 5.0 series is not supported and may return incorrect version numbers (it will return 5.1).

Returns:
WebObjects version number as string
See also:
webObjectsVersionAsDouble

ERXStringUtilities.removeExtraDotsFromVersionString

static double webObjectsVersionAsDouble (  )  [static]

Returns WebObjects version as double. If it's one of those version 5.1s (5.1, 5.1.1, 5.1.2...), this method will only return 5.1. If it's 5.2s, this mothod will return more precise version numbers such as 5.2.1. Note that version 5.0 series is not supported and may return incorrect version numbers (it will return 5.1).

Returns:
WebObjects version number as double
See also:
webObjectsVersion

static boolean webObjectsVersionIs522OrHigher (  )  [static]

Quick convience method used to determine if the current webobjects version is 5.22 or higher.

Returns:
if the version of webobjects is 5.22 or better

static boolean webObjectsVersionIs52OrHigher (  )  [static]

Quick convience method used to determine if the current webobjects version is 5.2 or higher.

Returns:
if the version of webobjects is 5.2 or better


Member Data Documentation

Map _cache = Collections.synchronizedMap(new HashMap()) [static, private]

Internal cache of type converted values to avoid reconverting attributes that are asked for frequently

String _webObjectsVersion [static, private]

WebObjects version number as string

double _webObjectsVersionDouble [static, private]

WebObjects version number as double

caches the application name that is appended to the key for lookup

final Map AppSpecificPropertyNames = new HashMap(128) [static, private]

final String DefaultString = "Default" [static]

default string

final Logger log = Logger.getLogger(ERXProperties.class) [static]

logging support

final NSMutableDictionary<String, ERXProperties.Operator> operators = new NSMutableDictionary<String, ERXProperties.Operator>() [static, private]

Stores the mapping between operator keys and operators

Boolean RetainDefaultsEnabled [static, private]

String UndefinedMarker = "-undefined-" [static, private]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:13 2012 for Project Wonder by  doxygen 1.5.8