Class EngineImpl

java.lang.Object
fr.istic.aco.editor.core.EngineImpl
All Implemented Interfaces:
Engine, Originator

public class EngineImpl extends Object implements Engine
This class represents an implementation of the Engine interface, which controls the main editing operations of a text editor such as insert, delete, cut, copy, and paste.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Copies the text within the interval specified by the selection control object into the clipboard.
    void
    Removes the text within the interval specified by the selection control object, from the buffer.
    void
    Removes the contents of the selection in the buffer
    Provides the whole contents of the buffer, as a string
    Provides the clipboard contents
    saves the state of the object calling this method in a memento matching the type of the object
    Provides access to the selection control object
    void
    Inserts a string in the buffer, which replaces the contents of the selection
    void
    Replaces the text within the interval specified by the selection object with the contents of the clipboard.
    void
    sets the attributes of the object calling this method to match the attributes the memento

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EngineImpl

      public EngineImpl()
  • Method Details

    • getSelection

      public Selection getSelection()
      Provides access to the selection control object
      Specified by:
      getSelection in interface Engine
      Returns:
      the selection object
    • getBufferContents

      public String getBufferContents()
      Provides the whole contents of the buffer, as a string
      Specified by:
      getBufferContents in interface Engine
      Returns:
      a copy of the buffer's contents
    • getClipboardContents

      public String getClipboardContents()
      Provides the clipboard contents
      Specified by:
      getClipboardContents in interface Engine
      Returns:
      a copy of the clipboard's contents
    • cutSelectedText

      public void cutSelectedText()
      Removes the text within the interval specified by the selection control object, from the buffer.
      Specified by:
      cutSelectedText in interface Engine
    • copySelectedText

      public void copySelectedText()
      Copies the text within the interval specified by the selection control object into the clipboard.
      Specified by:
      copySelectedText in interface Engine
    • pasteClipboard

      public void pasteClipboard()
      Replaces the text within the interval specified by the selection object with the contents of the clipboard.
      Specified by:
      pasteClipboard in interface Engine
    • insert

      public void insert(String s)
      Inserts a string in the buffer, which replaces the contents of the selection
      Specified by:
      insert in interface Engine
      Parameters:
      s - the text to insert
    • delete

      public void delete()
      Removes the contents of the selection in the buffer
      Specified by:
      delete in interface Engine
    • setMemento

      public void setMemento(Memento memento)
      Description copied from interface: Originator
      sets the attributes of the object calling this method to match the attributes the memento
      Specified by:
      setMemento in interface Originator
      Parameters:
      memento - Sets the attributes of the engine as in the memento
    • getMemento

      public EngineMemento getMemento()
      Description copied from interface: Originator
      saves the state of the object calling this method in a memento matching the type of the object
      Specified by:
      getMemento in interface Originator
      Returns:
      a memento of the state of the engine ie the clipboard, the selection, the buffer