Top Description Fields Constructors Methods
org.eclipse.swt.custom

pack-priv Class TextWriter

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.swt.custom.StyledTextWriterBase
Imports
org.eclipse.swt.*

The 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.

Field Summary

Modifier and TypeField and Description
private StringBuilder
private int
private boolean
private int

Constructor Summary

AccessConstructor and Description
public
TextWriter(int
start offset of content to write, 0 based from beginning of document
start
,
int
length of content to write
length
)

Creates a writer that writes content starting at offset "start" in the document.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Closes the writer.

public int

Returns:

the integer number of characters to write
getCharCount
()

Returns the number of characters to write.

public int

Returns:

the integer offset where writing starts
getStart
()

Returns the offset where writing starts.

public boolean

Returns:

a boolean specifying whether or not the writer is closed
isClosed
()

Returns whether the writer is closed.

public String

Returns:

the string
toString
()

Overrides java.lang.Object.toString.

Returns the string.
pack-priv void
write(String string)

Appends the given string to the data.

pack-priv void
write(String
text to insert
string
,
int
offset in the existing data to insert "string" at.
offset
)

Inserts the given string to the data at the specified offset.

pack-priv void
write(int i)

Appends the given int to the data.

pack-priv void
write(char i)

Appends the given character to the data.

public void
writeLine(String
line text to write. Must not contain line breaks Line breaks should be written using writeLineDelimiter()
line
,
int
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.
lineOffset
)

Appends the specified line text to the data.

public void
writeLineDelimiter(String
line delimiter to write
lineDelimiter
)

Appends the specified line delimiter to the data.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bufferback to summary
private StringBuilder buffer
endOffsetback to summary
private int endOffset
isClosedback to summary
private boolean isClosed
startOffsetback to summary
private int startOffset

Constructor Detail

TextWriterback to summary
public TextWriter(int start, int length)

Creates a writer that writes content starting at offset "start" in the document. start and length can be set to specify partial lines.

Parameters
start:int

start offset of content to write, 0 based from beginning of document

length:int

length of content to write

Method Detail

closeback to summary
public void close()

Closes the writer. Once closed no more content can be written

Note

toString() is not guaranteed to return a valid string unless the writer is closed.

getCharCountback to summary
public int getCharCount()

Returns the number of characters to write.

Returns:int

the integer number of characters to write

getStartback to summary
public int getStart()

Returns the offset where writing starts. 0 based from the start of the widget text. Used to write partial lines.

Returns:int

the integer offset where writing starts

isClosedback to summary
public boolean isClosed()

Returns whether the writer is closed.

Returns:boolean

a boolean specifying whether or not the writer is closed

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the string. close() must be called before toString() is guaranteed to return a valid string.

Returns:String

the string

Annotations
@Override
writeback to summary
pack-priv void write(String string)

Appends the given string to the data.

writeback to summary
pack-priv void write(String string, int offset)

Inserts the given string to the data at the specified offset.

Do nothing if "offset" is < 0 or > getCharCount()

Parameters
string:String

text to insert

offset:int

offset in the existing data to insert "string" at.

writeback to summary
pack-priv void write(int i)

Appends the given int to the data.

writeback to summary
pack-priv void write(char i)

Appends the given character to the data.

writeLineback to summary
public void writeLine(String line, int lineOffset)

Appends the specified line text to the data.

Parameters
line:String

line text to write. Must not contain line breaks Line breaks should be written using writeLineDelimiter()

lineOffset:int

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.

Exceptions
SWTException:
  • ERROR_IO when the writer is closed.
writeLineDelimiterback to summary
public void writeLineDelimiter(String lineDelimiter)

Appends the specified line delimiter to the data.

Parameters
lineDelimiter:String

line delimiter to write

Exceptions
SWTException:
  • ERROR_IO when the writer is closed.