|
WebObjects 5.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.webobjects.foundation.NSProperties
This class extends Java's properties mechanism to merge
application properties with the standard system properties available using
the java.lang.System.getProperties
method. The application properties
can come from three sources: the command line, the application's
Properties
file, and the Properties
files of any
frameworks the application includes.
This class has only static methods and cannot be instantiated.
To access the application properties you first need to merge the application and command line properties with the system properties. A WebObjects application automatically performs this step for you. You can then access the property as a string, and convert the string to the property's actual data type.
To obtain the application properties and merge them with the system
properties you have to invoke setPropertiesFromArgv
. Application properties
can come from the application's Properties
file, the
Properties
files for the frameworks the application
includes, the file WebObjects.properties
in the user's home directory and the command line.
Every property is a key-value pair. For example, on Unix machines, the
property value for the key "file.separator" is "/".
To access a property corresponding to a particular key, use the
java.lang.System.getProperty
method. This method returns the
property as a string.
If the property string represents a value other than java.lang.String
,
for example, a boolean value, NSArray, or
NSDictionary, you can convert it to the appropriate data type using the
NSPropertyListSerialization's booleanForString
, arrayForString
, or
dictionaryForString
method, respectively.
NSPropertyListSerialization also provides an intForString
method to simplify
converting a property string to an integer.
The properties must be stored in a file named Properties
in
the application or framework's Resources
directory. You can add
a Properties
file to the application or framework by adding it
to the Resources group in Project Builder.
The Properties file must be in the format specified by java.io.Properties.
Boolean values, NSArrays, and NSDictionaries must be specified using the property list representation. See the NSPropertyListSerialization class description for more information on property lists.
The setPropertiesFromArgv
method parses the command line arguments and
recognizes the property formats listed in the table below.
Format | Example | |
---|---|---|
-D key= value |
-DWOPort=4321 |
|
- key value |
-WOAutoOpenInBrowser NO |
Properties specified in these formats will be available as system
properties after you invoke setPropertiesFromArgv
.
System.getProperty(java.lang.String)
,
setPropertiesFromArgv(java.lang.String[])
,
NSPropertyListSerialization
Constructor Summary | |
NSProperties()
|
Method Summary | |
static NSArray |
arrayForKey(String aKey)
Deprecated. Instead, find the system property using System.getProperty and
convert the property to a string using NSPropertyListSerialization.arrayForString . |
static boolean |
booleanForKey(String aKey)
Deprecated. Instead, find the system property using System.getProperty and
convert it to a boolean using NSPropertyListSerialization.booleanForString . |
static NSData |
dataForKey(String aKey)
Deprecated. Instead, find the system property using System.getProperty ,
convert the property to a property list using
NSPropertyListSerialization.propertyListFromString ,
and convert the property list to an NSData object using
NSPropertyListSerialization.dataFromPropertyList . |
static NSDictionary |
dictionaryForKey(String aKey)
Deprecated. Instead, find the system property using System.getProperty and
convert the property to an NSDictionary using
NSPropertyListSerialization.dictionaryForString |
static double |
doubleForKey(String aKey)
Deprecated. Instead, find the system property using System.getProperty and
convert the property to a double. |
static float |
floatForKey(String aKey)
Deprecated. Instead, find the system property using System.getProperty and
and convert the property to a float. |
static int |
integerForKey(String aKey)
Deprecated. Instead, find the system property using System.getProperty and
convert it to an integer using
NSPropertyListSerialization.intForString . |
static long |
longForKey(String aKey)
Deprecated. Instead, find the system property using System.getProperty and
and convert the property to a long. |
static void |
setPropertiesFromArgv(String[] argv)
Loads all of the application's properties from all the three sources described in the class description and merges them with the Java System properties. |
static String |
stringForKey(String aKey)
Deprecated. Use System.getProperty(java.lang.String) . |
static NSDictionary |
valuesFromArgv(String[] argv)
Parses a String array of properties. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public NSProperties()
Method Detail |
public static NSArray arrayForKey(String aKey)
System.getProperty
and
convert the property to a string using NSPropertyListSerialization.arrayForString
.
aKey
- input key whose property will be converted to NSArrayaKey
or null
if no system property with that name existsNullPointerException
- aKey
is null
System.getProperty(java.lang.String)
,
NSPropertyListSerialization.arrayForString(java.lang.String)
public static boolean booleanForKey(String aKey)
System.getProperty
and
convert it to a boolean
using NSPropertyListSerialization.booleanForString
.
aKey
- input key whose property will be converted to booleanaKey
or false
if no system property with that name existsNullPointerException
- aKey
is null
System.getProperty(java.lang.String)
,
NSPropertyListSerialization.booleanForString(java.lang.String)
public static NSData dataForKey(String aKey)
System.getProperty
,
convert the property to a property list using
NSPropertyListSerialization.propertyListFromString
,
and convert the property list to an NSData object using
NSPropertyListSerialization.dataFromPropertyList
.
aKey
- input key whose property will be converted to NSDataNSData.EmptyData
if no system
property with that name existsNullPointerException
- aKey
is null
System.getProperty(java.lang.String)
,
NSPropertyListSerialization.propertyListFromString(java.lang.String)
,
NSPropertyListSerialization.dataFromPropertyList(java.lang.Object)
public static NSDictionary dictionaryForKey(String aKey)
System.getProperty
and
convert the property to an NSDictionary using
NSPropertyListSerialization.dictionaryForString
aKey
- input key whose property will be converted to NSDictionaryNSDictionary.EmptyDictionary
if
no system property with that name existsNullPointerException
- aKey
is null
System.getProperty(java.lang.String)
,
NSPropertyListSerialization.dictionaryForString(java.lang.String)
public static double doubleForKey(String aKey)
System.getProperty
and
convert the property to a double.
aKey
- input key whose property will be converted to a double0
if no system property with that
name existsNullPointerException
- aKey
is null
System.getProperty(java.lang.String)
public static float floatForKey(String aKey)
System.getProperty
and
and convert the property to a float.
aKey
- input key whose property will be converted to a float0
if the system property
indicated by aKey
does not existNullPointerException
- aKey
is null
System.getProperty(java.lang.String)
public static int integerForKey(String aKey)
System.getProperty
and
convert it to an integer using
NSPropertyListSerialization.intForString
.
aKey
- input key whose property will be converted to an integeraKey
or 0
if no system property with that name existsNullPointerException
- aKey
is null
System.getProperty(java.lang.String)
,
NSPropertyListSerialization.intForString(java.lang.String)
public static long longForKey(String aKey)
System.getProperty
and
and convert the property to a long.
aKey
- input key whose property will be converted to a long0
if the property
indicated by aKey
does not existNullPointerException
- aKey
is null
System.getProperty(java.lang.String)
public static void setPropertiesFromArgv(String[] argv)
This method obtains the properties for every bundle in the application including
the application and all of the frameworks it includes. It also merges
any properties specified by the string array argv
into the system
properties.
argv
- a String array representing extra properties to be merged into system
propertiesProperties
public static String stringForKey(String aKey)
System.getProperty(java.lang.String)
.
System.getProperty(key)
.
Equivalent to System.getProperty(key)
.
aKey
- system property being inquiredaKey
public static NSDictionary valuesFromArgv(String[] argv)
argv
- a String array of properties to be parsedNSDictionary
|
Last updated Fri Feb 21 13:15:00 PST 2003. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |