|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.tree.DefaultMutableTreeNode PIRL.PVL.Parameter PIRL.Configuration.Configuration
public class Configuration
A Configuration maintains a Parameter list used for configuration management.
A Configuration is constructed by parsing source text in Parameter
Value Language (PVL) format (as read by a Parameter Parser
), or from another Configuration or PVL
Parameter. The Default_Source
will be
used if no source is specified. Except when a Configuration is
constructed as a copy of another Configuration (or Parameter
Aggregate), the Defaults
Parameters are always
included; if the special name DEFAULTS
is
specified, only the Defaults Parameters will be in the
Configuration. In all cases, the Parameters in the Configuration
will be Coalesce
d together.
The parameters of a Configuration are refered to by their
pathname. The pathname may include a delimiter
(usually the '/' character)
separated sequence of names where each segment names a parameter
group within which subsequent named parameters are nested. A
pathname that begins with a delimiter is rooted at the top of the
Configuration parameter groupings (i.e. these pathnames have an
absolute location in the Configuration). Otherwise the pathname is
rooted at the first occurance of a parameter having the first
segment name (i.e. these pathnames have a relative location in the
Configuration).
There are a set of parameter names that are known to the Configuration package:
Classpath
Host
User
Alias
In addition, the INCLUDE
parameter is recognized when
Include
mode is enabled as a parameter
with a value that references another source of Parameters that is to
be included in the Configuration replacing the Include parameter.
Include files may be nested. Cyclical Include file (but not URL)
chains are caught.
Parameter
,
Serialized FormField Summary | |
---|---|
static String |
ALIAS
The parameter name for a linked parameter used to create a new Configuration: "Alias". |
static boolean |
Case_Sensitive_Default
The default Case_Sensitive() state. |
static String |
CLASSPATH
The parameter name for the Java CLASSPATH: "Classpath". |
static String |
CONTINUE_INCLUDE_ON_ERROR_FLAG
INCLUDE parameter value flag that, when
found at the beginning of the value, causes an error on the
include - the source does not exists - to be ignored and
the include skipped. |
static String |
Default_Source
The name of the default configuration source: initially "DEFAULTS". |
static Parameter |
Defaults
The default parameters conditionally set during configuration . |
static String |
DEFAULTS
The name of the internal default parameters: "DEFAULTS". |
static boolean |
Defaults_Default
The default automatic Defaults state. |
static int |
Duplicate_Parameter_Action_Default
The default Duplicate_Parameter_Action() . |
static String |
ENVIRONMENT
The name of the Group containing the environment variable parameters: "/Environment". |
static String |
HOST
The parameter name for the application-specific hostname: "Host". |
static String |
ID
Class name and version identification. |
static String |
INCLUDE
The name of a parameter that refers to a file of parameters to be included at that point in the Configuration: "@Include". |
static boolean |
Include_Default
The default automatic Include state. |
static String |
INCLUDE_END
Parameter name prefix for the end of an Include file when tracing is enabled. |
static String |
INCLUDE_ERROR
Parameter name prefix for an ignored error report from an Include file
when tracing is enabled. |
static String |
INCLUDE_START
Parameter name prefix for the start of an Include file when tracing is enabled. |
static boolean |
Include_Tracing_Default
The default automatic Include tracing flag. |
static String |
NL
|
static int |
PREFER_FIRST_PARAMETER
The first duplicate parameter in the list gets preference when coalescing. |
static int |
PREFER_LAST_PARAMETER
The last duplicate parameter in the list gets preference when coalescing. |
static int |
THROW_ON_DUPLICATE_PARAMETERS
Duplicate parameters in the list when coalescing causes an exception. |
static String |
USER
The parameter name for the application-specific username: "User". |
Fields inherited from class PIRL.PVL.Parameter |
---|
AGGREGATE, ASSIGNMENT, BEGIN_GROUP, BEGIN_OBJECT, END, END_AGGREGATE, END_GROUP, END_OBJECT, END_PVL, GROUP, HIGHEST_BIT, LOWEST_BIT, MASK, OBJECT, TOKEN, UNKNOWN |
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode |
---|
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject |
Constructor Summary | |
---|---|
Configuration()
Constructs a default Configuration. |
|
Configuration(Configuration configuration)
Copies a Configuration. |
|
Configuration(InputStream stream)
Constructs a Configuration using the specified InputStream. |
|
Configuration(Parameter parameter)
Constructs a Configuration from a Parameter. |
|
Configuration(String source)
Constructs a Configuration using the specified source. |
|
Configuration(URL url)
Constructs a Configuration using the specified URL. |
Method Summary | |
---|---|
Configuration |
Add_Environment()
Adds environment variables to the Configuration. |
boolean |
Case_Sensitive()
Gets the case sensitive mode for finding parameter names. |
boolean |
Case_Sensitive(boolean enable)
Sets the case sensitive mode for finding parameter names. |
Object |
clone()
Clones a Configurtion. |
void |
Coalesce()
Coalesce all Aggregate parameters of the same name together. |
void |
Configure(InputStream stream)
Loads a Configuration from an InputStream. |
void |
Configure(String source)
Loads a Configuration from a configuration file. |
void |
Configure(URL url)
Loads a Configuration from a URL. |
static String |
Default_Filename()
Deprecated. Replaced by Default_Source() |
static void |
Default_Filename(String filename)
Deprecated. Replaced by Default_Source(String) |
static String |
Default_Source()
Gets the default source name. |
static void |
Default_Source(String source)
Sets the default source name. |
boolean |
Defaults(boolean enable)
Enables or disables automatic inclusion of Defaults
parameters. |
String |
Description()
Provides a String description of a Configuration formatted as a list of the parameters and their values. |
int |
Duplicate_Parameter_Action()
Gets the duplicate parameter action during coalescing. |
Configuration |
Duplicate_Parameter_Action(int action)
Sets the duplicate parameter action during coalescing. |
Parameter |
Effective_Parameter(String pathname)
Gets the effective Parameter for a pathname. |
String |
Effective_Pathname(String pathname)
Gets the effective pathname for a specified pathname. |
boolean |
Enabled(String pathname,
boolean default_flag)
Tests if a parameter has a logically true value. |
String |
Filename()
Deprecated. Replaced by Source() |
Configuration |
Filename(String filename)
Deprecated. Replaced by Source(String) |
String |
Get_Linked_One(String pathname)
Gets one String value for the effective, and possibly linked, parameter at a pathname. |
Vector |
Get_Linked(String pathname)
Gets the value(s) for the effective parameter at a pathname where the parameter may be linked to another parameter through its value. |
double |
Get_Number(String pathname,
double default_value)
Gets a numerical value. |
String |
Get_One(Parameter parameter)
Gets one String value from the Get Vector. |
String |
Get_One(String pathname)
Gets one String value for the effective parameter at a pathname. |
String |
Get_One(Value value)
Gets one String value from the Get Vector. |
static String |
Get_One(Vector values)
Gets the first String value from a Vector of values. |
static String |
Get_One(Vector values,
int index)
Gets the indexed String value from a Vector of values. |
String |
Get_Specific_One(String pathname)
Gets one String value from the specific pathname. |
Vector |
Get_Specific(String pathname)
Gets the value(s) for a parameter at a specific pathname. |
Vector |
Get(Parameter parameter)
Gets the value(s) for a Parameter. |
Vector |
Get(String pathname)
Gets the value(s) for the effective parameter at a pathname. |
Vector |
Get(String pathname,
boolean specific)
Gets the value(s) for a parameter at a pathname. |
Vector |
Get(String pathname,
boolean specific,
int skip)
Gets the value(s) for a parameter at the Nth pathname. |
static Vector |
Get(Value value)
Gets the value(s) for a Parameter Value. |
String |
Group_Pathname(String group)
Gets the pathname to a parameter group. |
Configuration |
Group(String group)
Gets the Configuration parameters for a group. |
boolean |
Include_Tracing(boolean enable)
Enables or disables Include file tracing. |
Configuration |
Include()
Includes parameters from include files. |
boolean |
Include(boolean enable)
Enables or disables automatic Include s. |
static void |
main(String[] arguments)
Assemble and report on the contents of a configuration. |
Parameter |
Parameter_at(String pathname)
Gets the parameter or parameter group at a pathname. |
Parameter |
Parameter(String pathname,
boolean specific)
Gets the parameter for a pathname. |
Parameter |
Parameter(String pathname,
boolean specific,
int skip)
Gets the Nth parameter for a pathname. |
static String |
Path_Name_to_Pathname(String pathname)
Gets the Configuration pathname for a Parameter Path_Name. |
static String |
Pathname_Uncle(String pathname)
Gets the pathname for a parameter at the previous group level. |
static String |
Pathname(Parameter parameter)
Gets the Configuration pathaname for a parameter. |
static Class |
Relative_to_Class()
Gets the class relative to which a configuration file may be sought. |
static void |
Relative_to_Class(Class related_class)
Sets the class relative to which a configuration file may be sought. |
boolean |
Remove_Group(String pathname)
Removes a group of parameters at a pathname. |
boolean |
Remove_Specific(String pathname)
Removes the parameter at the specific pathname. |
boolean |
Remove(String pathname)
Removes the all of the effective parameters for the pathname. |
boolean |
Remove(String pathname,
boolean specific)
Removes the parameter(s) at a pathname. |
boolean |
Set_All(String name,
Object value)
Sets all occurances of a parameter with the specified name to have the specified value. |
void |
Set_Conditionally(Parameter parameter)
Conditionally sets parameters in the Configuration to correspond with the contents of another parameter. |
void |
Set_Conditionally(String[][] parameter_table)
Conditionally sets all of the entries of an array of String arrays. |
boolean |
Set_Conditionally(String pathname,
Object value)
Sets the value of a new parameter at a pathname. |
void |
Set(Parameter parameter)
Sets parameters in the Configuration to correspond with the contents of another parameter. |
void |
Set(Parameter parameter,
boolean replace)
Sets parameters in the Configuration to correspond with the contents of another parameter. |
void |
Set(String[][] parameter_table)
Sets all of the entries of an array of String arrays. |
void |
Set(String[][] parameter_table,
boolean replace)
Sets all of the entries of an array of String arrays as Configuration parameters. |
boolean |
Set(String pathname,
Object value)
Sets the value of a parameter at a pathname. |
boolean |
Set(String pathname,
Object value,
boolean replace)
Sets a parameter at a specified pathname location to the value of an Object. |
String |
Source()
Gets the name of the source from which the Configuration parameters have been set. |
Configuration |
Source(String source)
Resets the Configuration from the contents of the source. |
Parameter |
Specific_Parameter(String pathname)
Gets the specific Parameter for a pathname. |
static void |
Usage()
Prints the command line usage syntax. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String ID
public static final String CLASSPATH
public static final String HOST
public static final String USER
public static final String ALIAS
Group(String)
,
Constant Field Valuespublic static final String ENVIRONMENT
Add_Environment()
public static final String INCLUDE
public static boolean Include_Default
Include
state.
public static final String INCLUDE_START
Include
file when tracing is enabled.
public static final String INCLUDE_ERROR
ignored error
report from an Include
file
when tracing is enabled.
public static final String INCLUDE_END
Include
file when tracing is enabled.
public static boolean Include_Tracing_Default
Include
tracing flag.
public static final String CONTINUE_INCLUDE_ON_ERROR_FLAG
INCLUDE
parameter value flag that, when
found at the beginning of the value, causes an error on the
include - the source does not exists - to be ignored and
the include skipped.
public static final String DEFAULTS
public static String Default_Source
public static final Parameter Defaults
configuration
.
The default parameters are:
CLASSPATH
USER
HOST
public static boolean Defaults_Default
Defaults
state.
public static final int PREFER_FIRST_PARAMETER
When a duplicate Assignment parameter pathname is found while
coalescing
the Configuration, give preference
to the first parameter; i.e. remove all but the first of any
duplicate pathname parameters.
public static final int PREFER_LAST_PARAMETER
When a duplicate Assignment Parameter pathname is found while
coalescing
the Configuration, give preference
to the last parameter; i.e. remove all but the last of any
duplicate pathname parameters.
public static final int THROW_ON_DUPLICATE_PARAMETERS
When a duplicate Assignment Parameter pathname is found while
coalescing
the Configuration, a
Configuration_Exception will be thrown.
public static int Duplicate_Parameter_Action_Default
Duplicate_Parameter_Action()
.
public static boolean Case_Sensitive_Default
Case_Sensitive()
state.
public static final String NL
Constructor Detail |
---|
public Configuration()
The Defaults
are used to set the initial parameters. DEFAULTS
is the name of this Configuration.
public Configuration(String source) throws Configuration_Exception
source
- The source String reference for the Configuration
PVL. This may be in the form of a URL representation. If null,
the Default_Source
is used.
IllegalArgumentException
- If the source is not a URL and
no file or system resource can be found with the source name.
Configuration_Exception
- If the source can not be read or
successfully parsed for parameters, INCLUDE
files could
not be included, or there was a problem coalescing the
parameters (probably due to a duplicate parameter name).Configure(String)
,
Include(boolean)
public Configuration(URL url) throws Configuration_Exception
url
- A URL object to use as the source of Configuration
PVL.
Configuration_Exception
- If a stream can not be opened from
the URL, there was a problem while parsing the source for
parameters, INCLUDE
files could not be included, or
there was a problem coalescing the parameters (probably due to a
duplicate parameter name).Configure(URL)
,
Include(boolean)
public Configuration(InputStream stream) throws Configuration_Exception
stream
- An InputStream object to use as the source of
Configuration PVL.
Configuration_Exception
- If there was a problem while parsing
the stream for parameters, INCLUDE
files could not be
included, or there was a problem coalescing the parameters
(probably due to a duplicate parameter name).Configure(InputStream)
,
Include(boolean)
public Configuration(Parameter parameter) throws Configuration_Exception
If the Parameter is null or empty (has the Parameter.UNKNOWN
classification) an empty Configuration with the name Parser.CONTAINER_NAME
is constructed. If the Parameter is an
Assignment it becomes the only parameter in a Configuration with the
name Parser.CONTAINER_NAME
. If the Parameter is an
Aggregate, its Parameter list is copied into the new Configuration
which is given the name of the Aggregate (the Configuration is a
copy of the Parameter).
If automatic include is enabled any INCLUDE
parameters are
processed. Finally, the results are Coalesce
d.
N.B.: Only the provided Parameter is included in the new Configuration; Defaults are not included.
parameter
- The Parameter which will be copied into this
Configuration.
Configuration_Exception
- If the Parameter contents could not
be added to the new Configuration, INCLUDE
files could
not be included, or there was a problem coalescing the results
(probably due to duplicate parameter names).Coalesce()
,
Include(boolean)
public Configuration(Configuration configuration) throws Configuration_Exception
This is the same as constructing a Configuration from a Parameter,
followed by copying over the Configuration characteristics case sensitivity
, duplicate parameter handling
,
Include processing
, Include tracing
, Defaults parameters inclusion
and the filename
if
non-null;
N.B.: The state of this Configuration is used during the
copy, not the state of the copied Configuration. For example, copied
INCLUDE
parameters are processed if automatic Include
is enabled for this Configuration; the
automatic Include state of the Configuration being copied is not
used.
configuration
- The Configuration to be copied.
Configuration_Exception
- If the Parameter contents could not
be added to the new Configuration, or there was a problem
coalescing the results (probably due to duplicate parameter
names).Configuration(Parameter)
Method Detail |
---|
public Object clone()
clone
in class Parameter
Configuration(Configuration)
,
Object.clone()
,
Cloneable
public Vector Get(String pathname, boolean specific)
If specific is true then the values will be obtained from the Specific_Parameter
, otherwise the
Effective_Parameter
will be
used.
pathname
- A parameter pathname.specific
- true if only a parameter at the specific
pathname is acceptable, otherwise default values from an
effective parameter will do.
public Vector Get(String pathname, boolean specific, int skip)
pathname
- A parameter pathname.specific
- true if only a parameter at the specific
pathname is acceptable, otherwise default values from an
effective parameter will do.skip
- The number of matching parameters to skip
before selecting a parameter.
Get(String, boolean)
,
Parameter(String, boolean, int)
public Vector Get_Specific(String pathname)
This is the same as using the Get
method with the specific argument being true.
pathname
- A parameter pathname.
public String Get_Specific_One(String pathname)
pathname
- A parameter pathname.
Get_Specific(String)
,
Get_One(Vector)
public Vector Get(String pathname)
This is the same as using the Get
method with the specific argument being false.
pathname
- A parameter pathname.
public String Get_One(String pathname)
pathname
- A parameter pathname.
Get(String)
,
Get_One(Vector)
public Vector Get_Linked(String pathname)
A linked parameter is an assignment of a single String value in which the value is the pathname of some other effective parameter. If the parameter has more than one value it is not linked. The returned Vector contains the value(s) of the first non-linked parameter found. An empty Vector will be returned if no parameter is found.
pathname
- A parameter pathname.
public String Get_Linked_One(String pathname)
pathname
- A parameter pathname.
Get_Linked(String)
,
Get_One(Vector)
public Vector Get(Parameter parameter)
parameter
- The Parameter from which to get value(s).
Get(Value)
public String Get_One(Parameter parameter)
parameter
- The Parameter from which to get a value.
Get(Parameter)
,
Get_One(Vector)
public static Vector Get(Value value)
value
- The Value from which to get value(s).
public String Get_One(Value value)
value
- The Value from which to get a value.
Get(Value)
,
Get_One(Vector)
public static String Get_One(Vector values)
values
- The Vector to search.
Get_One(Vector, int)
public static String Get_One(Vector values, int index)
The Vector is searched for the first non-Vector Object and its
toString
value is returned. Vector Objects
are searched as they are encountered (i.e. depth-wise). Since the
Vector is presumed to be the values Vector returned from a Get
method, the first non-Vector Object should be the first String value
of a Configuration parameter (nevertheless, all Objects should have
a toString method).
values
- The Vector to search.index
- The index of the element in the values.
public double Get_Number(String pathname, double default_value)
The first available parameter value found at the pathname is converted to a binary double value.
pathname
- A parameter pathname.default_value
- The default value to use if the parameter can
not be found.
public boolean Enabled(String pathname, boolean default_flag)
The first available parameter value found at the pathname is examined for a logically true value. A paremeter is considered to have a logically true value if it is any one of (case ignored): "ENABLED", "TRUE", "YES", "ON", "Y", or "1".
pathname
- A parameter pathname.default_flag
- The default value to use if the parameter can
not be found.
public Configuration Group(String group) throws Configuration_Exception
All parameters for a named group, plus all default parameters for
the group, are collected into a new Configuration that will have the
name of the group. Default parameters are all Assignment parameters
in all parents of the group parameter. These parameters are Set_Conditionally
in the new configuration such that parameters closest to the group
(a parent is closer than a grandparent) have precedence when there
are parameters with the same name.
If an Assignment parameter with the group name is found instead of
an Aggregate parameter, its value is taken to be the name of the
Aggregate parameter name to use. Such a parameter is a "link" to the
actual group parameter, which gives the group parameter an "alias"
name. This allows configuration parameter groups to be known by
different names. Link parameters may refer to other link parameters.
If the extracted configuration is an alias it will be given an
ALIAS
parameter having the value that is
the name of the alias group.
group
- The name of the configuration group to extract.
Configuration_Exception
- If the Parameter group could not be
assembled into a new Configuration.public boolean Set(String pathname, Object value, boolean replace) throws Configuration_Exception
The Object may be of any type acceptable for use in creating a Parameter Value. This includes Vectors of Objects which will set the parameter to the corresponding Value array. A null value will result in an empty, Token, parameter.
When the value of an existing parameter is not to be replaced, the
availability of an Effective_Parameter
is sufficient to prevent the creation of a new
parameter. However, when replace is true, a parameter will be
created at the specific pathname if it does not already exist.
Note: If an existing parameter is found for the pathname,
whether specific or effective, that does not have a value, its
always assigned the new value.
Only parameters assigned a value - not parameter groups - may have their value set. If the parameter does not exist a new parameter is created and assigned the value.
pathname
- The pathname of the parameter whose value is to
be set.value
- The value that will be assigned to the parameter.replace
- If true, replace the values of existing parameters
with the new value; if false, do not replace existing values.
Configuration_Exception
- If a new parameter could not be
created (possibly because the pathname is null), or the value
could not be set.Parameter.Value(Object)
public boolean Set(String pathname, Object value) throws Configuration_Exception
A new parameter is created with the value if a parameter with the
pathname does not exist. Otherwise the existing value is replaced.
This is the same as using the Set
method with a replace argument of true.
pathname
- The pathname of the parameter whose value is to
be set.value
- The value that will be assigned to the parameter.
Configuration_Exception
Set(String, Object, boolean)
public boolean Set_Conditionally(String pathname, Object value) throws Configuration_Exception
A new parameter is created with the value if a parameter with the
pathname does not exist. Otherwise the existing value is left
unchanged. This is the same as using the Set
method with a replace argument of false.
pathname
- The name of the new parameter.value
- The value that will be assigned to the parameter.
Configuration_Exception
- If there was a problem setting any
parameter value.Set(String, Object, boolean)
public void Set(String[][] parameter_table, boolean replace) throws Configuration_Exception
Each entry of the primary array is taken to be an array of Strings. The first String is a parameter pathname and all remaining Strings in the array are values for the parameter. A parameter pathname without any following parameter value(s) will be skipped.
parameter_table
- The table of parameter names and
values.replace
- If true, replace the values of existing parameters
with the new value; if false, do not replace existing values.
Configuration_Exception
- If there was a problem setting any
parameter value.Set(String, Object, boolean)
public void Set(String[][] parameter_table) throws Configuration_Exception
An existing parameter has its value replaced, otherwise a new parameter is created
parameter_table
- The table of parameter names and
values.
Configuration_Exception
- If there was a problem setting any
parameter value.Set(String[][], boolean)
,
Set(String, Object)
public void Set_Conditionally(String[][] parameter_table) throws Configuration_Exception
New parameters are created; existing parameters are unchanged.
parameter_table
- The table of parameter names and
values.
Configuration_Exception
- If there was a problem setting any
parameter value.Set(String[][], boolean)
,
Set_Conditionally(String, Object)
public void Set(Parameter parameter, boolean replace) throws Configuration_Exception
For an Assignment parameter, a parameter in the Configuration at the same pathname location is assigned the same parameter value. For a parameter group, all of its members are recursivley set in the Configuration.
The pathname
of each parameter that
is set is made to appear to be rooted at the Configuration root.
Thus the location of each parameter set in the Configuration will
be at the same relative location of the source parameter in its
own hierarchy according to its own pathname. Referencing a
source parameter nested somewhere down in a hierachy will then
produce a Configuration parameter that is nested down to the same
relative location. However, when the intention is to root
the Configuration parameters relative to the source parameter being
at the root itself, then the source parameter should be copied
before being provided to this method:
Set (new Parameter (parameter), replace);
Note: Freestanding source parameters (that are not located in a group hierarchy) set Configuration parameters located at the root.
parameter
- The source Parameter for setting in the
Configuration.replace
- If true, replace the values of existing parameters
with the new value; if false, do not replace existing values.
Configuration_Exception
- If there was a problem setting
any parameter in the Configuration.Set(String, Object, boolean)
public void Set(Parameter parameter) throws Configuration_Exception
An existing Configuration parameter has its value replaced, otherwise a new parameter is created
parameter
- The source Parameter for setting in the
Configuration.
Configuration_Exception
- If there was a problem setting any
parameter value.Set(Parameter, boolean)
public void Set_Conditionally(Parameter parameter) throws Configuration_Exception
New parameters are created; existing parameters are unchanged.
parameter
- The source Parameter for setting in the
Configuration.
Configuration_Exception
- If there was a problem setting any
parameter value.Set(Parameter, boolean)
,
Set_Conditionally(String, Object)
public boolean Set_All(String name, Object value) throws Configuration_Exception
Only existing parameters have their value reset. If there are no parameters with the specified name, no new parameter is created.
name
- The parameter name to find. This should be a simple
name, not a pathname. If a pathname is specified, then only
parameters at the pathname will be modified; an absolute
pathname can only apply to a single parameter, but a relative
pathname may apply to more than one.value
- The Object to be assigned as the value of each
parameter found.
Configuration_Exception
- If there was a problem replacing a
parameter's value.public boolean Remove(String pathname, boolean specific)
pathname
- A parameter pathname.specific
- If true, remove only the parameter at the
specific pathname, otherwise remove all effective parameters
for the pathname.
public boolean Remove(String pathname)
This is the same as using the Remove
method with the specific argument being false.
pathname
- A parameter pathname.
public boolean Remove_Specific(String pathname)
This is the same as using the Remove
method with the specific argument being true.
pathname
- A parameter pathname.
public boolean Remove_Group(String pathname)
The group of parameters at the pathname is removed.
pathname
- A group pathname.
public String Source()
DEFAULTS
if
the Configuration is based soley on the internal default
parameters. It will be the Parser.CONTAINER_NAME
if the
Configuration was constructed from an Assignment Parameter
(including an empty Parameter) rather than an Aggregate. If the
Configuration was constructed from an Aggregate Parameter it
will be the name of the Aggregate Parameter.public String Filename()
Source()
public Configuration Source(String source) throws Configuration_Exception
source
- The name of the configuration source.
Configuration_Exception
- If the source can not be read or
successfully parsed for parameters, or there was a problem
coalescing the parameters (probably due to a duplicate
parameter name).Configure(String)
public Configuration Filename(String filename) throws Configuration_Exception
Source(String)
filename
- The name of the configuration file.
Configuration_Exception
public static void Default_Source(String source)
source
- The name of the new default source. If null, the
DEFAULTS
name will be used.public static void Default_Filename(String filename)
Default_Source(String)
filename
- The new default filename. If null, the DEFAULTS
name will be used.public static String Default_Source()
Default_Source(String)
public static String Default_Filename()
Default_Source()
public static void Relative_to_Class(Class related_class)
related_class
- The Class related to the configuration file
to be loaded.Configure(String)
public static Class Relative_to_Class()
Relative_to_Class(Class)
public boolean Case_Sensitive(boolean enable)
enable
- If true, case sensitive matching is used.
public boolean Case_Sensitive()
Case_Sensitive(boolean)
public boolean Defaults(boolean enable)
Defaults
parameters.
N.B.: This method controls the automatic inclusion of Defaults
parameters for subsequent Configure operations. The
default automatic defaults
state is
applied to the construction of new Configuration objects.
enable
- true if Defaults parameters are to be automatically
included; false otherwise.
public String Description()
The description is suitable for saving to a file for later input.
Description
in class Parameter
Parameter.Description(Lister)
public void Configure(String source) throws Configuration_Exception
If the source String is null or empty, the Default_Source
String is used. If this is null the DEFAULTS
name is used.
If the source String equals the DEFAULTS
name the
Configuration is loaded from a null
stream
.
If a URL can be constructred from the source String the Configuration
is loaded from the URL
.
An attempt is made to open a file input stream use the source String
as the file's pathname. If this fails and the source String is a
simple filename - it has no directory components - the user's home
directory pathname is prepended and another attempt is made to open a
file input stream (unless the simple filename is for the same file in
the user's home directory). If a stream is opened it is used to
load
the Configuration.
The source String is then treated as a system resource location
in
the JVM classpath. This includes finding configuration files located
in jar files. If this fails, a relative-to Class
has been specified and the source String is a
simple filename then the class's package pathname, if it can be
determined, is prepended to the source name and another attempt is
made to locate the system resource. If a system resource location is
found the Configuration is loaded from the
URL
.
When a input source is found the Source
is set to
the name of the source. If the source is a local file the absolute
pathname will be used. If the source is a URL, including a system
resource location URL, the URL will be used.
source
- A URL specification, pathname of a disk file or jar
resource, or the special DEFAULTS
name. If
null, the Default_Source
will be
used.
Configuration_Exception
- If the source does not refer to a
source that can be found, read or successfully parsed for
parameters, or there was a problem coalescing the parameters
(probably due to a duplicate parameter name).
IllegalArgumentException
- If no configuration source can be
found for the source name.Configure(URL)
,
Configure(InputStream)
,
Source()
public void Configure(URL url) throws Configuration_Exception
The URL is used to open an InputStream as a source of configuration
parameters. If the URL is null then a null stream will be used. If a
stream is successfully opened from the URL, then the Configuration's
Source
will be set to the URL String. The
Configuration is loaded from the
InputStream
.
url
- The URL source of configuration parameters. May be null.
Configuration_Exception
- If an InputStream can not be opened
from the URL, the stream could not be successfully parsed for
parameters, or there was a problem coalescing the parameters
(probably due to a duplicate parameter name).Configure(InputStream)
public void Configure(InputStream stream) throws Configuration_Exception
The stream is parsed for configuration parameters and their values (parameter = value).
This method will first Remove_All
current parameters from the Configuration. The InputStream is used
to construct a Parser from which all available parameters are Add
ed into this Configuration. If automatic
Defaults
are enabled the internal
parameter Defaults
are then Set_Conditionally
. If automatic file
Include
s is enabled any INCLUDE
parameters are found and the parameters from the files they
reference are Include
d. Finally all parameters
are Coalesce
d together.
If, however, the InputStream is null, then only the Defaults will be
used.
The Configuration's Source
will be
set to the special DEFAULTS
name.
If this Configuration's Source is not null, then the Name
will be set to the same String; otherwise it
will simply be set to "InputStream."
stream
- The InputStream source of configuration parameters.
Configuration_Exception
- If the stream can not be read or
successfully parsed for parameters, or there was a problem
coalescing the parameters (probably due to a duplicate
parameter name).Parser.Parser(InputStream)
public Configuration Add_Environment() throws Configuration_Exception
All environment variables that can be obtained from the runtime
environment are added to the ENVIRONMENT
group. If the
group doesn't exist, it is appended to the end of the Configuration.
Each environment variable is used to conditionally set a parameter
in the Environment group; i.e. any existing parameters with the same
name as an environment variable do not have their values changed.
The value of an environment variable is always a single String
regardless of embedded spaces or commas.
Configuration_Exception
Host.Environment()
public boolean Include(boolean enable)
Include
s.
N.B.: This method controls the automatic include state for
subsequent Configure operations. The Include_Default
state is applied to the construction of new
Configuration objects.
enable
- true if automatic file includes is enabled;
false otherwise.
public boolean Include_Tracing(boolean enable)
Include
file tracing.
Include file tracing inserts a TOKEN parameter at the beginning of the included parameters with a name of the form:
INCLUDE_START:source
where source is the URL or canonical pathname of the file
that was included. At the end of the included parameters another
TOKEN is inserted that has the same form, but with "START" replaced
by "END". If the source can not be found and the CONTINUE_INCLUDE_ON_ERROR_FLAG
is specified as the include file
prefix, then a parameter with a name of the same form, but with
"START" replaced by "ERROR", is inserted, and its value is the error
message.
Warning: When the resulting parameters are Coalesce
d the included parameters may be moved to new locations
outside the INCLUDE_START to INCLUDE_END sequence. Thus include file
tracing can only be advisory.
N.B.: This method controls include file tracing for
subsequent Configure operations. The Include_Tracing_Default
state is applied to the construction of
new Configuration objects.
enable
- true if include file tracing is enabled;
false otherwise.
public Configuration Include() throws Configuration_Exception
Every parameter named INCLUDE
is replaced with the
parameters included from the file named by the parameter's value.
The value may contain nested parameter references that are Resolve
d against the parameters
currently in the Configuration; this includes all parameters that
have been included so far.
Relative pathnames for include files are taken to be relative to the
directory of the file that contains the include parameter, if this
can be determined. This will be the location of the Configuration
file
itself for top level include parameters.
Include parameters may refer to a URL. If this is a "file" URL, then
its directory can be used for relative includes contained within it.
Other types of URLs may also be used, but they may not contain
include parameters with relative filename references. Relative
filename references that do not have a including file from which a
directory can be determined (URLs or a Configuration that was not
constructed from a file with an identified pathname) will be located
using the same process as that used to Configure
from a source name.
Recursive includes - an include parameter that refers to a parent include file - are not allowed (throw a Configuration_Exception).
Parameters that are Aggregates or the Value is an Array are ignored.
An include reference that begins with the CONTINUE_INCLUDE_ON_ERROR_FLAG
will not cause an exception to be
thrown if the reference can not be accessed. This is particularly
useful if the existence of the include file is uncertain and its
lack is acceptable.
Configuration_Exception
- If an include filename contains a
nested reference that can not be resolved; would result in a
recursive include; does not refer to a source that can be
found, read or successfully parsed for parameters; or there was
a problem coalescing its parameters (probably due to a
duplicate parameter name).public static String Pathname_Uncle(String pathname)
The Basename
is removed from the pathname.
Then the pathname is shortened by one additional segment and the
basename appended back again. This has the effect of producing a
pathname with the same basename but at the same level as the parent
(thus it is the "uncle" to the original pathname :-). This is used
when percolating up a Parameter hierarchy looking for an effective
(default) parameter of a given name.
pathname
- The pathname to modify.
public static String Path_Name_to_Pathname(String pathname)
A Parameter Path_Name
includes the
name of the root Aggregate parameter. A Configuration pathname does
not include the root name segment.
pathname
- A Parameter Path_Name.
public static String Pathname(Parameter parameter)
parameter
- A parameter.
Path_Name_to_Pathname(String)
public String Effective_Pathname(String pathname)
The effective pathname is the pathname of the Effective_Parameter
for the pathname.
pathname
- A parameter pathname.
public String Group_Pathname(String group)
Links will be followed: When an Assignment Parameter with the name of the group is found its value will be taken as the new group name to be sought until an Aggregate Parameter is found. A link chain is not allowed to loop back to the original group name.
group
- The name of an Aggregate Parameter to be found.
public Parameter Parameter(String pathname, boolean specific)
When specific is false and there is no parameter in the
Configuration at the specified pathname location, then a parameter
with the same Basename
is sought at
progressively higher levels of the path. The first parameter found
is returned, or null if no parameter is found.
Note: Only an Assignment (or Token) parameter will be found. Aggregate parameters do not qualify because they have no value. A Token has no value but can be assigned one.
pathname
- A parameter pathname.specific
- true if only a parameter at the specific
pathname is acceptable, otherwise an effective parameter will
do.
Pathname_Uncle(String)
public Parameter Parameter(String pathname, boolean specific, int skip)
The parameter is selected after skip parameters have been found that match the pathname. If skip is 0, the first matching parameter is selected; if skip is N, N matching parameters must be found before the next matching parameter will be selected.
pathname
- A parameter pathname.specific
- true if only a parameter at the specific
pathname is acceptable, otherwise an effective parameter will
do.skip
- The number of matching parameters to skip.
Parameter(String, boolean)
public Parameter Parameter_at(String pathname)
Only the parameter at the specific pathname will be found. This is
similar to the Parameter
method
used with specific=true. But unlike that method, this method may
return an Aggregate if that is what is found.
pathname
- A parameter pathname.
public Parameter Specific_Parameter(String pathname)
This is the same as using the Parameter
method with the specfic
argument being true.
pathname
- A parameter pathname.
public Parameter Effective_Parameter(String pathname)
This is the same as using the Parameter
method with the specific argument being false.
pathname
- A parameter pathname.
public Configuration Duplicate_Parameter_Action(int action)
One of these actions may be specified:
The default action is to THROW_ON_DUPLICATE_PARAMETERS.
action
- The duplicate parameter action.
Coalesce()
public int Duplicate_Parameter_Action()
Duplicate_Parameter_Action(int)
public void Coalesce() throws Configuration_Exception
Each Aggregate in the current list is compared, by name, against all other Aggregates in the list. When a duplicate name is found the parameters it contains are added to the end of the first parameter in the list having the same name. Finally each Aggregate is recursively coalesced in the same manner.
In addition, all Assignment (i.e. non-Aggregate) parameters in each Aggregate are checked for duplicates and moved to the front of the list of parameters.
The action taken when duplicate Assignment Parameter is encountered
depends on the current Duplicate_Parameter_Action
. Byt default the actions is to throw
a Configuration_Exception.
Configuration_Exception
- If there was a duplicate Assignment
parameter and the Duplicate_Parameter_Action is
THROW_ON_DUPLICATE_PARAMETERS, or there was a problem moving
parameters around in the list.public static void main(String[] arguments)
The command line syntax is described by the Usage
method.
Exit status:
0 - Success
1 - Command line syntax problem
2 - Unable to assemble the configuration
3 - The source file could not be found
public static void Usage()
Usage: Configuration <Options> <source> Options - -Query | -Find <pathname> [-Not_]Case_sensitive -Pattern
Only the source of the configuration parameters is required. This may be a filename or a URL.
The entire configuration, with all included configurations, will be
listed unless a specific parameter pathname is specified with the
-query or -find option. The only difference between -query and -find
is that the former never lists parameter comments. A parameter
pathname may be absolute or relative. All parameters having the
pathname will be listed. Pathname matching is not case sensitive
unless the -case_sensitive option is specified. If -pattern is
specified the pathname is taken to be a regular expression
Pattern
. The -query/-find option may be
used more than once to find more than one parameter.
N.B.This method always results in a System.exit with a status of 1.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |