public class CommonProperties
extends java.lang.Object
implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
private java.io.File |
m_binDir
The bin dir of the Pegasus install
|
private static CommonProperties |
m_instance
implements the singleton access via class variable.
|
private java.util.Properties |
m_props
internal set of properties.
|
private java.io.File |
m_schemaDir
Location of our schemas
|
private java.io.File |
m_sharedStateDir
GNU: modifiable architecture-independent data in DIR [PREFIX/share/pegasus].
|
private java.io.File |
m_sysConfDir
GNU: read-only single-machine data in DIR [PREFIX/etc].
|
static java.lang.String |
PROPERTY_FILENAME
Basename of the file to read to obtain system properties
|
static java.lang.String |
USER_PROPERTY_FILENAME
Basename of the (new) file to read for user properties.
|
Modifier | Constructor and Description |
---|---|
protected |
CommonProperties(java.lang.String confProperties)
ctor.
|
Modifier and Type | Method and Description |
---|---|
protected static java.util.Properties |
addProperties(java.util.Properties a,
java.util.Properties b)
Adds new properties to an existing set of properties while
substituting variables.
|
java.lang.Object |
clone()
Returns the clone of the object.
|
private static java.util.Properties |
defaultProps()
Set some defaults, should values be missing in the dataset.
|
java.io.File |
getBinDir()
Accessor pegasus bin directory
|
java.lang.String |
getProperty(java.lang.String key)
Accessor: access to the internal properties as read from file.
|
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defValue)
Accessor: access to the internal properties as read from file
An existing system property of the same key will have precedence
over any project property.
|
java.io.File |
getSchemaDir()
Accessor to schema directory
|
java.io.File |
getSharedStateDir()
Accessor to $PEGASUS_HOME/com.
|
java.io.File |
getSysConfDir()
Accessor to $PEGASUS_HOME/etc.
|
static CommonProperties |
instance()
Singleton threading: Creates the one and only instance of the
properties in the current application.
|
void |
list(java.io.PrintStream out)
Print out the property list onto the specified stream.
|
static void |
main(java.lang.String[] args) |
static java.util.Properties |
matchingSubset(java.util.Properties properties,
java.lang.String prefix,
boolean keepPrefix)
Extracts a specific property key subset from the properties passed.
|
java.util.Properties |
matchingSubset(java.lang.String prefix,
boolean keepPrefix)
Extracts a specific property key subset from the known properties.
|
static CommonProperties |
noHassleInstance()
Singleton interface: Creates the one and only instance of the
properties in the current application, and does not bother the
programmer with exceptions.
|
static CommonProperties |
nonSingletonInstance(java.lang.String confProperties)
Create a temporary property that is not attached to the Singleton.
|
private java.io.File |
pickPath(java.lang.String p1,
java.lang.String p2) |
java.util.Enumeration |
propertyNames()
Accessor: enumerate all keys known to this property collection
|
java.lang.Object |
setProperty(java.lang.String key,
java.lang.String value)
Accessor: Overwrite any properties from within the program.
|
int |
size()
Accessor: Obtains the number of properties known to the project.
|
private static CommonProperties m_instance
private java.util.Properties m_props
private java.io.File m_binDir
private java.io.File m_sysConfDir
private java.io.File m_sharedStateDir
private java.io.File m_schemaDir
public static final java.lang.String PROPERTY_FILENAME
public static final java.lang.String USER_PROPERTY_FILENAME
protected CommonProperties(java.lang.String confProperties) throws java.io.IOException, java.util.MissingResourceException
confProperties
- the path to conf properties, that supersede the loading
of properties from $PEGASUS_HOME/.pegasusrcjava.io.IOException
- will be thrown if reading the property file
goes awry.java.util.MissingResourceException
- will be thrown if not all
required properties are setprotected static java.util.Properties addProperties(java.util.Properties a, java.util.Properties b)
a
- is the initial set of known properties (besides System ones)b
- is the set of properties to add to aprivate static java.util.Properties defaultProps()
private java.io.File pickPath(java.lang.String p1, java.lang.String p2)
public static CommonProperties instance() throws java.io.IOException, java.util.MissingResourceException
java.io.IOException
- will be thrown if reading the property file
goes awry.java.util.MissingResourceException
- will be thrown if you forgot
to specify the -Dpegasus.home=$PEGASUS_HOME
to the runtime
environment.noHassleInstance()
public static CommonProperties nonSingletonInstance(java.lang.String confProperties) throws java.io.IOException, java.util.MissingResourceException
confProperties
- the path to conf properties, that supersede the
loading of properties from $PEGASUS_HOME/.pegasusrcjava.io.IOException
- will be thrown if reading the property file
goes awry.java.util.MissingResourceException
- will be thrown if you forgot
to specify the -Dpegasus.home=$PEGASUS_HOME
to the runtime
environment.instance()
public static CommonProperties noHassleInstance()
instance()
call are caught, converted to an error
message on stderr, and the program is exited.instance()
public java.io.File getBinDir()
public java.io.File getSysConfDir()
public java.io.File getSharedStateDir()
public java.io.File getSchemaDir()
public int size()
public java.lang.String getProperty(java.lang.String key)
key
- is the key to look uppublic java.lang.String getProperty(java.lang.String key, java.lang.String defValue)
key
- is the key to look updefValue
- is a default to use, if no value can be found for the key.public java.lang.Object setProperty(java.lang.String key, java.lang.String value)
key
- is the key to look upvalue
- is the new property value to place in the system.public java.util.Enumeration propertyNames()
public java.util.Properties matchingSubset(java.lang.String prefix, boolean keepPrefix)
prefix
- is the key prefix to filter the properties by.keepPrefix
- if true, the key prefix is kept in the resulting
dictionary. As side-effect, a key that matches the prefix exactly
will also be copied. If false, the resulting dictionary's keys are
shortened by the prefix. An exact prefix match will not be copied,
as it would result in an empty string key.is used to assemble matches
public static java.util.Properties matchingSubset(java.util.Properties properties, java.lang.String prefix, boolean keepPrefix)
prefix
- is the key prefix to filter the properties by.keepPrefix
- if true, the key prefix is kept in the resulting
dictionary. As side-effect, a key that matches the prefix exactly
will also be copied. If false, the resulting dictionary's keys are
shortened by the prefix. An exact prefix match will not be copied,
as it would result in an empty string key.is used to assemble matches
public void list(java.io.PrintStream out)
out
- an output streamjava.lang.ClassCastException
- if any key is not a string.Properties.list( PrintStream )
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException
public java.lang.Object clone()
clone
in class java.lang.Object