jade.util
Class ImportableProperties
java.lang.Object
|
+--jade.util.BasicProperties
|
+--jade.util.ImportableProperties
- Direct Known Subclasses:
- EnhancedProperties
- public abstract class ImportableProperties
- extends BasicProperties
This class serves as a basis for supporting the ability to import properties
from files. Those files may also contain further import dirrectives. It is
also usable in the restrictive J2ME CLDC environment. Since file support
will be handled differently in different environments, it contains one
abstract method fileReader which given the name of a file
(its URL) must return a Reader object. Extending classes will provide that
method in a suitable fashion. For example, in the desktop world this would be:
return new InputStreamReader(new FileInputStream(aFileName));
whereas in the CLDC environment it would be:
return new InputStreamReader(Connector.openInputStream(aFileName));
This class relates to four others as follows:
- BasicProperties - This class provides the foundation class. 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}.
- EnhancedProperties - Provides a concrete implementation of ImportableProperties
useable in the J2SE (desktop) world.
- ExpandedProperties - Extends EnhancedProperties and adds support for fetching
system environment variables (those usable from the OS shell). This class would need
to be carefully considered in different environments.
- PropertiesException - Extends RuntimeException and is thrown under various
error conditions by these classes.
- Author:
- Dick Cowan - HP Labs
Method Summary |
void |
addFromFile(java.lang.String aFileName)
Add properties from named file.
|
protected abstract java.io.Reader |
fileReader(java.lang.String aFileName)
Construct a Reader for the specified file name. |
java.lang.String |
getImportKey()
Get the string used to trigger import activity. |
void |
setImportKey(java.lang.String aKey)
Change value of import directive. |
protected boolean |
storableProperty(java.lang.String key,
java.lang.String value)
Detect import dirrective and import file. |
Methods inherited from class jade.util.BasicProperties |
addFromReader,
copyProperties,
doSubstitutions,
doSubstitutions,
extractSubset,
get,
getBooleanProperty,
getEnvironmentProperty,
getIntProperty,
getOneLine,
getProperty,
getProperty,
getPropertyIgnoreCase,
getRawProperty,
isCandidate,
isolateKey,
isolateValue,
keys,
list,
load,
main,
nextArgIndex,
parseArgs,
parseArgument,
prepareArgs,
put,
readLine,
renameKey,
setBooleanProperty,
setIntProperty,
setProperty,
setPropertyIfNot,
sortedKeys,
specialHandling,
store,
toStringArray,
valueFilter |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
ImportableProperties
public ImportableProperties()
- Construct empty property collection.
ImportableProperties
public ImportableProperties(java.lang.String[] theArgs)
- Construct properties from arguments.
- Parameters:
theArgs
- The applications original arguments.
fileReader
protected abstract java.io.Reader fileReader(java.lang.String aFileName)
throws java.io.IOException
- Construct a Reader for the specified file name.
- Parameters:
aFileName
- The name of the file.- Returns:
- Reader The reader for the file.
- Throws:
- java.io.IOException - if anything goes wrong.
getImportKey
public java.lang.String getImportKey()
- Get the string used to trigger import activity.
- Returns:
- String The import key. Default value is "import".
setImportKey
public void setImportKey(java.lang.String aKey)
- Change value of import directive.
- Parameters:
aKey
- New value to change default "import".
addFromFile
public void addFromFile(java.lang.String aFileName)
throws java.io.IOException
- Add properties from named file.
Creates a Reader for the file and calls addFromReader.
- Parameters:
name
- The name of the property file.importNames
- Hashtable with names of files processed - used
to catch circular imports.- Throws:
- java.io.IOException - if anything goes wrong.
- PropertiesException - if circular import.
storableProperty
protected boolean storableProperty(java.lang.String key,
java.lang.String value)
- Detect import dirrective and import file.
- Overrides:
- storableProperty in class BasicProperties
- Parameters:
key
- The key value string - check if equal to "import".value
- The value string - if import then this is file name.- Returns:
- False if import, true otherwise.