de.jstacs.motifDiscovery.history
Class SimpleHistory

java.lang.Object
  extended by de.jstacs.motifDiscovery.history.SimpleHistory
All Implemented Interfaces:
History, Storable, Cloneable

public class SimpleHistory
extends Object
implements History

This class implements a simple history that has a limited memory that will be used cyclicly. Only operations are allowed, that are not a priorily forbidden and the complementary operation has not been performed before (in the local history) except shrink operations. The last point helps to keep the motifs short that will be found.
This history may not cause an termination of the motif discovery.

Author:
Jens Keilwagen
See Also:
CappedHistory

Constructor Summary
SimpleHistory(int slots)
          This constructor creates a simple history with limited memory.
SimpleHistory(int slots, boolean allowShift, boolean allowShrink, boolean allowExpand)
          This constructor creates a simple history with limited memory.
SimpleHistory(StringBuffer xml)
          This is the constructor for the interface Storable.
 
Method Summary
 void clear()
          This method clears the history, i.e.
 SimpleHistory clone()
          This method returns a deep copy of the instance
 boolean operationAllowed(int... operation)
          Returns true if the specified operation is allowed, i.e.
 void operationPerfomed(int... operation)
          This method puts an operation to the history.
 StringBuffer toXML()
          This method returns an XML representation as StringBuffer of an instance of the implementing class.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleHistory

public SimpleHistory(int slots)
This constructor creates a simple history with limited memory. All operation are a priori allowed.

Parameters:
slots - the number of memory slots
See Also:
SimpleHistory(int, boolean, boolean, boolean)

SimpleHistory

public SimpleHistory(int slots,
                     boolean allowShift,
                     boolean allowShrink,
                     boolean allowExpand)
This constructor creates a simple history with limited memory.

Parameters:
slots - the number of memory slots
allowShift - if true shifts are allow
allowShrink - if true shrinks are allow
allowExpand - if true expands are allow

SimpleHistory

public SimpleHistory(StringBuffer xml)
              throws NonParsableException
This is the constructor for the interface Storable.

Parameters:
xml - the XML representation as StringBuffer
Throws:
NonParsableException - if the XML representation could not be parsed
Method Detail

toXML

public StringBuffer toXML()
Description copied from interface: Storable
This method returns an XML representation as StringBuffer of an instance of the implementing class.

Specified by:
toXML in interface Storable
Returns:
the XML representation

operationAllowed

public boolean operationAllowed(int... operation)
Description copied from interface: History
Returns true if the specified operation is allowed, i.e. it does not conflict with any operation from the history.

Specified by:
operationAllowed in interface History
Parameters:
operation - the operation to be tested
Returns:
true if the specified operation is allowed

operationPerfomed

public void operationPerfomed(int... operation)
Description copied from interface: History
This method puts an operation to the history.

Specified by:
operationPerfomed in interface History
Parameters:
operation - the performed operation

clear

public void clear()
Description copied from interface: History
This method clears the history, i.e. it removes all operations from the history.

Specified by:
clear in interface History

clone

public SimpleHistory clone()
                    throws CloneNotSupportedException
Description copied from interface: History
This method returns a deep copy of the instance

Specified by:
clone in interface History
Overrides:
clone in class Object
Returns:
a deep copy
Throws:
CloneNotSupportedException - if not possible
See Also:
Cloneable, Object.clone()