java.lang.Object | |
↳ | javax.swing.text.AbstractWriter |
![]() |
AbstractWriter is an abstract class that actually does the work of writing out the element tree including the attributes. In terms of how much is written out per line, the writer defaults to 100. But this value can be set by subclasses.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
char | NEWLINE | How the text packages models newlines. |
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new AbstractWriter.
| |||||||||||
Creates a new AbstractWriter.
| |||||||||||
Creates a new AbstractWriter.
| |||||||||||
Creates a new AbstractWriter.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the last offset to be output.
| |||||||||||
Returns the string used to represent newlines.
| |||||||||||
Returns the first offset to be output.
| |||||||||||
Sets the String used to reprsent newlines.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Decrements the indent level.
| |||||||||||
Returns whether or not the lines can be wrapped.
| |||||||||||
Returns the current line length.
| |||||||||||
Fetches the document.
| |||||||||||
Fetches the ElementIterator.
| |||||||||||
Returns the current indentation level.
| |||||||||||
Returns the amount of space to indent.
| |||||||||||
Returns the maximum line length.
| |||||||||||
Returns the text associated with the element.
| |||||||||||
Returns the Writer that is used to output the content.
| |||||||||||
This method determines whether the current element
is in the range specified.
| |||||||||||
Increments the indent level.
| |||||||||||
Does indentation.
| |||||||||||
Returns true if the current line should be considered empty.
| |||||||||||
The last stop in writing out content.
| |||||||||||
Sets whether or not lines can be wrapped.
| |||||||||||
Sets the current line length.
| |||||||||||
Enables subclasses to specify how many spaces an indent
maps to.
| |||||||||||
Enables subclasses to set the number of characters they
want written per line.
| |||||||||||
Writes out text.
| |||||||||||
All write methods call into this one.
| |||||||||||
This abstract method needs to be implemented
by subclasses.
| |||||||||||
Writes out a character.
| |||||||||||
Writes out a string.
| |||||||||||
Writes out the set of attributes as "
| |||||||||||
Writes the line separator.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Creates a new AbstractWriter. Initializes the ElementIterator with the default root of the document.
w | a Writer. |
---|---|
doc | a Document |
Creates a new AbstractWriter. Initializes the ElementIterator with the element passed in.
w | a Writer |
---|---|
doc | an Element |
pos | The location in the document to fetch the content. |
len | The amount to write out. |
Creates a new AbstractWriter. Initializes the ElementIterator with the element passed in.
w | a Writer |
---|---|
root | an Element |
Creates a new AbstractWriter. Initializes the ElementIterator with the element passed in.
w | a Writer |
---|---|
root | an Element |
pos | The location in the document to fetch the content. |
len | The amount to write out. |
Returns the last offset to be output.
Returns the first offset to be output.
Sets the String used to reprsent newlines. This is initialized in the constructor from either the Document, or the System property line.separator.
Decrements the indent level.
Returns whether or not the lines can be wrapped. If this is false no lineSeparator's will be output.
Returns the current line length.
Fetches the ElementIterator.
Returns the current indentation level. That is, the number of times
incrIndent
has been invoked minus the number of times
decrIndent
has been invoked.
Returns the amount of space to indent.
Returns the maximum line length.
Returns the text associated with the element. The assumption here is that the element is a leaf element. Throws a BadLocationException when encountered.
elem | an Element |
---|
String
BadLocationException | if pos represents an invalid location within the document |
---|
This method determines whether the current element is in the range specified. When no range is specified, the range is initialized to be the entire document. inRange() returns true if the range specified intersects with the element's range.
next | an Element. |
---|
Increments the indent level. If indenting would cause
getIndentSpace()
*getIndentLevel()
to be >
than getLineLength()
this will not cause an indent.
Does indentation. The number of spaces written out is indent level times the space to map mapping. If the current line is empty, this will not make it so that the current line is still considered empty.
IOException | on any I/O error |
---|
Returns true if the current line should be considered empty. This
is true when getCurrentLineLength
== 0 ||
indent
has been invoked on an empty line.
The last stop in writing out content. All the write methods eventually
make it to this method, which invokes write
on the
Writer.
This method also updates the line length based on
length
. If this is invoked to output a newline, the
current line length will need to be reset as will no longer be
valid. If it is up to the caller to do this. Use
writeLineSeparator
to write out a newline, which will
property update the current line length.
IOException |
---|
Sets whether or not lines can be wrapped. This can be toggled during the writing of lines. For example, outputting HTML might set this to false when outputting a quoted string.
Sets the current line length.
Enables subclasses to specify how many spaces an indent maps to. When indentation takes place, the indent level is multiplied by this mapping. The default is 2.
space | an int representing the space to indent mapping. |
---|
Enables subclasses to set the number of characters they want written per line. The default is 100.
l | the maximum line length. |
---|
Writes out text. If a range is specified when the constructor is invoked, then only the appropriate range of text is written out.
elem | an Element. |
---|
IOException | on any I/O error |
---|---|
BadLocationException | if pos represents an invalid location within the document. |
All write methods call into this one. If getCanWrapLines()
returns false, this will call output
with each sequence
of chars
that doesn't contain a NEWLINE, followed
by a call to writeLineSeparator
. On the other hand,
if getCanWrapLines()
returns true, this will split the
string, as necessary, so getLineLength
is honored.
The only exception is if the current string contains no whitespace,
and won't fit in which case the line length will exceed
getLineLength
.
IOException |
---|
This abstract method needs to be implemented by subclasses. Its responsibility is to iterate over the elements and use the write() methods to generate output in the desired format.
BadLocationException | |
---|---|
IOException |
Writes out a character. This is implemented to invoke
the write
method that takes a char[].
ch | a char. |
---|
IOException | on any I/O error |
---|
Writes out a string. This is implemented to invoke the
write
method that takes a char[].
content | a String. |
---|
IOException | on any I/O error |
---|
Writes out the set of attributes as "
attr | an AttributeSet. |
---|
IOException | on any I/O error |
---|
Writes the line separator. This invokes output
directly
as well as setting the lineLength
to 0.
IOException |
---|