public class TextChangeImpl extends java.lang.Object implements TextChange
TextChange
implementation with mutable state.Constructor and Description |
---|
TextChangeImpl(java.lang.CharSequence text,
int start)
Shorthand for creating change object with the given arguments where
'end index' has the same value as
'start index' . |
TextChangeImpl(java.lang.CharSequence text,
int start,
int end)
Creates new
TextChange object with the given arguments. |
Modifier and Type | Method and Description |
---|---|
void |
advance(int offset)
|
boolean |
equals(java.lang.Object o) |
char [] |
getChars()
Allows to get change text as a char array.
|
int |
getDiff()
Difference in document symbols number after current change appliance.
|
int |
getEnd() |
int |
getStart() |
java.lang.CharSequence |
getText()
Allows to retrieve text that is directly affected by the change encapsulated by the current object.
|
int |
hashCode() |
void |
setEnd(int end) |
void |
setStart(int start) |
java.lang.String |
toString() |
public TextChangeImpl(java.lang.CharSequence text, int start) throws java.lang.IllegalArgumentException
'end index'
has the same value as
'start index'
.text
- text affected by the current changestart
- start index (inclusive) of text range affected by the change encapsulated by the current objectjava.lang.IllegalArgumentException
- if given start index is invalidpublic TextChangeImpl(java.lang.CharSequence text, int start, int end) throws java.lang.IllegalArgumentException
TextChange
object with the given arguments. It encapsulates information about the change that
may be applied to the target document.text
- text that is introduced by the current changestart
- start index of the target document location where current change is to be appliedend
- end index of the target document where current change is to be applied, i.e. it's assumed that current text
change appliance to particular document causes replacement of its original text at [start; end)
interval by the text encapsulated by the current change. I.e. original text is replaced by the new onejava.lang.IllegalArgumentException
- if given start or end index in invalid or they are inconsistent to each otherpublic int getStart()
getStart
in interface TextChange
public void setStart(int start)
public int getEnd()
getEnd
in interface TextChange
public void setEnd(int end)
public java.lang.CharSequence getText()
getText
in interface TextChange
public char [] getChars()
getText()
result.
Generally speaking, this method is introduced just as a step toward existing high-performance services that work in terms
of char arrays. Resulting array is instantiated on-demand via CharArrayUtil.fromSequence(CharSequence)
, hence, it
doesn't hit memory if, for example, CharSequenceBackedByArray
is used as initial change text.getChars
in interface TextChange
public int getDiff()
'remove'
or 'replace'
changes (number of text symbols is less than number of symbols at target change interval)public void advance(int offset) throws java.lang.IllegalArgumentException
offset
- offset to apply to the current change objectjava.lang.IllegalArgumentException
- if start index becomes zero after given offset appliance (it is not applied then)public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object