public class SampleDocument
extends java.lang.Object
| Constructor and Description |
|---|
SampleDocument(History history) |
| Modifier and Type | Method and Description |
|---|---|
void |
forceStatus(java.util.List<java.lang.Character> characters,
int position)
Forces inner status of the document
Can be used for demonstrating Command.setExecuted().
|
void |
forceStatus(java.lang.String content,
int position)
Forces inner status of the document
|
java.util.List<java.lang.Character> |
getCharacters()
Gets the characters of this document (the content).
|
History |
getHistory()
Gets the history manager of this document.
|
int |
getPosition()
Gets current position of internal pointer.
|
int |
moveTo(int newPosition)
Moves internal pointer to the given position.
|
int |
moveToEnd()
Moves internal pointer to end (length of document).
|
int |
moveToStart()
Moves internal pointer to begin (zero).
|
boolean |
printChar(char character)
Inserts a character at position of internal pointer.
|
boolean |
printChars(char... characters)
Inserts multiple characters at position of internal pointer.
|
boolean |
removeChar()
Removes character before the current position of internal pointer.
|
java.lang.String |
toString() |
public SampleDocument(History history)
history - the history manager for handling commandspublic History getHistory()
public int moveTo(int newPosition)
newPosition - the new position of the internal pointerpublic int moveToStart()
public int moveToEnd()
public boolean removeChar()
true on successpublic boolean printChar(char character)
true on successpublic boolean printChars(char... characters)
true on successpublic java.util.List<java.lang.Character> getCharacters()
public int getPosition()
public void forceStatus(java.lang.String content,
int position)
content - string of characters, see the other versionposition - new position of the pointerpublic void forceStatus(java.util.List<java.lang.Character> characters,
int position)
characters - the new character listposition - new position of the pointerpublic java.lang.String toString()
toString in class java.lang.Object