org.zaval.data
Class SingleLineTxt
java.lang.Object
|
+--org.zaval.data.SingleLineTxt
- All Implemented Interfaces:
- TextModel
- public class SingleLineTxt
- extends java.lang.Object
- implements TextModel
This class is an implementation of the TextModel interface. It is used to
represent single line text, it means that in any case the specified input string is
parsed to single line (you can use '\n' delimiter, but it will not have effect)
text.
|
Constructor Summary |
SingleLineTxt(java.lang.String s)
Constructs a new text with the given text. |
SingleLineTxt(java.lang.String s,
int max)
Constructs a new text with the given text and the specified maximal length. |
|
Method Summary |
void |
addTextListener(TextListener l)
Adds the specified text listener. |
int |
getExtraChar(int i)
Gets special extra char that is used to store extra information by the specified index.
|
java.lang.String |
getLine(int line)
Returns the line at the specified line number. |
int |
getSize()
Returns the line number of the text. |
java.lang.String |
getText()
Returns the original text data that have been set with setText method. |
int |
getTextLength()
Returns the text length. |
void |
remove(int offset,
int size)
Removes a text at the specified offset with the size. |
void |
removeTextListener(TextListener l)
Removes the specified text listener. |
void |
setExtraChar(int i,
int ch)
Sets special extra char that is used to store extra information by the specified index.
|
void |
setText(java.lang.String text)
Sets the specified text data. |
void |
write(char ch,
int offset)
Inserts the specified character at the given offset. |
void |
write(java.lang.String s,
int offset)
Inserts the specified text at the given offset. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SingleLineTxt
public SingleLineTxt(java.lang.String s)
- Constructs a new text with the given text.
- Parameters:
s - the initial value of the text.
SingleLineTxt
public SingleLineTxt(java.lang.String s,
int max)
- Constructs a new text with the given text and the specified maximal length.
- Parameters:
s - the initial value of the text.max - the specified maximal length.
getLine
public java.lang.String getLine(int line)
- Returns the line at the specified line number.
- Specified by:
getLine in interface TextModel
- Parameters:
line - the specified line number. The implementation doesn't use
the argument, since this is single line implementation.- Returns:
- a line at the specified line number.
setText
public void setText(java.lang.String text)
- Sets the specified text data. The method performs the text data parsing process.
The process decides how the text data have to be divided into lines. The implementation
uses the input text as is.
- Specified by:
setText in interface TextModel
- Parameters:
text - the text data.
getText
public java.lang.String getText()
- Returns the original text data that have been set with
setText method.
- Specified by:
getText in interface TextModel
- Returns:
- an original text data.
getSize
public int getSize()
- Returns the line number of the text.
- Specified by:
getSize in interface TextModel
- Returns:
- a line number.
write
public void write(java.lang.String s,
int offset)
- Inserts the specified text at the given offset. The offset has to be less than the text
length. The method performs re-parsing of the text.
- Specified by:
write in interface TextModel
- Parameters:
s - the text to be inserted.offset - the offset where the text will be inserted.
write
public void write(char ch,
int offset)
- Inserts the specified character at the given offset. The offset has to be less than the text
length. The method performs re-parsing of the text.
- Specified by:
write in interface TextModel
- Parameters:
ch - the character to be inserted.offset - the offset where the character will be inserted.
remove
public void remove(int offset,
int size)
- Removes a text at the specified offset with the size. The offset and the offset plus the
size have to be less than the text length.
- Specified by:
remove in interface TextModel
- Parameters:
offset - the offset where the text will be removed.size - the size of the part that is going to be removed.
addTextListener
public void addTextListener(TextListener l)
- Adds the specified text listener.
- Specified by:
addTextListener in interface TextModel
- Parameters:
l - the text listener.
removeTextListener
public void removeTextListener(TextListener l)
- Removes the specified text listener.
- Specified by:
removeTextListener in interface TextModel
- Parameters:
l - the text listener.- See Also:
TextListener,
TextEvent
getTextLength
public int getTextLength()
- Returns the text length.
- Specified by:
getTextLength in interface TextModel
- Returns:
- a text length.
getExtraChar
public int getExtraChar(int i)
- Description copied from interface:
TextModel
- Gets special extra char that is used to store extra information by the specified index.
The method is deprecated to be used, because it will be probably re-designed in the future.
- Specified by:
getExtraChar in interface TextModel
- Following copied from interface:
org.zaval.data.TextModel
- Parameters:
i - the specified extra char index.- Returns:
- an extra char value.
setExtraChar
public void setExtraChar(int i,
int ch)
- Description copied from interface:
TextModel
- Sets special extra char that is used to store extra information by the specified index.
The method is deprecated, since probably it will be re-designed in the future.
- Specified by:
setExtraChar in interface TextModel
- Following copied from interface:
org.zaval.data.TextModel
- Parameters:
i - the specified extra char index.val - the specified extra char value.
|