org.softevo.ample.eval
Class Pattern

java.lang.Object
  extended by org.softevo.ample.eval.Pattern
All Implemented Interfaces:
java.lang.Comparable

public class Pattern
extends java.lang.Object
implements java.lang.Comparable

A pattern and the index in the trace it was discovered.


Field Summary
static java.security.MessageDigest digest
          The message digest for md5 hashing.
private  int discoveryIndex
          The discovery index of the pattern.
private  int lastOccurence
          The last time this pattern was found.
private  java.lang.String[] methodCallSequence
          The sequence of method calls.
private  int numberOfOccurences
          The number of times the pattern occured.
 
Constructor Summary
Pattern(java.lang.String[] methodCallSequence, int discoveryIndex)
          Creates a new pattern.
 
Method Summary
 int compareTo(java.lang.Object object)
          Compares this object by the number of references.
 void countOccurence()
          Increases the occurence counter by one.
 boolean equals(java.lang.Object object)
          Two patterns are considered equal if they have the same method call sequence.
 java.lang.String getCanonicalPattern()
          Gets the canonical form of the pattern.
 int getDiscoveryIndex()
          Gets the discovery index for the pattern.
 byte[] getHash()
          Gets a md5 hash of the canonical pattern.
 int getLastOccurence()
          Gets the last occurence of this pattern.
 java.lang.String[] getMethodCallSequence()
          Gets the method call sequence.
 int getNumberOfOccurences()
          Gets the number of times the pattern was found.
 int hashCode()
          Gets the hash code of the concatenated method calls.
 void setLastOccurence(int lastOccurence)
          Sets a new value for the last occurence.
 void setOccurences(int occurences)
          Sets the number of occurences.
 java.lang.String toString()
          Returns a textual representation of the method call sequence.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

digest

public static java.security.MessageDigest digest
The message digest for md5 hashing.


methodCallSequence

private java.lang.String[] methodCallSequence
The sequence of method calls.


discoveryIndex

private int discoveryIndex
The discovery index of the pattern.


numberOfOccurences

private int numberOfOccurences
The number of times the pattern occured.


lastOccurence

private int lastOccurence
The last time this pattern was found.

Constructor Detail

Pattern

public Pattern(java.lang.String[] methodCallSequence,
               int discoveryIndex)
Creates a new pattern.
Parameters:
methodCalls - the call sequence
discoveryIndex - the index in the trace the pattern was discovered
Method Detail

toString

public java.lang.String toString()
Returns a textual representation of the method call sequence.

Overrides:
toString in class java.lang.Object

countOccurence

public void countOccurence()
Increases the occurence counter by one.


getNumberOfOccurences

public int getNumberOfOccurences()
Gets the number of times the pattern was found.


getMethodCallSequence

public java.lang.String[] getMethodCallSequence()
Gets the method call sequence.


getDiscoveryIndex

public int getDiscoveryIndex()
Gets the discovery index for the pattern.


hashCode

public int hashCode()
Gets the hash code of the concatenated method calls.

Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(java.lang.Object object)
Compares this object by the number of references.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
object - the object to compare this entry to

equals

public boolean equals(java.lang.Object object)
Two patterns are considered equal if they have the same method call sequence.

Overrides:
equals in class java.lang.Object
Parameters:
object - another pattern

getHash

public byte[] getHash()
Gets a md5 hash of the canonical pattern.


getLastOccurence

public int getLastOccurence()
Gets the last occurence of this pattern.


setLastOccurence

public void setLastOccurence(int lastOccurence)
Sets a new value for the last occurence.


setOccurences

public void setOccurences(int occurences)
Sets the number of occurences.


getCanonicalPattern

public java.lang.String getCanonicalPattern()
Gets the canonical form of the pattern.
This method simply concatenates the method names using the separator defined in SimpleFormat.

Returns:
the canonical pattern