MicroTAPAS
Class CapabilitySet

java.lang.Object
  |
  +--MicroTAPAS.CapabilitySet
All Implemented Interfaces:
java.io.Serializable

public class CapabilitySet
extends java.lang.Object
implements java.io.Serializable

Defines the representation of capability sets, and functionality related to capability sets. Capability sets are properties attached to actors, and they are used as requirements for doing plug in of actors. A capability set may consists of zero or more capabilities, where each capability value is represented as a text string. Capabilitities specifications may be done as a dotted (i.e. ".") separated list of terms, where each term represents a level in the hierarchical specification of the capability. I.e. "printer" define the capability "any printer", while "printer.postscript" specifies the capability "printer with postscript capabilities". The term asterisk (i.e. "*") may be used to specify "any value" for a capability term. I.e. "printer.*" specifies any printer capability. Functionality is defined to assign or change the set of capabilities included into a capability set value, and also functionality to determine whether or not a set of capabilities is included in another specified capability set.

See Also:
Serialized Form

Field Summary
static int ADD
          Add specified capabilities to set for those not already existing
private  java.util.Vector capabilities
          The set of capabilities included in this set is represented as a vector.
static int REMOVE
          Remove specified set of capabilities, for those that exists in set
static int SET
          Set capability set to value specified
 
Constructor Summary
CapabilitySet(java.lang.String[] initialSet)
          Constructor defines a capability set, with an initial value as specified.
 
Method Summary
private  void addEntries(java.lang.String[] entries)
          Add a number of entries to the capability set.
private  int capabilityIncluded(java.util.Vector set, java.lang.String cap)
          Check whether or not the specified capabilities is included within the specified set.
 java.lang.String[] getAll()
          Determine all capability entries
 boolean includedIn(CapabilitySet caps)
          Check if specified capability set is included in this one
 int length()
          Determine the number of category entries included into the set
(package private) static void main(java.lang.String[] args)
          main is just included for the purpose of standalone testing No arguments are used
private  void removeEntries(java.lang.String[] entries)
          Remove specified entries that are included into the set
private  java.lang.String[] splitCapability(java.lang.String s)
          Splits the capability into two parts: the first part contains everything up until the last element, the second part contains the last element: screen.colors.65000 will be split into screen.colors and 65000.
private  int stringAsValue(java.lang.String s)
          Returns the integer represented by the supplied String.
 java.lang.String toString()
          Determine a string representation of all capabilities.
static java.lang.String toString(CapabilitySet obj)
          Determine a string representation of all capabilities.
 void update(int opType, CapabilitySet caps)
          Update set of capabilities according to specified set and operation type.
 RequestResult validateRequiredCaps(RequestPars pRP)
          This method compares the offered capabilities (this set), with the capabilities required by an actor.
 java.lang.String value(int i)
          Determine the value of a specified category entry in the set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

capabilities

private java.util.Vector capabilities
The set of capabilities included in this set is represented as a vector.


SET

public static final int SET
Set capability set to value specified

See Also:
Constant Field Values

ADD

public static final int ADD
Add specified capabilities to set for those not already existing

See Also:
Constant Field Values

REMOVE

public static final int REMOVE
Remove specified set of capabilities, for those that exists in set

See Also:
Constant Field Values
Constructor Detail

CapabilitySet

public CapabilitySet(java.lang.String[] initialSet)
Constructor defines a capability set, with an initial value as specified.

Parameters:
initialSet - The initial set of capabilities
Method Detail

update

public void update(int opType,
                   CapabilitySet caps)
Update set of capabilities according to specified set and operation type.

Parameters:
opType - Operation type
caps - The set of capabilities

capabilityIncluded

private int capabilityIncluded(java.util.Vector set,
                               java.lang.String cap)
Check whether or not the specified capabilities is included within the specified set. The capability values is specified as a dotted (i.e. '.') separated list of terms, and asterisk (i.e. '*') is considered as a wildcard value for a term.

Parameters:
set - The set of capabilities to check against
cap - The specified capability value
Returns:
true if included, false else

addEntries

private void addEntries(java.lang.String[] entries)
Add a number of entries to the capability set.

Parameters:
entries - The set of capability entries to add.

removeEntries

private void removeEntries(java.lang.String[] entries)
Remove specified entries that are included into the set

Parameters:
entries - The set of entries to be removed

length

public int length()
Determine the number of category entries included into the set

Returns:
The number of category entries included in the set

value

public java.lang.String value(int i)
Determine the value of a specified category entry in the set

Parameters:
i - The index to where the category entry is located
Returns:
The category entry at specified index if valid index value, else null is returned

getAll

public java.lang.String[] getAll()
Determine all capability entries

Returns:
A list containing all capability entries if such exists, else null is returned

includedIn

public boolean includedIn(CapabilitySet caps)
Check if specified capability set is included in this one

Parameters:
caps - The set of capabilities that are checked if included
Returns:
true if 'caps' is included in this set, or if specified to 'null' (i.e. not use)

validateRequiredCaps

public RequestResult validateRequiredCaps(RequestPars pRP)
                                   throws java.lang.Exception
This method compares the offered capabilities (this set), with the capabilities required by an actor.

Parameters:
pRP - The request.
Returns:
TAPAS style result
java.lang.Exception

splitCapability

private java.lang.String[] splitCapability(java.lang.String s)
Splits the capability into two parts: the first part contains everything up until the last element, the second part contains the last element: screen.colors.65000 will be split into screen.colors and 65000.

Parameters:
s - The capability represented by a . seperated list.
Returns:
A String array with two elements; the beginning and end of the capability.

stringAsValue

private int stringAsValue(java.lang.String s)
Returns the integer represented by the supplied String. If the string is not an integer, -1 will be returned, otherwise the integer value is returned.

Parameters:
s - The String representation of an integer.
Returns:
The integer of the String.

toString

public java.lang.String toString()
Determine a string representation of all capabilities. Starts with [ and ends with ].

Overrides:
toString in class java.lang.Object
Returns:
String representation of all capabilities in set

toString

public static java.lang.String toString(CapabilitySet obj)
Determine a string representation of all capabilities. Starts with [ and ends with ].

Parameters:
obj - CapabilitySet object - if existing
Returns:
String representation of all capabilities in set

main

static void main(java.lang.String[] args)
main is just included for the purpose of standalone testing No arguments are used



The Telematics Architecture for Plug-and-Play Systems (TAPAS) is a research project undertaken by the Norwegian University of Science and Technology's Telematics department which aims at developing an architecture for network-based service systems with a) flexibility and adaptability, b) robustness and survivability, and c) QoS awareness and resource control.

More information can be found at the project's homepage at http://tapas.item.ntnu.no and the project manager, Professor Finn Arve Aagesen, can be reached at finn.arve.aagesen@item.ntnu.no.