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

Constructor Index

 o AttrBundle()
Construct an AttrBundle with empty type and selector.
 o AttrBundle(AttrBundle)
Construct an AttrBundle that is a copy of other.
 o AttrBundle(String)
Construct an AttrBundle from serialized format.
 o AttrBundle(String, String)
Construct an AttrBundle with type and selector.

Method Index

 o addAttrListener(AttrListener)
Add a listener to get notified when Attributes are added, changed, or removed.
 o clone()
Create a new AttrBundle that is a copy of this AttrBundle.
 o equals(AttrBundle)
Determine whether other is equal to this AttrBundle.
 o getAttr(String)
Get the Attribute associated with key.
 o getAttrEnum()
Get an Enumeration of the Attributes in this AttrBundle.
 o getAttrVisible(String)
Get the visibility of Attribute named by key.
 o getBoolean(String)
Convenience method for getting the value of an Attribute of type boolean.
 o getBundle(String)
Convenience method for getting the value of an Attribute of type AttrBundle.
 o getDouble(String)
Convenience method for getting the value of an Attribute of type double.
 o getLong(String)
Convenience method for getting the value of an Attribute of type long.
 o getSelector()
Get the selector of this AttrBundle.
 o getString(String)
Convenience method for getting the value of an Attribute of type String.
 o getType()
Get the type of this AttrBundle.
 o getValueString(String)
Convenience method for getting the String value of an Attribute of any type.
 o removeAllAttrs()
Removes all the Attributes in the bundle.
 o removeAttr(String)
Remove the Attribute associated with key.
 o removeAttrListener(AttrListener)
Remove a listener.
 o serialize()
Return a string representation of this AttrBundle, suitable for transmission to another program.
 o setAttr(Attribute)
Set an Attribute.
 o setAttrVisible(String, boolean)
Set the visibility of Attribute named by key.
 o setBoolean(String, boolean)
Convenience method for setting a boolean attribute.
 o setBundle(String, AttrBundle)
Convenience method for setting an AttrBundle attribute.
 o setDouble(String, double)
Convenience method for setting a double attribute.
 o setLong(String, long)
Convenience method for setting a long attribute.
 o setString(String, String)
Convenience method for setting a String attribute.
 o size()
Get the number of Attributes in this AttrBundle.
 o toString()
Return a string representation of this AttrBundle, suitable for human viewing.
 o toString(int)
Return a string representation of this AttrBundle, suitable for human viewing.

Constructors

 o 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.
 o AttrBundle
 public AttrBundle()
Construct an AttrBundle with empty type and selector.

 o AttrBundle
 public AttrBundle(String stream)
Construct an AttrBundle from serialized format.

Parameters:
stream - serialized AttrBundle.
 o 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.

Methods

 o 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
 o 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.
 o 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.
 o getType
 public String getType()
Get the type of this AttrBundle.

Returns:
type of this AttrBundle.
 o getSelector
 public String getSelector()
Get the selector of this AttrBundle.

Returns:
selector of this AttrBundle.
 o serialize
 public String serialize()
Return a string representation of this AttrBundle, suitable for transmission to another program.

Returns:
String representation of this AttrBundle.
 o 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.
 o 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
 o 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.
 o 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".
 o 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.
 o 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.
 o removeAllAttrs
 public void removeAllAttrs()
Removes all the Attributes in the bundle.

 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o size
 public int size()
Get the number of Attributes in this AttrBundle.

Returns:
Number of Attributes.
 o getAttrEnum
 public Enumeration getAttrEnum()
Get an Enumeration of the Attributes in this AttrBundle.

Returns:
Enumeration of Attributes.
 o 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