|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jade.util.BasicProperties
Provides the foundation class for property management. It is designed to be usable in the restrictive J2ME CLDC environment. It provides enhanced property management as well as providing support for values containing strings of the form ${key}.
A property may be set such that it can't be altered by ending the key value with a '!'. For example:
agentClass!=com.hp.agent.FooOne still references this property as ${agentClass}.
This class relates to four others as follows:
return new InputStreamReader(new FileInputStream(aFileName));whereas in the CLDC environment it would be:
return new InputStreamReader(Connector.openInputStream(aFileName));
Constructor Summary | |
BasicProperties()
Construct empty property collection. |
|
BasicProperties(java.lang.String[] theArgs)
Construct properties from arguments. |
Method Summary | |
protected void |
addFromReader(java.io.Reader reader)
Add properties from Reader. |
void |
copyProperties(BasicProperties source)
Copy a data from standard Properties. |
java.lang.String |
doSubstitutions(java.lang.String anInputString)
Replace all substrings of the form ${xxx} with the property value using the key xxx. |
java.lang.String |
doSubstitutions(java.lang.String anInputString,
boolean allowUndefined)
Replace all substrings of the form ${xxx} with the property value using the key xxx. |
BasicProperties |
extractSubset(java.lang.String anArgPrefix)
Create a new PropertiesCollection from this one by coping those attributes which begin with a particular prefix string. |
java.lang.Object |
get(java.lang.String aKey)
Get the object associated with a key. |
boolean |
getBooleanProperty(java.lang.String aKey,
boolean aDefaultValue)
Extract a string value ("true" or "false") and convert it to a boolean. |
protected java.lang.String |
getEnvironmentProperty(java.lang.String key)
Fetch environment property by looking calling System.getProperty. |
int |
getIntProperty(java.lang.String aKey,
int aDefaultValue)
Extract a string value and convert it to an integer. |
protected java.lang.String |
getOneLine(java.io.Reader reader)
Get a logical line. |
java.lang.String |
getProperty(java.lang.String aKey)
Override getProperty in base class so all occurances of the form ${key} are replaced by their associated value. |
java.lang.String |
getProperty(java.lang.String aKey,
java.lang.String defaultValue)
Perform substitution when a value is fetched. |
java.lang.String |
getPropertyIgnoreCase(java.lang.String aKey)
Use this method to fetch a property ignoring case of key. |
java.lang.String |
getRawProperty(java.lang.String aKey)
Fetch property value for key which may contain strings of the form ${key}. |
protected boolean |
isCandidate(java.lang.String arg)
Called by parseArgument to determine if an argument is a candidate key, value combination. |
protected java.lang.String |
isolateKey(java.lang.String arg)
Called by parseArgument to extract the key component from an argument. |
protected java.lang.String |
isolateValue(java.lang.String arg)
Called by parseArgument to extract the value component from the current argument. |
java.util.Enumeration |
keys()
|
void |
list(java.io.PrintStream out)
List properties to provided PrintStream. |
void |
load(java.io.InputStream inStream)
Add properties from a specified InputStream. |
static void |
main(java.lang.String[] args)
For testing. |
protected int |
nextArgIndex(java.lang.String[] args,
int argIndex)
Called by parseArgs to set the next argument index. |
void |
parseArgs(java.lang.String[] args)
Parse the arguments and place them in this properties collection. |
protected void |
parseArgument(java.lang.String arg)
Called to handle either an argument or line from an import file. |
protected java.lang.String[] |
prepareArgs(java.lang.String[] args)
Called by parseArgs to perform any preprocessing of the arguments. |
java.lang.Object |
put(java.lang.String aKey,
java.lang.Object aValue)
Set property value to specified object. |
protected java.lang.String |
readLine(java.io.Reader aReader)
Read one line from the Reader. |
java.lang.Object |
renameKey(java.lang.String existingKey,
java.lang.String newKey)
Change key string associated with existing value. |
void |
setBooleanProperty(java.lang.String aKey,
boolean aValue)
Store a boolean as a string ("true" or "false") with the specified key. |
int |
setIntProperty(java.lang.String aKey,
int aValue)
Store an int as a string with the specified key. |
java.lang.Object |
setProperty(java.lang.String aKey,
java.lang.String aValue)
Set property value. |
java.lang.Object |
setPropertyIfNot(java.lang.String aKey,
java.lang.String value)
Set property value only if its not set already. |
java.util.Enumeration |
sortedKeys()
Return a sorted enumertion of this properties keys. |
protected void |
specialHandling(java.lang.String arg)
Called by parseArgument when the isCandidate method returns false. |
protected boolean |
storableProperty(java.lang.String key,
java.lang.String value)
Called by parseArgument as a final step prior to actually storing the key=value pair. |
void |
store(java.io.OutputStream out,
java.lang.String header)
Writes this property collection to the output stream in a format suitable for loading into a Properties table using the load method. |
java.lang.String[] |
toStringArray()
Create a String[] for the properties with one key=value pair per array entry. |
protected java.lang.String |
valueFilter(java.lang.String key,
java.lang.String value)
Called by getProperty(key, default) to perform any post processing of the value string. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public BasicProperties()
public BasicProperties(java.lang.String[] theArgs)
theArgs
- The applications original arguments.Method Detail |
public static void main(java.lang.String[] args)
public void load(java.io.InputStream inStream) throws java.io.IOException
aFileName
- The name of the file.public void store(java.io.OutputStream out, java.lang.String header) throws java.io.IOException
out
- An output stream.header
- A description of the property list - may be null.public java.util.Enumeration keys()
public java.util.Enumeration sortedKeys()
public void parseArgs(java.lang.String[] args)
args
- The array of arguments - typically from a command line.
If null, this method does nothing.protected void parseArgument(java.lang.String arg)
arg
- The argument or line. Typically of the form key=value.protected java.lang.String[] prepareArgs(java.lang.String[] args)
args
- The original arguments passed to parseArgs.protected boolean isCandidate(java.lang.String arg)
arg
- The argument being processed.protected void specialHandling(java.lang.String arg)
arg
- The argument being processed.protected java.lang.String isolateKey(java.lang.String arg)
arg
- The argument being processed.index
- Index into args of current argument.protected java.lang.String isolateValue(java.lang.String arg)
arg
- The argument being processed.protected boolean storableProperty(java.lang.String key, java.lang.String value)
key
- The key string.value
- The value string.protected int nextArgIndex(java.lang.String[] args, int argIndex)
public void copyProperties(BasicProperties source)
source
- The Hashtable to copy from.public BasicProperties extractSubset(java.lang.String anArgPrefix)
anArgPrefix
- The prefix string. Ex: "server."public java.lang.Object get(java.lang.String aKey)
aKey
- Key for desired property.public java.lang.Object put(java.lang.String aKey, java.lang.Object aValue)
aKey
- The key used to store the data. The key may contain strings of
the form ${key} which will be evaluated first.aValue
- The object to be stored.public java.lang.String getProperty(java.lang.String aKey)
aKey
- Key for desired property.public java.lang.Object setProperty(java.lang.String aKey, java.lang.String aValue)
aKey
- The key used to store the data. The key may contain strings of
the form ${key} which will be evaluated first.aValue
- The value to be stored, if null they property will be removed.public java.lang.Object setPropertyIfNot(java.lang.String aKey, java.lang.String value)
aKey
- The key used to store the data. The key may contain strings of
the form ${key} which will be evaluated first.value
- The value to be stored.public java.lang.String getRawProperty(java.lang.String aKey)
aKey
- Key for desired property.public java.lang.String getPropertyIgnoreCase(java.lang.String aKey)
aKey
- The key of the environment property.public java.lang.String getProperty(java.lang.String aKey, java.lang.String defaultValue)
aKey
- The property key.defaultValue
- Value to return if property not defined. May be null.
If non null it will be passes to valueFilter first.protected java.lang.String valueFilter(java.lang.String key, java.lang.String value)
key
- The properties key.value
- The properties value.public int getIntProperty(java.lang.String aKey, int aDefaultValue)
aKey
- The key which will be used to fetch the attribute.aDefaultValue
- Specifies the default value for the int.public int setIntProperty(java.lang.String aKey, int aValue)
aKey
- The key which will be used to store the attribute.aValue
- The int value.public boolean getBooleanProperty(java.lang.String aKey, boolean aDefaultValue)
aKey
- The key which will be used to fetch the attribute.aDefaultValue
- Specifies the default value for the boolean.public void setBooleanProperty(java.lang.String aKey, boolean aValue)
aKey
- The key which will be used to store the attribute.aValue
- The boolean value.public java.lang.Object renameKey(java.lang.String existingKey, java.lang.String newKey)
existintKey
- The current key.newKey
- The new key.public java.lang.String doSubstitutions(java.lang.String anInputString)
anInputString
- The input string - may be null.public java.lang.String doSubstitutions(java.lang.String anInputString, boolean allowUndefined)
anInputString
- The input string - may be null.allowUndefined
- If true, undefined strings will remain as is,
if false, an exception will be thrown.protected java.lang.String getEnvironmentProperty(java.lang.String key)
key
- The key of the desired property.protected void addFromReader(java.io.Reader reader) throws java.io.IOException
reader
- The buffered reader to read from.
to catch circular imports.protected java.lang.String getOneLine(java.io.Reader reader) throws java.io.IOException
reader
- The input reader to read.protected java.lang.String readLine(java.io.Reader aReader) throws java.io.IOException
aReader
- The Reader to read characters from.public void list(java.io.PrintStream out)
out
- The print stream.public java.lang.String[] toStringArray()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |