class StyledText.TextWriter
extends java.lang.Object
TextWriter class is used to write widget content to
a string. Whole and partial lines and line breaks can be written. To write
partial lines, specify the start and length of the desired segment
during object creation.
NOTE: toString() is guaranteed to return a valid string only after close()
has been called.
| Modifier and Type | Field and Description |
|---|---|
private java.lang.StringBuffer |
buffer |
private int |
endOffset |
private boolean |
isClosed |
private int |
startOffset |
| Constructor and Description |
|---|
StyledText.TextWriter(int start,
int length)
Creates a writer that writes content starting at offset "start"
in the document.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the writer.
|
int |
getCharCount()
Returns the number of characters to write.
|
int |
getStart()
Returns the offset where writing starts. 0 based from the start of
the widget text.
|
boolean |
isClosed()
Returns whether the writer is closed.
|
java.lang.String |
toString()
Returns the string.
|
(package private) void |
write(char i)
Appends the given character to the data.
|
(package private) void |
write(int i)
Appends the given int to the data.
|
(package private) void |
write(java.lang.String string)
Appends the given string to the data.
|
(package private) void |
write(java.lang.String string,
int offset)
Inserts the given string to the data at the specified offset.
|
void |
writeLine(java.lang.String line,
int lineOffset)
Appends the specified line text to the data.
|
void |
writeLineDelimiter(java.lang.String lineDelimiter)
Appends the specified line delimiter to the data.
|
private java.lang.StringBuffer buffer
private int startOffset
private int endOffset
private boolean isClosed
public StyledText.TextWriter(int start,
int length)
start and length can be set to specify partial lines.start - start offset of content to write, 0 based from beginning of documentlength - length of content to writepublic void close()
toString() is not guaranteed to return a valid string unless
the writer is closed.public int getCharCount()
public int getStart()
public boolean isClosed()
public java.lang.String toString()
close() must be called before toString()
is guaranteed to return a valid string.toString in class java.lang.Objectvoid write(java.lang.String string)
void write(java.lang.String string,
int offset)
Do nothing if "offset" is < 0 or > getCharCount()
string - text to insertoffset - offset in the existing data to insert "string" at.void write(int i)
void write(char i)
public void writeLine(java.lang.String line,
int lineOffset)
line - line text to write. Must not contain line breaks
Line breaks should be written using writeLineDelimiter()lineOffset - offset of the line. 0 based from the start of the
widget document. Any text occurring before the start offset or after the
end offset specified during object creation is ignored.SWTException - public void writeLineDelimiter(java.lang.String lineDelimiter)
lineDelimiter - line delimiter to writeSWTException -