All Packages Class Hierarchy This Package Previous Next Index
Class com.sgi.sysadm.util.AttrBundle
java.lang.Object
|
+----com.sgi.sysadm.util.AttrBundle
- public class AttrBundle
- extends Object
AttrBundle is an aggregation of Attributes, which are typed
key/value pairs. Methods are provided for getting and setting the
values of Attributes, for getting notification when Attributes
change, and for managing a string representation of an AttrBundle
that can be used to transfer an AttrBundle to or from another
program.
In addition to Attributes, each AttrBundle has a type and a
selector, both of which are Strings. Type and selector are used by
subclasses of AttrBundle for uniquely identifying items and for
routing packets.
An AttrBundle stores an independent mapping of key names to
visibility flags, controlled via the setAttrVisible
method. The visibility mapping is used in the toString
method to prevent invisible Attributes from being part of the
String returned. This facility is used to prevent sensitive
information such as passwords from appearing in logging or debug
output.
- See Also:
- Attribute
-
AttrBundle()
- Construct an AttrBundle with empty type and selector.
-
AttrBundle(AttrBundle)
- Construct an AttrBundle that is a copy of other.
-
AttrBundle(String)
- Construct an AttrBundle from serialized format.
-
AttrBundle(String, String)
- Construct an AttrBundle with type and
selector.
-
addAttrListener(AttrListener)
- Add a listener to get notified when Attributes are added,
changed, or removed.
-
clone()
- Create a new AttrBundle that is a copy of this AttrBundle.
-
equals(AttrBundle)
- Determine whether other is equal to this AttrBundle.
-
getAttr(String)
- Get the Attribute associated with key.
-
getAttrEnum()
- Get an Enumeration of the Attributes in this AttrBundle.
-
getAttrVisible(String)
- Get the visibility of Attribute named by key.
-
getBoolean(String)
- Convenience method for getting the value of an Attribute of
type boolean.
-
getBundle(String)
- Convenience method for getting the value of an Attribute of
type AttrBundle.
-
getDouble(String)
- Convenience method for getting the value of an Attribute of
type double.
-
getLong(String)
- Convenience method for getting the value of an Attribute of
type long.
-
getSelector()
- Get the selector of this AttrBundle.
-
getString(String)
- Convenience method for getting the value of an Attribute of
type String.
-
getType()
- Get the type of this AttrBundle.
-
getValueString(String)
- Convenience method for getting the String value of an Attribute of
any type.
-
removeAllAttrs()
- Removes all the Attributes in the bundle.
-
removeAttr(String)
- Remove the Attribute associated with key.
-
removeAttrListener(AttrListener)
- Remove a listener.
-
serialize()
- Return a string representation of this AttrBundle, suitable for
transmission to another program.
-
setAttr(Attribute)
- Set an Attribute.
-
setAttrVisible(String, boolean)
- Set the visibility of Attribute named by key.
-
setBoolean(String, boolean)
- Convenience method for setting a boolean attribute.
-
setBundle(String, AttrBundle)
- Convenience method for setting an AttrBundle attribute.
-
setDouble(String, double)
- Convenience method for setting a double attribute.
-
setLong(String, long)
- Convenience method for setting a long attribute.
-
setString(String, String)
- Convenience method for setting a String attribute.
-
size()
- Get the number of Attributes in this AttrBundle.
-
toString()
- Return a string representation of this AttrBundle,
suitable for human viewing.
-
toString(int)
- Return a string representation of this AttrBundle, suitable for
human viewing.
AttrBundle
public AttrBundle(String type,
String selector)
- Construct an AttrBundle with type and
selector.
- Parameters:
- type - The type of this AttrBundle. The interpretation of
type depends on the application.
- selector - The selector of this AttrBundle. The
interpretation of selector depends on
the application.
AttrBundle
public AttrBundle()
- Construct an AttrBundle with empty type and selector.
AttrBundle
public AttrBundle(String stream)
- Construct an AttrBundle from serialized format.
- Parameters:
- stream - serialized AttrBundle.
AttrBundle
public AttrBundle(AttrBundle other)
- Construct an AttrBundle that is a copy of other. The
list of listeners is not copied. The visibility flags are
copied.
- Parameters:
- other - AttrBundle to copy.
clone
public Object clone() throws CloneNotSupportedException
- Create a new AttrBundle that is a copy of this AttrBundle. The
list of listeners is not copied. The visibility flags are
copied.
- Returns:
- A copy of this AttrBundle
- Overrides:
- clone in class Object
addAttrListener
public void addAttrListener(AttrListener listener)
- Add a listener to get notified when Attributes are added,
changed, or removed. listener does not get notified
about the current state of the AttrBundle.
It is safe to add an AttrListener while AttrListeners are being
notified. The added AttrListener will not receive the
notification that was being processed when it was added.
- Parameters:
- listener - gets notified when Attributes are added,
changed, or removed.
removeAttrListener
public void removeAttrListener(AttrListener listener)
- Remove a listener.
It is safe to remove an AttrListener while AttrListeners are
being notified. In this case, however, it is possible for the
removed AttrListener to get one last notification even after it
has been removed.
- Parameters:
- listener - listener to remove.
getType
public String getType()
- Get the type of this AttrBundle.
- Returns:
- type of this AttrBundle.
getSelector
public String getSelector()
- Get the selector of this AttrBundle.
- Returns:
- selector of this AttrBundle.
serialize
public String serialize()
- Return a string representation of this AttrBundle, suitable for
transmission to another program.
- Returns:
- String representation of this AttrBundle.
toString
public String toString(int pad)
- Return a string representation of this AttrBundle, suitable for
human viewing.
- Parameters:
- pad - number of spaces to pad the left side of displayed
Attributes.
- Returns:
- String representation of this AttrBundle.
toString
public String toString()
- Return a string representation of this AttrBundle,
suitable for human viewing.
- Returns:
- String representation of this AttrBundle.
- Overrides:
- toString in class Object
setAttrVisible
public void setAttrVisible(String key,
boolean visible)
- Set the visibility of Attribute named by key.
The visibility flags are separate from the Attributes
themselves, so a call to setAttrVisible permanently
affects the visibility of Attributes for key,
regardless of the order in which and how many times they are
added or removed.
- Parameters:
- key - Key to set visibility of.
- visible - true if Attribute is to be
visible, false otherwise.
getAttrVisible
public boolean getAttrVisible(String key)
- Get the visibility of Attribute named by key.
- Parameters:
- key - Key of Attribute to check visibility of.
- Returns:
- visibility of Attribute named by "key".
getAttr
public Attribute getAttr(String key)
- Get the Attribute associated with key.
- Parameters:
- key - key of Attribute to get.
- Returns:
- Attribute associated with key, or null if the
Attribute does not exist.
removeAttr
public Attribute removeAttr(String key)
- Remove the Attribute associated with key.
- Parameters:
- key - key of Attribute to remove.
- Returns:
- Attribute associated with key, or null if the
Attribute does not exist.
removeAllAttrs
public void removeAllAttrs()
- Removes all the Attributes in the bundle.
setAttr
public void setAttr(Attribute attr)
- Set an Attribute. Replaces any existing Attribute that had the
same key as attr. Notify AttrListeners that an
attribute has changed.
It is an error to try to change the type of an Attribute. If
an Attribute already exists with the same key as attr
but with a different type (e.g. String v. Long), an assertion
(Log.assert) will fail.
If an Attribute with the same key as attr already
exists with an identical value, the old Attribute is left in
place and no change notification occurs.
- Parameters:
- attr - Attribute to set.
- See Also:
- assert
setString
public void setString(String key,
String value)
- Convenience method for setting a String attribute. Everything
in the description of setAttr applies to this method as
well.
- Parameters:
- key - key of the attribute to set.
- value - String value of the attribute to set.
- See Also:
- setAttr
setLong
public void setLong(String key,
long value)
- Convenience method for setting a long attribute. Everything
in the description of setAttr applies to this method as
well.
- Parameters:
- key - key of the attribute to set.
- value - long value of the attribute to set.
- See Also:
- setAttr
setDouble
public void setDouble(String key,
double value)
- Convenience method for setting a double attribute. Everything
in the description of setAttr applies to this method as
well.
- Parameters:
- key - key of the attribute to set.
- value - double value of the attribute to set.
- See Also:
- setAttr
setBoolean
public void setBoolean(String key,
boolean value)
- Convenience method for setting a boolean attribute. Everything
in the description of setAttr applies to this method as
well.
- Parameters:
- key - key of the attribute to set.
- value - boolean value of the attribute to set.
- See Also:
- setAttr
setBundle
public void setBundle(String key,
AttrBundle value)
- Convenience method for setting an AttrBundle attribute. Everything
in the description of setAttr applies to this method as
well.
- Parameters:
- key - key of the attribute to set.
- value - AttrBundle value of the attribute to set.
- See Also:
- setAttr
getString
public String getString(String key)
- Convenience method for getting the value of an Attribute of
type String. This method will throw a ClassCastException if
an Attribute for key exists but is not of type String.
This method also asserts (using Log.assert) that the
Attribute has previously been set.
- Parameters:
- key - key of the Attribute to get the String value of.
- Returns:
- value of Attribute corresponding to key.
- See Also:
- assert
getValueString
public String getValueString(String key)
- Convenience method for getting the String value of an Attribute of
any type.
This method asserts (using Log.assert) that the
Attribute has previously been set.
- Parameters:
- key - key of the Attribute to get the String representation of.
- Returns:
- value of Attribute corresponding to key.
- See Also:
- assert
getLong
public long getLong(String key)
- Convenience method for getting the value of an Attribute of
type long. This method will throw a ClassCastException if
an Attribute for key exists but is not of type long.
This method also asserts (using Log.assert) that the
Attribute has previously been set.
- Parameters:
- key - key of the Attribute to get the long value of.
- Returns:
- value of Attribute corresponding to key.
- See Also:
- assert
getDouble
public double getDouble(String key)
- Convenience method for getting the value of an Attribute of
type double. This method will throw a ClassCastException if
an Attribute for key exists but is not of type double.
This method also asserts (using Log.assert) that the
Attribute has previously been set.
- Parameters:
- key - key of the Attribute to get the double value of.
- Returns:
- value of Attribute corresponding to key.
- See Also:
- assert
getBoolean
public boolean getBoolean(String key)
- Convenience method for getting the value of an Attribute of
type boolean. This method will throw a ClassCastException if
an Attribute for key exists but is not of type boolean.
This method also asserts (using Log.assert) that the
Attribute has previously been set.
- Parameters:
- key - key of the Attribute to get the boolean value of.
- Returns:
- value of Attribute corresponding to key.
- See Also:
- assert
getBundle
public AttrBundle getBundle(String key)
- Convenience method for getting the value of an Attribute of
type AttrBundle. This method will throw a ClassCastException if
an Attribute for key exists but is not of type AttrBundle.
This method also asserts (using Log.assert) that the
Attribute has previously been set.
- Parameters:
- key - key of the Attribute to get the AttrBundle value of.
- Returns:
- value of Attribute corresponding to key.
- See Also:
- assert
size
public int size()
- Get the number of Attributes in this AttrBundle.
- Returns:
- Number of Attributes.
getAttrEnum
public Enumeration getAttrEnum()
- Get an Enumeration of the Attributes in this AttrBundle.
- Returns:
- Enumeration of Attributes.
equals
public boolean equals(AttrBundle other)
- Determine whether other is equal to this AttrBundle.
AttrBundles are equal if they have the same type, the same
selector, the same set of keys, and the Attribute for each key
is of the same type and has the same value. The visibility
flags are not considered. If other is null,
equals returns false.
- Parameters:
- other - AttrBundle to compare.
- Returns:
- true if AttrBundles are equal, false
otherwise.
All Packages Class Hierarchy This Package Previous Next Index