S
- type of data that was removed and inserted in the TextEditingArea
.Self
- a subclass of TextChangepublic abstract class TextChange<S,Self extends TextChange<S,Self>>
extends java.lang.Object
RichTextChange
) and non-style changes (PlainTextChange
)
in a TextEditingArea
.Modifier and Type | Field and Description |
---|---|
protected S |
inserted |
protected int |
position |
protected S |
removed |
Constructor and Description |
---|
TextChange(int position,
S removed,
S inserted) |
Modifier and Type | Method and Description |
---|---|
protected abstract S |
concat(S a,
S b) |
protected abstract Self |
create(int position,
S removed,
S inserted) |
boolean |
equals(java.lang.Object other) |
S |
getInserted() |
int |
getInsertionEnd()
Returns the position where the inserted ends (e.g.
|
int |
getNetLength()
Gets the net length of this change (i.e.,
insertedLength() - removedLength() ) |
int |
getPosition()
Gets the start position of where the replacement happened
|
int |
getRemovalEnd()
Returns the position where the removal ends (e.g.
|
S |
getRemoved() |
int |
hashCode() |
protected abstract int |
insertedLength() |
Self |
invert()
Returns a new subclass of
TextChange that makes the inserted the removed object and
the removed the inserted object |
boolean |
isIdentity()
Returns true if this change is an identity change: applying it does nothing as it removes what it inserts.
|
java.util.Optional<Self> |
mergeWith(Self latter)
Merges this change with the given change, if possible.
|
protected abstract int |
removedLength() |
protected abstract S |
sub(S s,
int from,
int to) |
java.lang.String |
toString() |
protected final int position
protected final S removed
protected final S inserted
public int getPosition()
public S getRemoved()
public S getInserted()
public Self invert()
TextChange
that makes the inserted
the removed object and
the removed
the inserted objectpublic int getRemovalEnd()
position + removedLength())
public int getInsertionEnd()
position + insertedLength())
public int getNetLength()
insertedLength() - removedLength()
)protected abstract int removedLength()
protected abstract int insertedLength()
public final boolean isIdentity()
Function.identity()
public java.util.Optional<Self> mergeWith(Self latter)
latter
- change to merge with this change.null
otherwise.public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public final java.lang.String toString()
toString
in class java.lang.Object