planet.behaviour
Class Pattern

java.lang.Object
  extended byplanet.behaviour.Pattern

public class Pattern
extends java.lang.Object

This class stores a pattern for incoming messages on a node. This pattern is used to dispatch a behaviour classOf whenever the pattern matches the type and mode of the incoming message. To allow behaviours to execute randomly on time, every pattern has a probability.

Author:
Marc Sanchez Date: 10/10/2004

Field Summary
static java.lang.String Always
          Overlay property: Always refers to a behvaiour which must run always despite RouteMessage's destination.
static java.lang.String Bad
          Overlay property: Bad refers to a behvaiour which must run when node misbehaves, including routing and overlay invariant's maintenance.
static java.lang.String Cwildcard
          Complementary wildcard: given a set of patterns P, this wildcard is used to attach a behaviour to the patterns on the whole pattern space S not included in P set.
static java.lang.String Good
          Overlay property: Good refers to a behaviour which must run when node behaves as underlying kbr protocol stipulates.
static java.lang.String Local
          Overlay property: Local refers to a behaviour which must run only when RouteMessage's pattern is for him.
static java.lang.String Neutral
          Overlay property: Neutral refers to a behvaiour which must run always despite node's role is bad or good.
static java.lang.String Remote
          Overlay property: Remote refers to a behaviour which must run only when RouteMessage's pattern is for another peer rather than him.
static java.lang.String Uwildcard
          Universal wildcard: given a set of patterns P, this wildcard is used to attach a behaviour to all the patterns on the whole pattern space S included P set, i.e.
 
Constructor Summary
Pattern(java.lang.Class classOf, java.lang.String typeOf, java.lang.String modeOf, double pdf, java.lang.String whenTo, java.lang.String roleOf)
           
 
Method Summary
 int compareTo(Pattern pattern)
          Compares two patterns based on specific criteria.
 java.lang.Class getClassOf()
           
 int getMap()
           
 java.lang.String getModeOf()
           
 double getPdf()
           
 java.lang.String getRoleOf()
           
 java.lang.String getTypeOf()
           
 java.lang.String getWhenTo()
           
 int map(java.lang.String property)
          Maps a property to specific quantifier.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Cwildcard

public static final java.lang.String Cwildcard
Complementary wildcard: given a set of patterns P, this wildcard is used to attach a behaviour to the patterns on the whole pattern space S not included in P set.

See Also:
Constant Field Values

Uwildcard

public static final java.lang.String Uwildcard
Universal wildcard: given a set of patterns P, this wildcard is used to attach a behaviour to all the patterns on the whole pattern space S included P set, i.e. P C S.

See Also:
Constant Field Values

Local

public static final java.lang.String Local
Overlay property: Local refers to a behaviour which must run only when RouteMessage's pattern is for him.

See Also:
Constant Field Values

Remote

public static final java.lang.String Remote
Overlay property: Remote refers to a behaviour which must run only when RouteMessage's pattern is for another peer rather than him.

See Also:
Constant Field Values

Always

public static final java.lang.String Always
Overlay property: Always refers to a behvaiour which must run always despite RouteMessage's destination.

See Also:
Constant Field Values

Good

public static final java.lang.String Good
Overlay property: Good refers to a behaviour which must run when node behaves as underlying kbr protocol stipulates.

See Also:
Constant Field Values

Bad

public static final java.lang.String Bad
Overlay property: Bad refers to a behvaiour which must run when node misbehaves, including routing and overlay invariant's maintenance.

See Also:
Constant Field Values

Neutral

public static final java.lang.String Neutral
Overlay property: Neutral refers to a behvaiour which must run always despite node's role is bad or good.

See Also:
Constant Field Values
Constructor Detail

Pattern

public Pattern(java.lang.Class classOf,
               java.lang.String typeOf,
               java.lang.String modeOf,
               double pdf,
               java.lang.String whenTo,
               java.lang.String roleOf)
Method Detail

getClassOf

public java.lang.Class getClassOf()
Returns:
Returns the class of behaviour.

getModeOf

public java.lang.String getModeOf()
Returns:
Returns the mode of pattern.

getPdf

public double getPdf()
Returns:
Returns the probability binding.

getTypeOf

public java.lang.String getTypeOf()
Returns:
Returns the type of the pattern.

getWhenTo

public java.lang.String getWhenTo()
Returns:
Returns when to exec this behaviour.

getRoleOf

public java.lang.String getRoleOf()
Returns:
Returns the role of this behaviour.

getMap

public int getMap()
Returns:
Returns an integer mapping for this pattern.

map

public int map(java.lang.String property)
Maps a property to specific quantifier. So Complementary wildcard "?" is more specific than universal wildcard "*".

Parameters:
property - The property to quantify.
Returns:
The quantifier of the property.

compareTo

public int compareTo(Pattern pattern)
Compares two patterns based on specific criteria. Specific criteria: Type Mode 1) Tag, Tag 2) Tag, ? 3) Tag, * 4) ? , Tag 5) * , Tag 6) ? , * 7) * , ? 8) * , *

Parameters:
pattern - The pattern to compare.
Returns:
the value 0 if the argument pattern is equal to this pattern; a value less than 0 if this pattern is less specific than the pattern argument; and a value greater than 0 if the pattern is more specific than the pattern argument.

toString

public java.lang.String toString()