|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.as400.registry.RegistryNode
The representation of a node in a hierarchical collection of configuration
information. RegistryNode
provides methods that let applications
store and retrieve configuration data. The data is stored persistently in
an implementation-dependent backing store. Applications need not concern
themselves with the type of backing store being used.
Methods that modify registry data operate asynchronously, i.e. changes
need not be immediately propagated to the backing store. The method
flush
may be used to force updates to the backing store.
Within a single process, there is at most one RegistryNode
which represents a particular node in the registry hierarchy. It follows that
if n1
and n2
are references to RegistryNode
objects representing the same location in the hierarchy, then n1 == n2
.
import com.ibm.as400.registry.*; ... try { // Get the application registry ApplicationRegistry reg = (ApplicationRegistry)Registry.getInstance(); // Get the user namespace root for the current user RegistryNode root = reg.getRoot(Registry.USER_ROOT); // Get the "preferences" node for this user, creating it if necessary RegistryNode prefs = root.createNode("preferences"); // Store some preferences prefs.putValue("Favorite Ice Cream", "vanilla"); prefs.putValue("Favorite Music", "Steely Dan"); // Commit changes to the backing store prefs.flush(); } catch (RegistryException e) { e.printStackTrace(); }
Registry
,
WindowsRegistry
,
ApplicationRegistry
,
LDAPRegistry
Method Summary | |
void |
addNodeChangeListener(NodeChangeListener ncl)
Adds the specified listener to receive NodeChangeEvent s
for this RegistryNode . |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Adds the specified listener to receive PropertyChangeEvent s
for this RegistryNode . |
void |
clear()
Removes all attribute-value pairs from this node. |
RegistryNode |
createNode(java.lang.String path)
Returns the specified RegistryNode , creating it and any of
its ancestors if they do not already exist. |
void |
flush()
Forces any changes to the contents of this RegistryNode
and its descendants to the persistent store. |
java.lang.String[] |
getAttributes()
Returns all of the attributes that have an associated value in this RegistryNode . |
boolean |
getBooleanValue(java.lang.String attribute,
boolean defaultValue)
Returns the boolean value associated with the specified attribute in this RegistryNode . |
byte[] |
getByteValue(java.lang.String attribute,
byte[] defaultValue)
Returns the byte array value associated with the specified attribute in this RegistryNode . |
RegistryNode[] |
getChildren()
Returns the children of this RegistryNode . |
java.lang.String |
getFullName()
Returns this RegistryNode 's absolute path name
within the current namespace. |
int |
getIntValue(java.lang.String attribute,
int defaultValue)
Returns the integer value associated with the specified attribute in this RegistryNode . |
java.lang.String |
getName()
Returns this RegistryNode 's name, relative to its parent. |
java.lang.String |
getNamespace()
Returns an indicator identifying which namespace this RegistryNode
belongs to. |
RegistryNode |
getNode(java.lang.String path)
Returns the specified RegistryNode . |
java.lang.Object |
getObjectValue(java.lang.String attribute,
java.lang.Object defaultValue)
Returns the Object associated with the specified attribute
in this RegistryNode . |
RegistryNode |
getParent()
Returns the parent of this RegistryNode , or null
if this is a namespace root. |
long |
getUnsignedIntValue(java.lang.String attribute,
long defaultValue)
Returns the unsigned integer value associated with the specified attribute in this RegistryNode . |
java.lang.String |
getValue()
Returns the default value for this RegistryNode . |
java.lang.String |
getValue(java.lang.String attribute)
Returns the value associated with the specified attribute in this RegistryNode . |
boolean |
isBoolean(java.lang.String attribute)
Indicates whether the value associated with the specified attribute is a boolean. |
boolean |
isByteArray(java.lang.String attribute)
Indicates whether the value associated with the specified attribute is a byte array. |
boolean |
isInteger(java.lang.String attribute)
Indicates whether the value associated with the specified attribute is an integer. |
boolean |
isModified()
Indicates whether this object has been modified. |
boolean |
isObject(java.lang.String attribute)
Indicates whether the value associated with the specified attribute is an Object . |
boolean |
isString(java.lang.String attribute)
Indicates whether the value associated with the specified attribute is a String. |
boolean |
isUnsignedInteger(java.lang.String attribute)
Indicates whether the value associated with the specified attribute is an unsigned integer. |
boolean |
nodeExists(java.lang.String path)
Determines whether the specified RegistryNode exists. |
void |
putBooleanValue(java.lang.String attribute,
boolean value)
Associates a boolean value with the specified attribute in this RegistryNode . |
void |
putByteValue(java.lang.String attribute,
byte[] value)
Associates a byte array value with the specified attribute in this RegistryNode . |
void |
putIntValue(java.lang.String attribute,
int value)
Associates an integer value with the specified attribute in this RegistryNode . |
void |
putObjectValue(java.lang.String attribute,
java.lang.Object value)
Associates an object with the specified attribute in this RegistryNode . |
void |
putUnsignedIntValue(java.lang.String attribute,
long value)
Associates an unsigned integer value with the specified attribute in this RegistryNode . |
void |
putValue(java.lang.String value)
Assigns the specified default value to this RegistryNode . |
void |
putValue(java.lang.String attribute,
java.lang.String value)
Associates the specified string value with the designated attribute in this RegistryNode . |
java.lang.String |
remove(java.lang.String attribute)
Removes the value associated with the specified attribute in this RegistryNode . |
boolean |
removeNode(java.lang.String path)
Removes the specified RegistryNode and all of its descendants. |
void |
removeNodeChangeListener(NodeChangeListener ncl)
Removes the specified listener so it no longer receives NodeChangeEvent s for this RegistryNode . |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
Removes the specified listener so it no longer receives PropertyChangeEvent s for this RegistryNode . |
java.lang.String |
toString()
Returns a string representation of this RegistryNode . |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Method Detail |
public void flush() throws RegistryException
RegistryNode
and its descendants to the persistent store.
If this RegistryNode
has been created since the last call
to flush
, it and all of its descendants are made permanent
by this operation.
Pending modifications to the registry hierarchy are not automatically flushed on process termination. This is so that applications can abandon pending changes if desired.
public RegistryNode createNode(java.lang.String path) throws RegistryException
RegistryNode
, creating it and any of
its ancestors if they do not already exist.
Accepts either a relative or absolute path name. Absolute path names
begin with '/' and are interpreted relative to the root of the current
namespace. Relative path names begin with any character other than a
slash and are interpreted relative to this RegistryNode
.
The path name "" is valid and refers to this RegistryNode
.
Path names cannot contain any of the characters \ : ? " < > |.
If this call causes nodes to be created, the nodes are not guaranteed to
be persistent until the flush
method is called on this node
or on one of its ancestors.
path
- The path name of the RegistryNode
to return.
Elements of the path should be separated with a slash character '/'.RegistryNode
.path
is null.flush()
public RegistryNode getNode(java.lang.String path) throws NodeNotFoundException, RegistryException
RegistryNode
.
It is assumed that the node already exists in the registry hierarchy.
If it does not, a NodeNotFoundException
will be thrown.
Accepts either a relative or absolute path name. Absolute path names
begin with '/' and are interpreted relative to the root of the current
namespace. Relative path names begin with any character other than a
slash and are interpreted relative to this RegistryNode
.
The path name "" is valid and refers to this RegistryNode
.
Path names cannot contain any of the characters \ : ? " < > |.
path
- The path name of the RegistryNode
to return.
Elements of the path should be separated with a slash character '/'.RegistryNode
.path
is null.createNode(java.lang.String)
public boolean nodeExists(java.lang.String path)
RegistryNode
exists.
Accepts either a relative or absolute path name. Absolute path names
begin with '/' and are interpreted relative to the root of the current
namespace. Relative path names begin with any character other than a
slash and are interpreted relative to this RegistryNode
.
The path name "" is valid and refers to this RegistryNode
.
Path names cannot contain any of the characters \ : ? " < > |.
path
- The path name of the RegistryNode
whose existence
is to be checked. Elements of the path should be separated with a slash character '/'.true
if the specified node exists; false
otherwise.path
is null.public boolean removeNode(java.lang.String path)
RegistryNode
and all of its descendants.
Accepts either a relative or absolute path name. Absolute path names
begin with '/' and are interpreted relative to the root of the current
namespace. Relative path names begin with any character other than a
slash and are interpreted relative to this RegistryNode
.
The path name "" is valid and refers to this RegistryNode
.
Path names cannot contain any of the characters \ : ? " < > |.
The removal of a node is not guaranteed to be permanent until the
flush
method is called on an ancestor of the specified
node.
Once a RegistryNode
has been removed, attempting any
operation on the node other than getNamespace
,
getFullName
, getName
or nodeExists
will result in an IllegalStateException
.
true
if the node was successfully removed;
false
if the node does not exist.public RegistryNode[] getChildren()
RegistryNode
.
The returned array will be of size zero if this node has
no children. The order of the children in the array is undefined.
public RegistryNode getParent()
RegistryNode
, or null
if this is a namespace root.
public java.lang.String getFullName()
RegistryNode
's absolute path name
within the current namespace.
public java.lang.String getName()
RegistryNode
's name, relative to its parent.
Returns "/" if this is a namespace root.
public java.lang.String getNamespace()
RegistryNode
belongs to.
The indicators are defined on the Registry
class.
Registry
public void clear()
public java.lang.String remove(java.lang.String attribute)
RegistryNode
.
Returns the value previously associated with the attribute, or
null
if there was no value associated with
the attribute.
attribute
- The attribute whose mapping is to be removed
from this node. If null
the default value will be removed.RegistryNode
, or null
if the attribute did not have a mapping.public java.lang.String[] getAttributes()
RegistryNode
. Note that the attribute associated
with the default value for a node has no string representation
and will not be included in the returned array.
public java.lang.String getValue()
RegistryNode
.
Equivalent to getValue(null)
.
If no default value has been assigned getValue
will
return null
.
String
.public java.lang.String getValue(java.lang.String attribute)
RegistryNode
.
If the value was not stored as a string, it will be converted
to a string using the appropriate data conversion.
If no value has been assigned to the attribute getValue
will
return null
.
attribute
- The attribute whose value is to be returned.
If null
the default value for this node will be returned.attribute
, in the form of a String
.public int getIntValue(java.lang.String attribute, int defaultValue)
RegistryNode
.
If no value has been assigned to the attribute or the value cannot
be represented as an integer, getIntValue
will
return the specified default value.
attribute
- The attribute whose value is to be returned.
If null
the default value for this node will be returned.defaultValue
- The value to be returned if no value is
assigned to the attribute or the value is not an integer.attribute
.putIntValue(java.lang.String, int)
public long getUnsignedIntValue(java.lang.String attribute, long defaultValue)
RegistryNode
. The value is represented in Java as
a long
.
If no value has been assigned to the attribute or the value cannot
be represented as an unsigned integer, getUnsignedIntValue
will
return the specified default value.
attribute
- The attribute whose value is to be returned.
If null
the default value for this node will be returned.defaultValue
- The value to be returned if no value is
assigned to the attribute or the value is not an unsigned integer.attribute
.putUnsignedIntValue(java.lang.String, long)
public boolean getBooleanValue(java.lang.String attribute, boolean defaultValue)
RegistryNode
.
If no value has been assigned to the attribute or the value cannot
be represented as a boolean, getBooleanValue
will
return the specified default value.
attribute
- The attribute whose value is to be returned.
If null
the default value for this node will be returned.defaultValue
- The value to be returned if no value is
assigned to the attribute or the value is not a boolean.attribute
.putBooleanValue(java.lang.String, boolean)
public byte[] getByteValue(java.lang.String attribute, byte[] defaultValue)
RegistryNode
.
If no value has been assigned to the attribute or the value cannot
be represented as a byte array, getByteValue
will
return the specified default value.
attribute
- The attribute whose value is to be returned.
If null
the default value for this node will be returned.defaultValue
- The value to be returned if no value is
assigned to the attribute or the value is not a byte array.attribute
.putByteValue(java.lang.String, byte[])
public java.lang.Object getObjectValue(java.lang.String attribute, java.lang.Object defaultValue)
Object
associated with the specified attribute
in this RegistryNode
.
If no value has been assigned to the attribute, getObjectValue
will return the specified default value.
This method will attempt to return a clone of the object in the registry
by calling its public clone
method.
No exception is thrown if the object's class does not implement
clone
. However, since the registry cache will
contain a direct reference to the returned object, subsequent changes
to the object's state will be immediately reflected in the registry.
If this is not the desired behavior, the object's class should
implement the Cloneable
interface and a public
clone
method. Note that for the clone
method
to be accessible the application class must be a public class.
attribute
- The attribute whose value is to be returned.
If null
the default value for this node will be returned.defaultValue
- The Object
to be returned if no value is
assigned to the attribute or the value is not an Object
.attribute
.putObjectValue(java.lang.String, java.lang.Object)
public void putValue(java.lang.String value)
RegistryNode
.
Equivalent to putValue(null, value)
.
value
- The default value to be associated with this node.value
is null.public void putValue(java.lang.String attribute, java.lang.String value)
RegistryNode
.
attribute
- The attribute with which the specified value is
to be associated. If null
, the value will be treated as
the default value for this node.value
- The string value to be associated with attribute
.value
is null.public void putIntValue(java.lang.String attribute, int value)
RegistryNode
.
The value may later be retrieved using either getIntValue
or getValue
.
attribute
- The attribute with which the specified value is
to be associated. If null
, the value will be treated as
the default value for this node.value
- The integer value to be associated with attribute
.attribute
is null.getValue()
,
getIntValue(java.lang.String, int)
public void putUnsignedIntValue(java.lang.String attribute, long value)
RegistryNode
.
The value is represented in Java as a long
.
The value may later be retrieved using either getUnsignedIntValue
or getValue
.
attribute
- The attribute with which the specified value is
to be associated. If null
, the value will be treated as
the default value for this node.value
- The unsigned integer value to be associated with attribute
.attribute
is null.getValue()
,
getUnsignedIntValue(java.lang.String, long)
public void putBooleanValue(java.lang.String attribute, boolean value)
RegistryNode
.
The value may later be retrieved using either getBooleanValue
or getValue
.
attribute
- The attribute with which the specified value is
to be associated. If null
, the value will be treated as
the default value for this node.value
- The value to be associated with attribute
.attribute
is null.getValue()
,
getBooleanValue(java.lang.String, boolean)
public void putByteValue(java.lang.String attribute, byte[] value)
RegistryNode
.
The value may later be retrieved using either getByteValue
or getValue
.
attribute
- The attribute with which the specified value is
to be associated. If null
, the value will be treated as
the default value for this node.value
- The value to be associated with attribute
.attribute
is null.getValue()
,
getByteValue(java.lang.String, byte[])
public void putObjectValue(java.lang.String attribute, java.lang.Object value)
RegistryNode
.
The value may later be retrieved using either getObjectValue
or getValue
.
The object's class must implement the java.io.Serializable
interface. In addition, if objects to which the designated object
refers do not also implement Serializable
, a
java.io.NotSerializableException
will occur when
flush
is called. The application is therefore
responsible for ensuring that the entire object graph
is serializable.
This method will attempt to store a clone of the specified object
by calling its public clone
method.
No exception is thrown if the object's class does not implement
clone
. However, since the registry cache will
contain a direct reference to the application object, subsequent changes
to the object's state will be immediately reflected in the registry.
If this is not the desired behavior, the object's class should
implement the Cloneable
interface and a public
clone
method. Note that for the clone
method
to be accessible the application class must be a public class.
attribute
- The attribute with which the specified value is
to be associated. If null
, the value will be treated as
the default value for this node.value
- The object to be associated with attribute
.Serializable
.attribute
is null.getValue()
,
getObjectValue(java.lang.String, java.lang.Object)
public boolean isString(java.lang.String attribute)
isString
will
return false
.
attribute
- The attribute with which the specified value is
associated. If null
, the value will be treated as
the default value for this node.true
if the value is a string; false
otherwise.public boolean isInteger(java.lang.String attribute)
isInteger
will
return false
.
attribute
- The attribute with which the specified value is
associated. If null
, the value will be treated as
the default value for this node.true
if the value is an integer; false
otherwise.public boolean isUnsignedInteger(java.lang.String attribute)
isUnsignedInteger
will
return false
.
attribute
- The attribute with which the specified value is
associated. If null
, the value will be treated as
the default value for this node.true
if the value is an unsigned integer; false
otherwise.public boolean isBoolean(java.lang.String attribute)
isBoolean
will
return false
.
attribute
- The attribute with which the specified value is
associated. If null
, the value will be treated as
the default value for this node.true
if the value is a boolean; false
otherwise.public boolean isByteArray(java.lang.String attribute)
isByteArray
will
return false
.
attribute
- The attribute with which the specified value is
associated. If null
, the value will be treated as
the default value for this node.true
if the value is a byte array; false
otherwise.public boolean isObject(java.lang.String attribute)
Object
.
If no value has been assigned to the attribute isObject
will
return false
.
isObject
returns true
except when the
value is stored as an integer, boolean, or byte array.
attribute
- The attribute with which the specified value is
associated. If null
, the value will be treated as
the default value for this node.true
if the value is an Object
; false
otherwise.public boolean isModified()
RegistryNode
are not guaranteed to
be persistent until the flush
method is called on this node
or on one of its ancestors.
true
if the node has been modified; false
otherwise.public final void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
PropertyChangeEvent
s
for this RegistryNode
.
A PropertyChangeEvent
is generated whenever an attribute
is added to this node, removed from this node, or when the attribute
value is changed. The property name is the attribute being added,
removed or modified (will be null
if the default value
is being modified). An old value of null
indicates
the preference was added; a new value of null
indicates
the preference was removed.
pcl
- The PropertyChangeListener
to be added.pcl
is null
.public final void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
PropertyChangeEvent
s for this RegistryNode
.
pcl
- The PropertyChangeListener
to be removed.pcl
is null
.public final void addNodeChangeListener(NodeChangeListener ncl)
NodeChangeEvent
s
for this RegistryNode
.
A NodeChangeEvent
is generated whenever a child node
is added to or removed from this node.
ncl
- The NodeChangeListener
to be added.ncl
is null
.NodeChangeListener
,
NodeChangeEvent
public final void removeNodeChangeListener(NodeChangeListener ncl)
NodeChangeEvent
s for this RegistryNode
.
ncl
- The NodeChangeListener
to be removed.ncl
is null
.NodeChangeListener
,
NodeChangeEvent
public java.lang.String toString()
RegistryNode
.
getFullName()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |