|
Rule Execution Server API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ilog.rules.util.resources.IlrResources
public final class IlrResources
This class manages a resource bundle used for configuring the engine.
A resource bundle is a list of properties with associated values.
During creation, the user can specify the initial resources to
load into the bundle. Later on, the user can call one of the methods
for loading more resources. Each time a resource stream is loaded, a
symbolic name is appended to a list. This provides a mean for identifying
the resource streams which have been loaded and to avoid loading a same
stream several times. Moreover, the class may be set a
ClassLoader
to be used for finding the resource files.
See the User's Manual for more details.
Constructor Summary | |
---|---|
IlrResources()
Constructs a resource bundle with no arguments. |
|
IlrResources(boolean init)
Constructs a resource bundle with a boolean argument. |
|
IlrResources(IlrResources initial)
Constructs a resource bundle using another resource bundle. |
|
IlrResources(Reader reader)
Constructs a resource bundle and initializes its content using a reader. |
Method Summary | |
---|---|
void |
clear()
Clears the properties and their associated values in this resource bundle. |
void |
clearToDefaults()
Clears all the properties and their associated values, and then loads the engine's default settings from the file /ilog/rules/engine/engine.conf provided in the
IBM Decision server engine
Jar files. |
boolean |
containsKey(String key)
Tests whether a particular string is a key of the property map. |
boolean |
containsName(String name)
Tests if a stream of some name has already been loaded. |
Set |
entrySet()
Returns a set view of the hash table used to manage the associations between property names and their values. |
boolean |
forClass(Class cl)
Loads a resource stream using a class. |
boolean |
forObject(Object obj)
Loads a resource stream using an object. |
boolean |
forPackage(String pkg)
Loads a resource stream using a package name. |
Object |
get(String key,
Object def)
Gets the property value associated to a key and returns a default value is the key does not exist. |
Object[] |
getArray(String key,
Object[] def)
Gets the property value associated to a key as an array of objects and returns a default value is the key does not exist. |
boolean |
getBoolean(String key,
boolean def)
Gets the property value associated to a key as a boolean value and returns a default value is the key does not exist. |
boolean[] |
getBooleanArray(String key,
boolean[] def)
Gets the property value associated to a key as an array of booleans and returns a default value is the key does not exist. |
char |
getChar(String key,
char def)
Gets the property value associated to a key as a char and returns a default value is the key does not exist. |
char[] |
getCharArray(String key,
char[] def)
Gets the property value associated to a key as a char array and returns a default value is the key does not exist. |
ClassLoader |
getClassLoader()
Gets the class loader previously set. |
double |
getDouble(String key,
double def)
Gets the property value associated to a key as a double and returns a default value is the key does not exist. |
double[] |
getDoubleArray(String key,
double[] def)
Gets the property value associated to a key as a double array and returns a default value is the key does not exist. |
float |
getFloat(String key,
float def)
Gets the property value associated to a key as a float and returns a default value is the key does not exist. |
float[] |
getFloatArray(String key,
float[] def)
Gets the property value associated to a key as a float array and returns a default value is the key does not exist. |
int |
getInt(String key,
int def)
Gets the property value associated to a key as an int and returns a default value is the key does not exist. |
int[] |
getIntArray(String key,
int[] def)
Gets the property value associated to a key as an int array and returns a default value is the key does not exist. |
long |
getLong(String key,
long def)
Gets the property value associated to a key as a long and returns a default value is the key does not exist. |
long[] |
getLongArray(String key,
long[] def)
Gets the property value associated to a key as a long array and returns a default value is the key does not exist. |
String |
getName()
Gets the resource name which has been appended the most lately, i.e. |
String[] |
getNames()
Gets the names of the resource streams that have been loaded. |
String |
getString(String key,
String def)
Gets the property value associated to a key as a string and returns a default value is the key does not exist. |
String[] |
getStringArray(String key,
String[] def)
Gets the property value associated to a key as an array of strings and returns a default value is the key does not exist. |
boolean |
load(InputStream str)
Loads a resource stream using an InputStream . |
boolean |
load(Reader reader)
Loads a resource stream using a reader. |
boolean |
load(String filename)
Loads a resource stream using a file name. |
void |
put(String key,
Object value)
Adds or rebinds the value associated to a property name. |
void |
putAll(IlrResources resources)
Puts all the properties and values stored in the argument resource bundle into the current bundle. |
void |
putBoolean(String key,
boolean value)
Adds or rebinds a boolean value associated to a property name. |
void |
putChar(String key,
char value)
Adds or rebinds a char value associated to a property name. |
void |
putDouble(String key,
double value)
Adds or rebinds a double value associated to a property name. |
void |
putFloat(String key,
float value)
Adds or rebinds a float value associated to a property name. |
void |
putInt(String key,
int value)
Adds or rebinds a int value associated to a property name. |
void |
putLong(String key,
long value)
Adds or rebinds a long value associated to a property name. |
void |
putString(String key,
String value)
Adds or rebinds a string value associated to a property name. |
Object |
remove(String key)
Removes an entry using its key if it exists. |
void |
setClassLoader(ClassLoader cl)
Sets a class loader. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IlrResources()
true
in order to load the initial default resources.
public IlrResources(boolean init)
false
, the resource bundle is left
empty.
If it is true
, then the resource file
/ilog/rules/engine/engine.conf
provided in the IBM
Decision Server engine Jar
files is loaded. Following this, one of the following files is loaded:
/META-INF/engine.conf
. If it exists, it is loaded and
the next step is skipped.
ilog.rules.engine.config.file
, provided
that the property is defined and the file exists.
The later operation is subject to the existence of the file and to the permission of the security manager. If the file does not exist, or the file can not be read, or permission is not granted for reading that file, the loading will simply be ignored.
public IlrResources(Reader reader)
reader
- A reader to load.public IlrResources(IlrResources initial)
Method Detail |
---|
public ClassLoader getClassLoader()
null
if no class loader
has been set.public void setClassLoader(ClassLoader cl)
cl
- A class loader.public void clear()
public void clearToDefaults()
/ilog/rules/engine/engine.conf
provided in the
IBM Decision server engine
Jar files. After this call, the resource bundle will contain only
the IBM Decision server default settings.
public void putAll(IlrResources resources)
resources
- A resource bundle from which the properties and
values are copied.public Set entrySet()
Map.Entry
. For more details, refer to
the entrySet()
method of the Hashtable
class.
public boolean load(Reader reader)
meta.name
will be appended to the list
of names if the list does not already contain this name. In other words,
if this is the first time that the reader is loaded and if the content
defines a string value for meta.name
property, and
provided that
there is no resource stream having the same name, then the name will
be appended to the list.
Later on, you could know which resource streams have been loaded and implement specific code for loading resource streams only if they have not been loaded. Care should be taken in assigning a meaningful name. If the resource stream is for a package, then a package name is good for identifying the stream.
reader
- The resource stream to load.
true
if the stream contains well formed properties,
and false
if the stream raises syntax errors or I/O
exceptions.public boolean load(InputStream str)
InputStream
. This method
redirects the loading to the method using Reader
. If the
property ilog.rules.engine.encoding
is defined, its value
is taken as the encoding for this operation. Otherwise, the system's
default encoding is applied.
str
- The resource stream to load.
true
if the stream contains well formed properties,
and false
if the stream raises syntax errors or I/O
exceptions.load(java.io.Reader)
public boolean load(String filename)
Reader
and applies
the same encoding as for load(java.io.InputStream)
.
true
if the stream contains well formed properties,
and false
if the stream raises syntax errors or I/Oload(java.io.Reader)
public boolean forPackage(String pkg)
com.sun.mypackage
. This
method looks for a resource stream named
/com/sun/mypackage/engine.conf
. If one is found, it is
loaded using the load(java.io.InputStream)
method.
pkg
- A well formed Java package name.
true
if the stream is found and its content is
well-formed, and false
if the stream is not found or
there are syntax errors, or there are I/O exceptions.load(java.io.InputStream)
public boolean forClass(Class cl)
engine.conf
to the passed class. If the
stream is found, it is loaded
using the load(java.io.InputStream)
method.
cl
- A Java class.
true
if the stream is found and its content is
well-formed, and false
if the stream is not found or
there are syntax errors, or there are I/O exceptions.load(java.io.InputStream)
public boolean forObject(Object obj)
forClass
.
obj
- An object.
true
if the stream is found and its content is
well-formed, and false
if the stream is not found or
there are syntax errors, or there are I/O exceptions.forClass(java.lang.Class)
public String[] getNames()
load(java.io.Reader)
public String getName()
null
.public boolean containsName(String name)
name
- The name of the resource stream.
true
if the name is part of the loaded name list,
and false
otherwise.public Object get(String key, Object def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public Object[] getArray(String key, Object[] def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public String getString(String key, String def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public String[] getStringArray(String key, String[] def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public boolean getBoolean(String key, boolean def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public boolean[] getBooleanArray(String key, boolean[] def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public char getChar(String key, char def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public char[] getCharArray(String key, char[] def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public int getInt(String key, int def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public int[] getIntArray(String key, int[] def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public long getLong(String key, long def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public long[] getLongArray(String key, long[] def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public float getFloat(String key, float def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public float[] getFloatArray(String key, float[] def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public double getDouble(String key, double def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public double[] getDoubleArray(String key, double[] def)
key
- The property name.def
- The default value to be returned if the key does not exist.
def
if
the key does not exist.public Object remove(String key)
key
- The property name.
null
if the key is not an entry.public boolean containsKey(String key)
key
- The property name.
true
is the passed argument is a key.public void put(String key, Object value)
key
- The property name.value
- The property value.public void putString(String key, String value)
key
- The property name.value
- The property value.public void putBoolean(String key, boolean value)
key
- The property name.value
- The property value.public void putChar(String key, char value)
key
- The property name.value
- The property value.public void putInt(String key, int value)
key
- The property name.value
- The property value.public void putLong(String key, long value)
key
- The property name.value
- The property value.public void putFloat(String key, float value)
key
- The property name.value
- The property value.public void putDouble(String key, double value)
key
- The property name.value
- The property value.
|
Rule Execution Server API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |