All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class uhr.core.attract.AttractorStd

java.lang.Object
   |
   +----uhr.core.attract.AttractorStd

public class AttractorStd
extends Object
implements Attractor
An attractor expresses the desire of things for each other. See full documentation.


Constructor Index

 o AttractorStd()

Method Index

 o addType(String)
Adds a type for the service.
 o containsAttribute(Object, Object)
Determine whether the key and value are an attribute in this Attractor.
 o containsKey(Object)
Determines whether the key is in this attractor's attributes.
 o containsType(String)
Determines whether the attractor contains the type.
 o enumerateKeys()
Returns an enumeration of all attribute keys in no particular order.
 o enumerateTypes()
Returns an enumeration of all types in no particular order.
 o equals(Object)
Overrides the method in Object for use in matching or to use the atttractor as a unique key.
 o getAttributeCount()
Returns the number of attributes.
 o getTypeCount()
Returns the number of types.
 o getValue(Object)
Returns the attribute value for the key or null if none.
 o hashCode()
Overrides the method in Object for use as a key.
 o isAttributeSubset(Attractor)
Determines whether this attractor's attributes are a subset of the argument attractor's attributes.
 o isTypeSubset(Attractor)
Determines whether this attractor's types are a subset of the argument attractor's types.
 o putAttribute(Object, Object)
Puts a single Attribute into the Attractor.
 o toString()

Constructors

 o AttractorStd
 public AttractorStd()

Methods

 o addType
 public void addType(String type)
Adds a type for the service. This is a Java class name such as "uhr.parts.net.SocketMonitor" or "UF_double_double_int". At least one type must be added.

If Unifaces are used then a service has only one type, and a need for that service also has only one type. However we offer the flexibility of multiple types to avoid overly contraining the designer.

A service has one or more types. This allows a service to evolve and still have backwards compatability with prior needs. For example if a service implements a new interface that extends the old interface, it adds both interfaces as types. A need for the old type will be honored, as well as allowing more currently written needs to use the new type.

A need has one or more types, though usually just one. If it has more than one then upon receiving the service it casts it to the most opportune type.

Parameters:
type - the Java type for the service.
Throws: IllegalArgumentException
if type class is not found.
Throws: IllegalStateException
if already added.
 o containsType
 public boolean containsType(String type)
Determines whether the attractor contains the type.

Parameters:
type - the type in question.
Returns:
true if contained or false if not.
 o getTypeCount
 public int getTypeCount()
Returns the number of types. There should be at least one.

Returns:
the number of types.
 o enumerateTypes
 public Enumeration enumerateTypes()
Returns an enumeration of all types in no particular order.

Returns:
the enumeration of types.
 o putAttribute
 public Object putAttribute(Object key,
                            Object value)
Puts a single Attribute into the Attractor. Attributes describe what is needed or what a host has. At least one attribute is required. The attribute value can be any object, but we caution developers to limit value to Strings, primitive wrappers, etc at first.

Parameters:
key - the key, which cannot be null.
value - the value, which cannot be null;
Returns:
the previous value or null if none.
 o getValue
 public Object getValue(Object key)
Returns the attribute value for the key or null if none.

Parameters:
key - the key in question.
Returns:
the value for the key or null if none.
 o enumerateKeys
 public Enumeration enumerateKeys()
Returns an enumeration of all attribute keys in no particular order.

Returns:
the enumeration of keys.
 o containsKey
 public boolean containsKey(Object key)
Determines whether the key is in this attractor's attributes.

Parameters:
attribute - the attribute to test.
 o containsAttribute
 public boolean containsAttribute(Object key,
                                  Object value)
Determine whether the key and value are an attribute in this Attractor.

Parameters:
key - the key in question, which may be null.
value - the value in question, which may be null.
Returns:
true if the attribute described by the key and value is in the Attractor, false if not.
 o getAttributeCount
 public int getAttributeCount()
Returns the number of attributes. There should be at least one.

Returns:
the number of attributes.
 o isTypeSubset
 public boolean isTypeSubset(Attractor attractor)
Determines whether this attractor's types are a subset of the argument attractor's types. This is true if each of this attractor's types is contained in the other attractor.

Parameters:
attractor - the other attractor to use for comparison.
Returns:
true if a subset, false if not.
 o isAttributeSubset
 public boolean isAttributeSubset(Attractor attractor)
Determines whether this attractor's attributes are a subset of the argument attractor's attributes. This is true if each of this attractor's attributes is contained in the other attractor.

Parameters:
attractor - the other attractor to use for comparison.
Returns:
true if a subset, false if not.
 o toString
 public String toString()
Overrides:
toString in class Object
 o equals
 public boolean equals(Object object)
Overrides the method in Object for use in matching or to use the atttractor as a unique key.

Parameters:
object - the object to compare to.
Returns:
true if equal or false if not.
Overrides:
equals in class Object
 o hashCode
 public int hashCode()
Overrides the method in Object for use as a key.

Returns:
the same int if two attractors are equal, and usually a different int if they're not.
Overrides:
hashCode in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index