public abstract class AbstractWriter extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static char |
NEWLINE
How the text packages models newlines.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractWriter(Writer
Creates a new AbstractWriter.
|
protected |
AbstractWriter(Writer
Creates a new AbstractWriter.
|
protected |
AbstractWriter(Writer
Creates a new AbstractWriter.
|
protected |
AbstractWriter(Writer
Creates a new AbstractWriter.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
decrIndent()
Decrements the indent level.
|
protected boolean |
getCanWrapLines()
Returns whether or not the lines can be wrapped.
|
protected int |
getCurrentLineLength()
Returns the current line length.
|
protected Document |
getDocument()
Fetches the document.
|
protected ElementIterator |
getElementIterator()
Fetches the ElementIterator.
|
int |
getEndOffset()
Returns the last offset to be output.
|
protected int |
getIndentLevel()
Returns the current indentation level.
|
protected int |
getIndentSpace()
Returns the amount of space to indent.
|
protected int |
getLineLength()
Returns the maximum line length.
|
String |
getLineSeparator()
Returns the string used to represent newlines.
|
int |
getStartOffset()
Returns the first offset to be output.
|
protected String |
getText(Element
Returns the text associated with the element.
|
protected Writer |
getWriter()
Returns the Writer that is used to output the content.
|
protected void |
incrIndent()
Increments the indent level.
|
protected void |
indent()
Does indentation.
|
protected boolean |
inRange(Element
This method determines whether the current element is in the range specified.
|
protected boolean |
isLineEmpty()
Returns true if the current line should be considered empty.
|
protected void |
output(char[] content, int start, int length)
The last stop in writing out content.
|
protected void |
setCanWrapLines(boolean newValue)
Sets whether or not lines can be wrapped.
|
protected void |
setCurrentLineLength(int length)
Sets the current line length.
|
protected void |
setIndentSpace(int space)
Enables subclasses to specify how many spaces an indent maps to.
|
protected void |
setLineLength(int l)
Enables subclasses to set the number of characters they want written per line.
|
void |
setLineSeparator(String
Sets the String used to represent newlines.
|
protected void |
text(Element
Writes out text.
|
protected abstract void |
write()
This abstract method needs to be implemented by subclasses.
|
protected void |
write(char ch)
Writes out a character.
|
protected void |
write(char[] chars, int startIndex, int length)
All write methods call into this one.
|
protected void |
write(String
Writes out a string.
|
protected void |
writeAttributes(AttributeSet
Writes out the set of attributes as " <name>=<value>" pairs.
|
protected void |
writeLineSeparator()
Writes the line separator.
|
protected static final char NEWLINE
getLineSeparator(),
Constant Field Values
protected AbstractWriter(Writerw, Document doc)
w - a Writer.
doc - a Document
protected AbstractWriter(Writerw, Document doc, int pos, int len)
w - a Writer
doc - an Element
pos - The location in the document to fetch the content.
len - The amount to write out.
protected AbstractWriter(Writerw, Element root)
w - a Writer
root - an Element
protected AbstractWriter(Writerw, Element root, int pos, int len)
w - a Writer
root - an Element
pos - The location in the document to fetch the content.
len - The amount to write out.
public int getStartOffset()
public int getEndOffset()
protected ElementIteratorgetElementIterator()
protected WritergetWriter()
protected DocumentgetDocument()
protected boolean inRange(Elementnext)
next - an Element.
protected abstract void write()
throws IOException,
BadLocationException
IOException
BadLocationException
protected StringgetText(Element elem) throws BadLocationException
elem - an
Element
String
BadLocationException - if pos represents an invalid location within the document
protected void text(Elementelem) throws BadLocationException , IOException
elem - an Element.
IOException - on any I/O error
BadLocationException - if pos represents an invalid location within the document.
protected void setLineLength(int l)
l - the maximum line length.
protected int getLineLength()
protected void setCurrentLineLength(int length)
protected int getCurrentLineLength()
protected boolean isLineEmpty()
getCurrentLineLength == 0 ||
indent has been invoked on an empty line.
protected void setCanWrapLines(boolean newValue)
protected boolean getCanWrapLines()
protected void setIndentSpace(int space)
space - an int representing the space to indent mapping.
protected int getIndentSpace()
public void setLineSeparator(Stringvalue)
public StringgetLineSeparator()
protected void incrIndent()
getIndentSpace() *
getIndentLevel() to be > than
getLineLength() this will not cause an indent.
protected void decrIndent()
protected int getIndentLevel()
incrIndent has been invoked minus the number of times
decrIndent has been invoked.
protected void indent()
throws IOException
IOException - on any I/O error
protected void write(char ch)
throws IOException
write method that takes a char[].
ch - a char.
IOException - on any I/O error
protected void write(Stringcontent) throws IOException
write method that takes a char[].
content - a String.
IOException - on any I/O error
protected void writeLineSeparator()
throws IOException
output directly as well as setting the
lineLength to 0.
IOException
protected void write(char[] chars,
int startIndex,
int length)
throws IOException
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
protected void writeAttributes(AttributeSetattr) throws IOException
attr - an AttributeSet.
IOException - on any I/O error
protected void output(char[] content,
int start,
int length)
throws IOException
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