public class Profile
extends java.lang.Object
implements java.io.Serializable
An application identifies the profile list to use in an app.profile.list file. This file contains a single entry which points to a profile list file. The profile list file contains a list of the properties files to load.
Example app.profile.list:
myapplication.list
Example myapplication.list:
base.site.properties base.dbinfo.properties base.message.properties base.log4j.properties base.velocity.properties myapplication.site.properties myapplication.db.properties myapplication.dbinfo.properties myapplication.dbsql.properties myapplication.message.properties
When duplicate keys exist in the properties files being loaded, the last key read overrides the value stored by an earlier read.
This class assumes that the app.profile.list file as well as all other referenced files reside in a folder that is accessible via the classpath. Properties file names are assumed to be lower case.
Modifier and Type | Field and Description |
---|---|
static boolean |
BASE_URL_ISSAME
A flag indicating if the site is configured to run full-time SSL or
full-time nonSSL.
|
static java.lang.String |
BASE_URL_NONSECURE
The value of the "Site.URL.Nonsecure" key.
|
static java.lang.String |
BASE_URL_SECURE
The value of the "Site.URL.Secure" key.
|
static int |
COOKIE_EXPIRES
The value of the "Site.Cookie.Expires" key.
|
private static java.util.Properties |
cvProfile
A static cache of profile properties.
|
static java.text.DateFormat |
FMT_DATEINPUT
The value of the "Site.Format.DateInput" key.
|
static java.text.DateFormat |
FMT_TIMEINPUT
The value of the "Site.Format.TimeInput" key.
|
private static long |
serialVersionUID
The class' serialization version id.
|
static java.lang.String |
SITE_PATH
The value of the "Site.Path" key.
|
static java.lang.String |
SITE_ROOT
The value of the "Site.Root" key.
|
static java.lang.String[] |
STACK_OMIT_PARMS
The value of the "Servlet.Stack.Omit.Parms" key.
|
static java.lang.String |
TEMP_PATH
The value of the "FileSystem.TempFolder" key.
|
static java.lang.String |
URL_ERROR
The URL to the SiteError servlet.
|
static java.lang.String |
URL_REDIRECT
The URL to the Redirect.html file.
|
Constructor and Description |
---|
Profile() |
Modifier and Type | Method and Description |
---|---|
static void |
dumpPropertiesToFile()
Dumps a sorted list of all profile.list property keys and values to a
file named "_properties.profile.txt" in the application's temp folder.
|
static java.util.ArrayList<java.lang.String> |
dumpPropertiesToList()
Returns a sorted list of all profile.list property keys and values.
|
static boolean |
getBoolean(java.lang.String key)
Returns a
boolean value for the given properties key. |
static double |
getDouble(java.lang.String key)
Returns an
double value for the given properties key. |
static int |
getInteger(java.lang.String key)
Returns an
int value for the given properties key. |
static int[] |
getIntegerArray(java.lang.String key,
java.lang.String delimiter)
Returns an
int array of the parsed values for the given
properties key using the given parsing delimiter. |
static java.lang.String |
getProperty(java.lang.String key)
Returns the property value associated with the given key.
|
static java.lang.String |
getProperty(java.lang.String key,
java.lang.String dftValue)
Returns the property value associated with the given key.
|
static java.lang.String |
getPropertyFileFolder()
Returns the file path to the .property configuration folder.
|
static java.lang.String |
getPropertyListContent()
Returns the content for the site's configured property list (as defined by
app.profile.list).
|
static java.lang.String |
getString(java.lang.String key)
Returns a
String value for the given properties key. |
static java.lang.String[] |
getStringArray(java.lang.String key)
Returns a
String array of the parsed values for the given
properties key using the vertical bar (|) as the default parsing delimiter. |
static java.lang.String[] |
getStringArray(java.lang.String key,
java.lang.String delimiter)
Returns a
String array of the parsed values for the given
properties key using the given parsing delimiter. |
static java.lang.String |
getStringWithError(java.lang.String key)
Returns a
String value for the given properties key. |
static java.util.Properties |
getSubSet(java.lang.String prefix,
boolean remove)
Returns a new
Properties object that contains a subset of
the profile properties. |
static void |
init()
Initializes the cache of properties and static constants.
|
private static void |
loadProperties()
Loads and stores the properties files defined in a profile list.
|
private static void |
loadProperties(java.lang.String propfile)
Loads the contents of the given properties file into the cache.
|
static void |
setProperty(java.lang.String key,
java.lang.String value)
Sets the value for a property key.
|
private static void |
substituteValues()
Performs substitutions for property values that contain references to
other properties.
|
private static java.lang.String |
substituteValues(java.util.regex.Pattern p,
java.lang.String s)
Performs substitutions for property values that contain references to
other properties.
|
private static final long serialVersionUID
private static java.util.Properties cvProfile
public static java.lang.String BASE_URL_SECURE
public static java.lang.String BASE_URL_NONSECURE
public static boolean BASE_URL_ISSAME
public static int COOKIE_EXPIRES
public static java.text.DateFormat FMT_DATEINPUT
public static java.text.DateFormat FMT_TIMEINPUT
public static java.lang.String SITE_PATH
public static java.lang.String SITE_ROOT
public static java.lang.String[] STACK_OMIT_PARMS
public static java.lang.String TEMP_PATH
public static java.lang.String URL_ERROR
public static java.lang.String URL_REDIRECT
public static void init()
public static boolean getBoolean(java.lang.String key)
boolean
value for the given properties key.key
- (String) The key for the desired property value.boolean
.public static double getDouble(java.lang.String key)
double
value for the given properties key.key
- (String) The key for the desired property value.double
.public static int getInteger(java.lang.String key)
int
value for the given properties key.key
- (String) The key for the desired property value.int
.public static int[] getIntegerArray(java.lang.String key, java.lang.String delimiter)
int
array of the parsed values for the given
properties key using the given parsing delimiter.key
- (String) The key for the desired property value.delimiter
- (String) The delimiter to be used for the parsing.int
array containing the parsed
results of the retrieved property value.public static java.lang.String getProperty(java.lang.String key)
key
- (String) The key for the desired value.null
if
a value for the key could not be found.public static java.lang.String getProperty(java.lang.String key, java.lang.String dftValue)
key
- (String) The key for the desired value.dftValue
- (String) The default value if the key is not found.public static java.lang.String getString(java.lang.String key)
String
value for the given properties key.key
- (String) The key for the desired property value.public static java.lang.String getStringWithError(java.lang.String key) throws java.util.MissingResourceException
String
value for the given properties key.key
- (String) The key for the desired property value.java.util.MissingResourceException
- - if the key is not found.public static java.lang.String[] getStringArray(java.lang.String key)
String
array of the parsed values for the given
properties key using the vertical bar (|) as the default parsing delimiter.key
- (String) The key for the desired property value.String
array containing the parsed
results of the retrieved property value.public static java.lang.String[] getStringArray(java.lang.String key, java.lang.String delimiter)
String
array of the parsed values for the given
properties key using the given parsing delimiter.key
- (String) The key for the desired property value.delimiter
- (String) The delimiter to be used for the parsing.String
array containing the parsed
results of the retrieved property value.public static java.util.Properties getSubSet(java.lang.String prefix, boolean remove)
Properties
object that contains a subset of
the profile properties. The subset contains all profile properties that
have keys beginning with the specified prefix.prefix
- (String) The prefix for the keys to include in the
subset (case sensitive).remove
- (boolean) true
if the prefix should be
removed from the subset's property keys, or false
if the subset's property keys should be the same as the keys
in the profile properties.public static java.lang.String getPropertyFileFolder()
public static java.lang.String getPropertyListContent()
null
if the content could not be determined.public static void setProperty(java.lang.String key, java.lang.String value)
key
- (String) The key for the value to set.value
- (String) The value to set.private static void loadProperties()
private static void loadProperties(java.lang.String propfile)
propfile
- (String) The name of the properties file to load.private static void substituteValues()
private static java.lang.String substituteValues(java.util.regex.Pattern p, java.lang.String s)
p
- (Pattern) The precompiled RegEx pattern to use for finding
values to be substituted.s
- (String) The property value to process.public static void dumpPropertiesToFile()
public static java.util.ArrayList<java.lang.String> dumpPropertiesToList()