|
Project Wonder 5.0 | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Dictionary<K,V>
java.util.Hashtable<java.lang.Object,java.lang.Object>
java.util.Properties
er.extensions.foundation.ERXProperties
public class ERXProperties
Collection of simple utility methods used to get and set properties
in the system properties. The only reason this class is needed is
because all of the methods in NSProperties have been deprecated.
This is a wee bit annoying. The usual method is to have a method
like getBoolean
off of Boolean which would resolve
the System property as a Boolean object.
Properties can be set in all the following places:
Properties | |
er.extensions.ERXProperties.RetainDefaultsEnabled | er.extensions.ERXProperties.RetainDefaultsEnabled |
Nested Class Summary | |
---|---|
static class |
ERXProperties._Properties
_Properties is a subclass of Properties that provides support for including other Properties files on the fly. |
static class |
ERXProperties.EncryptedOperator
Encrypted operator supports decrypting values using the default crypter. |
static class |
ERXProperties.InRangeOperator
InRangeOperator provides support for defining properties that only get set if a value falls within a specific range of values. |
static interface |
ERXProperties.Operator
Property operators work like array operators. |
static class |
ERXProperties.Property
|
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding |
---|
com.webobjects.foundation.NSKeyValueCoding._BooleanFieldBinding, com.webobjects.foundation.NSKeyValueCoding._BooleanMethodBinding, com.webobjects.foundation.NSKeyValueCoding._FieldBinding, com.webobjects.foundation.NSKeyValueCoding._ForwardingBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding._MethodBinding, com.webobjects.foundation.NSKeyValueCoding._NumberFieldBinding, com.webobjects.foundation.NSKeyValueCoding._NumberMethodBinding, com.webobjects.foundation.NSKeyValueCoding._ReflectionKeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding.DefaultImplementation, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCoding.Null, com.webobjects.foundation.NSKeyValueCoding.UnknownKeyException, com.webobjects.foundation.NSKeyValueCoding.Utility, com.webobjects.foundation.NSKeyValueCoding.ValueAccessor |
Field Summary | |
---|---|
protected java.lang.String |
applicationNameForAppending
caches the application name that is appended to the key for lookup |
static java.lang.String |
DefaultString
default string |
static org.apache.log4j.Logger |
log
logging support |
Fields inherited from class java.util.Properties |
---|
defaults |
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding |
---|
_CLASS, NullValue |
Constructor Summary | |
---|---|
ERXProperties()
|
Method Summary | |
---|---|
static com.webobjects.foundation.NSArray<ERXProperties.Property> |
allProperties()
|
static java.util.Map<java.lang.String,java.lang.String> |
allPropertiesMap(boolean protectValues)
Returns all of the properties in the system mapped to their evaluated values, sorted by key. |
static java.lang.String |
applicationDeveloperProperties()
Returns the application-specific user properties. |
static java.lang.String |
applicationMachinePropertiesPath(java.lang.String fileName)
Returns the path to the application-specific system-wide file "fileName". |
protected java.lang.String |
applicationNameForAppending()
Caches the application name for appending to the key. |
static java.lang.String |
applicationUserProperties()
Returns the application-specific user properties. |
static java.util.Properties |
applyConfiguration(java.util.Properties source,
java.util.Properties commandLine)
Apply the current configuration to the supplied properties. |
static com.webobjects.foundation.NSArray |
arrayForKey(java.lang.String s)
Cover method for returning an NSArray for a given system property. |
static com.webobjects.foundation.NSArray |
arrayForKeyWithDefault(java.lang.String s,
com.webobjects.foundation.NSArray defaultValue)
Cover method for returning an NSArray for a given system property and set a default value if not given. |
static java.math.BigDecimal |
bigDecimalForKey(java.lang.String s)
Cover method for returning a BigDecimal for a given system property. |
static java.math.BigDecimal |
bigDecimalForKeyWithDefault(java.lang.String s,
java.math.BigDecimal defaultValue)
Cover method for returning a BigDecimal for a given system property or a default value. |
static boolean |
booleanForKey(java.lang.String s)
Cover method for returning a boolean for a given system property. |
static boolean |
booleanForKeyWithDefault(java.lang.String s,
boolean defaultValue)
Cover method for returning a boolean for a given system property or a default value. |
static com.webobjects.foundation.NSArray<java.lang.String> |
componentsSeparatedByString(java.lang.String key,
java.lang.String separator)
Returns an array of strings separated with the given separator string. |
static com.webobjects.foundation.NSArray<java.lang.String> |
componentsSeparatedByStringWithDefault(java.lang.String key,
java.lang.String separator,
com.webobjects.foundation.NSArray<java.lang.String> defaultValue)
Returns an array of strings separated with the given separator string. |
static java.lang.String |
decryptedStringForKey(java.lang.String propertyName)
Returns the decrypted value for the given property name using the default crypter if the property propertyName.encrypted=true. |
static java.lang.String |
decryptedStringForKeyWithDefault(java.lang.String propertyName,
java.lang.String defaultValue)
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 . |
static java.lang.String |
decryptedStringForKeyWithEncryptedDefault(java.lang.String propertyName,
java.lang.String defaultValue)
Returns the decrypted value for the given property name using the ERXCrypto.defaultCrypter . |
static com.webobjects.foundation.NSDictionary |
dictionaryForKey(java.lang.String s)
Cover method for returning an NSDictionary for a given system property. |
static com.webobjects.foundation.NSDictionary |
dictionaryForKeyWithDefault(java.lang.String s,
com.webobjects.foundation.NSDictionary defaultValue)
Cover method for returning an NSDictionary for a given system property or the default value. |
static double |
doubleForKey(java.lang.String s)
Cover method for returning a double for a given system property. |
static double |
doubleForKeyWithDefault(java.lang.String s,
double defaultValue)
Cover method for returning a double for a given system property with a default value. |
static void |
evaluatePropertyOperators(java.util.Properties originalProperties,
java.util.Properties destinationProperties)
For each property in originalProperties, process the keys and avlues with the registered property operators and stores the converted value into destinationProperties. |
static float |
floatForKey(java.lang.String s)
Cover method for returning a float for a given system property. |
static float |
floatForKeyWithDefault(java.lang.String s,
float defaultValue)
Cover method for returning a float for a given system property with a default value. |
static ERXProperties |
fromExternalForm(java.lang.String string)
Load the properties from a String in Property file format. |
static java.lang.String |
getActualPath(java.lang.String path)
Returns actual full path to the given file system path that could contain symbolic links. |
java.lang.String |
getProperty(java.lang.String key)
Overriding the default getProperty method to first check: key.<ApplicationName> before checking for key. |
static int |
intForKey(java.lang.String s)
Cover method for returning an int for a given system property. |
static int |
intForKeyWithDefault(java.lang.String s,
int defaultValue)
Cover method for returning an int for a given system property with a default value. |
static java.lang.String |
logString(java.util.Properties properties)
Returns a string suitable for logging. |
static long |
longForKey(java.lang.String s)
Cover method for returning a long for a given system property. |
static long |
longForKeyWithDefault(java.lang.String s,
long defaultValue)
Cover method for returning a long for a given system property with a default value. |
static com.webobjects.foundation.NSArray |
optionalConfigurationFiles()
Gets an array of optionally defined configuration files. |
static java.lang.String |
pathForPropertiesUnderProjectPath(java.lang.String projectPath)
Returns the full path to the Properties file under the given project path. |
static com.webobjects.foundation.NSArray |
pathsForUserAndBundleProperties()
Returns an array of paths to the Properties and
WebObjects.properties files contained in the
application/framework bundles and home directory. |
static com.webobjects.foundation.NSArray |
pathsForUserAndBundleProperties(boolean reportLoggingEnabled)
|
static void |
populateSystemProperties()
Puts handy properties such as com.webobjects.version
into the system properties. |
static java.util.Properties |
propertiesFromArgv(java.lang.String[] argv)
Sets and returns properties object with the values from the given command line arguments string array. |
static java.util.Properties |
propertiesFromFile(java.io.File file)
Gets the properties for a given file. |
static java.util.Properties |
propertiesFromPath(java.lang.String path)
Reads a Java properties file at the given path and returns a Properties object
as the result. |
static java.util.Map<java.lang.String,java.lang.String> |
propertiesMap(java.util.Properties properties,
boolean protectValues)
Returns all of the properties in the system mapped to their evaluated values, sorted by key. |
static void |
removeKey(java.lang.String key)
|
static void |
setArrayForKey(com.webobjects.foundation.NSArray array,
java.lang.String key)
Sets an array in the System properties for a particular key. |
static void |
setCommandLineArguments(java.lang.String[] argv)
|
static void |
setDictionaryForKey(com.webobjects.foundation.NSDictionary dictionary,
java.lang.String key)
Sets a dictionary in the System properties for a particular key. |
static void |
setOperatorForKey(ERXProperties.Operator operator,
java.lang.String key)
Registers a property operator for a particular key. |
static void |
setStringForKey(java.lang.String string,
java.lang.String key)
Sets a string in the System properties for another string. |
static java.lang.String |
sourceVersionString()
Returns the version string of the given framework. |
static java.lang.String |
stringForKey(java.lang.String s)
Returning an string for a given system property. |
static java.lang.String |
stringForKeyWithDefault(java.lang.String s,
java.lang.String defaultValue)
Returning an string for a given system property. |
static void |
systemPropertiesChanged()
|
void |
takeValueForKey(java.lang.Object anObject,
java.lang.String aKey)
KVC implementation. |
java.lang.Object |
toExternalForm()
Returns the properties as a String in Property file format. |
static void |
transferPropertiesFromSourceToDest(java.util.Properties source,
java.util.Properties dest)
Copies all properties from source to dest. |
java.lang.Object |
valueForKey(java.lang.String aKey)
KVC implementation. |
static java.lang.String |
variantPropertiesInBundle(java.lang.String userName,
java.lang.String bundleName)
Returns the application-specific variant properties for the given bundle. |
static java.lang.String |
versionStringForApplication()
Returns the version string of the application. |
static java.lang.String |
versionStringForFrameworkNamed(java.lang.String frameworkName)
Returns the version string of the given framework. |
static java.lang.String |
webObjectsVersion()
Returns WebObjects version as string. |
static double |
webObjectsVersionAsDouble()
Returns WebObjects version as double. |
static boolean |
webObjectsVersionIs522OrHigher()
Quick convience method used to determine if the current webobjects version is 5.22 or higher. |
static boolean |
webObjectsVersionIs52OrHigher()
Quick convience method used to determine if the current webobjects version is 5.2 or higher. |
Methods inherited from class java.util.Properties |
---|
getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames |
Methods inherited from class java.util.Hashtable |
---|
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DefaultString
public static final org.apache.log4j.Logger log
protected java.lang.String applicationNameForAppending
Constructor Detail |
---|
public ERXProperties()
Method Detail |
---|
public static void populateSystemProperties()
com.webobjects.version
into the system properties. This method is called when
the framework is initialized
(when WOApplication.ApplicationWillFinishLaunchingNotification
is posted.)
public static java.lang.String versionStringForApplication()
CFBundleShortVersionString
property
in the info.plist
resource and returns
a trimmed version of the value.
CFBundleShortVersionString
in its info.plist
resource.versionStringForFrameworkNamed(java.lang.String)
,
webObjectsVersion()
public static java.lang.String versionStringForFrameworkNamed(java.lang.String frameworkName)
CFBundleShortVersionString
property
in the info.plist
resource and returns
a trimmed version of the value.
frameworkName
- name
CFBundleShortVersionString
in its
info.plist
resource.versionStringForApplication()
,
webObjectsVersion()
,
ERXStringUtilities#removeExtraDotsFromVersionString
public static java.lang.String sourceVersionString()
SourceVersion
property
in the version.plist
resource and returns
a trimmed version of the value.
SourceVersion
in its
info.plist
resource.versionStringForApplication()
,
webObjectsVersion()
public static java.lang.String webObjectsVersion()
webObjectsVersionAsDouble()
,
ERXStringUtilities#removeExtraDotsFromVersionString
public static double webObjectsVersionAsDouble()
webObjectsVersion()
public static boolean webObjectsVersionIs52OrHigher()
public static boolean webObjectsVersionIs522OrHigher()
public static com.webobjects.foundation.NSArray arrayForKey(java.lang.String s)
s
- system property
public static com.webobjects.foundation.NSArray arrayForKeyWithDefault(java.lang.String s, com.webobjects.foundation.NSArray defaultValue)
s
- system propertydefaultValue
- default value
public static boolean booleanForKey(java.lang.String s)
booleanValue
from
ERXUtilities
.
s
- system property
public static boolean booleanForKeyWithDefault(java.lang.String s, boolean defaultValue)
booleanValue
from
ERXUtilities
.
s
- system propertydefaultValue
- default value
public static com.webobjects.foundation.NSDictionary dictionaryForKey(java.lang.String s)
s
- system property
public static com.webobjects.foundation.NSDictionary dictionaryForKeyWithDefault(java.lang.String s, com.webobjects.foundation.NSDictionary defaultValue)
s
- system propertydefaultValue
- default value
public static int intForKey(java.lang.String s)
s
- system property
public static long longForKey(java.lang.String s)
s
- system property
public static float floatForKey(java.lang.String s)
s
- system property
public static double doubleForKey(java.lang.String s)
s
- system property
public static java.math.BigDecimal bigDecimalForKey(java.lang.String s)
bigDecimalValueWithDefault
from
ERXValueUtilities
.
s
- system property
public static java.math.BigDecimal bigDecimalForKeyWithDefault(java.lang.String s, java.math.BigDecimal defaultValue)
bigDecimalValueWithDefault
from
ERXValueUtilities
.
s
- system propertydefaultValue
- default value
public static int intForKeyWithDefault(java.lang.String s, int defaultValue)
s
- system propertydefaultValue
- default value
public static long longForKeyWithDefault(java.lang.String s, long defaultValue)
s
- system propertydefaultValue
- default value
public static float floatForKeyWithDefault(java.lang.String s, float defaultValue)
s
- system propertydefaultValue
- default value
public static double doubleForKeyWithDefault(java.lang.String s, double defaultValue)
s
- system propertydefaultValue
- default value
public static java.lang.String stringForKey(java.lang.String s)
System.getProperty(java.lang.String)
s
- system property
public static java.lang.String stringForKeyWithDefault(java.lang.String s, java.lang.String defaultValue)
System.getProperty(java.lang.String)
s
- system property
public static java.lang.String decryptedStringForKey(java.lang.String propertyName)
propertyName
- the property name to retrieve and optionally decrypt
public static java.lang.String decryptedStringForKeyWithDefault(java.lang.String propertyName, java.lang.String defaultValue)
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.
propertyName
- the property name to retrieve and optionally decryptdefaultValue
- the default value to return if there is no password
public static java.lang.String decryptedStringForKeyWithEncryptedDefault(java.lang.String propertyName, java.lang.String defaultValue)
ERXCrypto.defaultCrypter
. This is slightly different than
decryptedStringWithKeyWithDefault in that it does not require the encrypted
property to be set.
propertyName
- the name of the property to decryptdefaultValue
- the default encrypted value
public static com.webobjects.foundation.NSArray<java.lang.String> componentsSeparatedByString(java.lang.String key, java.lang.String separator)
key
- the key to lookupseparator
- the separator (",")
public static com.webobjects.foundation.NSArray<java.lang.String> componentsSeparatedByStringWithDefault(java.lang.String key, java.lang.String separator, com.webobjects.foundation.NSArray<java.lang.String> defaultValue)
key
- the key to lookupseparator
- the separator (",")defaultValue
- the default array to return if there is no value
public static void setArrayForKey(com.webobjects.foundation.NSArray array, java.lang.String key)
array
- to be set in the System propertieskey
- to be used to get the valuepublic static void setDictionaryForKey(com.webobjects.foundation.NSDictionary dictionary, java.lang.String key)
dictionary
- to be set in the System propertieskey
- to be used to get the valuepublic static void setStringForKey(java.lang.String string, java.lang.String key)
string
- to be set in the System propertieskey
- to be used to get the valuepublic static void removeKey(java.lang.String key)
public static void transferPropertiesFromSourceToDest(java.util.Properties source, java.util.Properties dest)
source
- properties copied fromdest
- properties copied topublic static java.util.Properties propertiesFromPath(java.lang.String path)
Properties
object
as the result. If the file does not exist, returns
an empty properties object.
path
- file path to the properties file
public static java.util.Properties propertiesFromFile(java.io.File file) throws java.io.IOException
file
- the properties file
java.io.IOException
- if the file is not found or cannot be readpublic static java.util.Properties propertiesFromArgv(java.lang.String[] argv)
argv
- string array typically provided by
the command line arguments
public static com.webobjects.foundation.NSArray pathsForUserAndBundleProperties()
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.
public static com.webobjects.foundation.NSArray pathsForUserAndBundleProperties(boolean reportLoggingEnabled)
public static java.util.Properties applyConfiguration(java.util.Properties source, java.util.Properties commandLine)
source
- commandLine
- public static java.util.Map<java.lang.String,java.lang.String> allPropertiesMap(boolean protectValues)
protectValues
- if true, keys with the word "password" in them will have their values removed
public static java.util.Map<java.lang.String,java.lang.String> propertiesMap(java.util.Properties properties, boolean protectValues)
protectValues
- if true, keys with the word "password" in them will have their values removed
public static java.lang.String logString(java.util.Properties properties)
properties
- public static com.webobjects.foundation.NSArray<ERXProperties.Property> allProperties()
public static java.lang.String pathForPropertiesUnderProjectPath(java.lang.String projectPath)
projectPath
- string to the project root directory
public static java.lang.String applicationDeveloperProperties()
public static java.lang.String variantPropertiesInBundle(java.lang.String userName, java.lang.String bundleName)
public static java.lang.String applicationUserProperties()
public static java.lang.String applicationMachinePropertiesPath(java.lang.String fileName)
public static com.webobjects.foundation.NSArray optionalConfigurationFiles()
public static java.lang.String getActualPath(java.lang.String path)
path
- path string to a resource that could
contain symbolic links
public static void systemPropertiesChanged()
protected java.lang.String applicationNameForAppending()
public java.lang.String getProperty(java.lang.String key)
getProperty
in class java.util.Properties
key
- to check
public java.lang.Object toExternalForm() throws java.io.IOException
java.io.IOException
public static ERXProperties fromExternalForm(java.lang.String string)
string
- public void takeValueForKey(java.lang.Object anObject, java.lang.String aKey)
takeValueForKey
in interface com.webobjects.foundation.NSKeyValueCoding
anObject
- aKey
- public java.lang.Object valueForKey(java.lang.String aKey)
valueForKey
in interface com.webobjects.foundation.NSKeyValueCoding
aKey
- public static void setOperatorForKey(ERXProperties.Operator operator, java.lang.String key)
operator
- the operator to registerkey
- the key name of the operatorpublic static void evaluatePropertyOperators(java.util.Properties originalProperties, java.util.Properties destinationProperties)
originalProperties
- the properties to convertdestinationProperties
- the properties to copy intopublic static void setCommandLineArguments(java.lang.String[] argv)
|
Last updated: Tue, Feb 21, 2017 05:45 PM CET | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |