TUM CCSM Commons

edu.tum.cs.commons.string
Class StringUndoStackBase

java.lang.Object
  extended by edu.tum.cs.commons.string.StringUndoStackBase

public abstract class StringUndoStackBase
extends java.lang.Object

Base class for an undo stack using a string as the underlying model. Please refer to the test case for a demonstration and further explanation of this class.

Version:
$Rev: 26283 $
Author:
hummelb, $Author: juergens $
Rating:
GREEN Hash: 6C0282A04515FF5028992B67673ED9DD

Constructor Summary
protected StringUndoStackBase(java.lang.String initialString)
          Constructor.
 
Method Summary
 boolean canRedo()
          Returns whether redo is possible.
 boolean canUndo()
          Returns whether undo is possible.
protected  int debugGetSize()
          Prints the amount of memory currently used by this stack.
 void doSave()
          Mark the current position as saved (affects dirty calculation).
protected abstract  void fireStackChanged()
          Something about this stack has changed.
protected  void insertNewVersion(java.lang.String s)
          Inserts a new version of the model (as a string) into this stack.
 boolean isDirty()
          Returns whether something changed compared to the last safe.
protected abstract  java.lang.String join(java.util.List<java.lang.String> parts)
          Joins the parts created by split(String).
 void redo()
          Performs one redo step.
protected abstract  void setModelFromString(java.lang.String s)
          This should write back the stack content to the model.
protected abstract  java.util.List<java.lang.String> split(java.lang.String s)
          Splits the given string (as reported from the implementing class) into suitable parts used for diffing (lines, words, tokens, etc.).
 void undo()
          Performs one undo step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUndoStackBase

protected StringUndoStackBase(java.lang.String initialString)
Constructor.

Method Detail

canUndo

public boolean canUndo()
Returns whether undo is possible.


undo

public void undo()
Performs one undo step.


canRedo

public boolean canRedo()
Returns whether redo is possible.


redo

public void redo()
Performs one redo step.


isDirty

public boolean isDirty()
Returns whether something changed compared to the last safe.


doSave

public void doSave()
Mark the current position as saved (affects dirty calculation).


insertNewVersion

protected void insertNewVersion(java.lang.String s)
Inserts a new version of the model (as a string) into this stack.


split

protected abstract java.util.List<java.lang.String> split(java.lang.String s)
Splits the given string (as reported from the implementing class) into suitable parts used for diffing (lines, words, tokens, etc.).


join

protected abstract java.lang.String join(java.util.List<java.lang.String> parts)
Joins the parts created by split(String).


setModelFromString

protected abstract void setModelFromString(java.lang.String s)
This should write back the stack content to the model. This is called for every undo and redo operation.


fireStackChanged

protected abstract void fireStackChanged()
Something about this stack has changed.


debugGetSize

protected int debugGetSize()
Prints the amount of memory currently used by this stack.


TUM CCSM Commons

TUM CCSM Commons - 2.7