java.lang.Objectjavax.swing.text.AbstractWriter
public abstract class 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.
Field Summary | |
---|---|
protected static char |
NEWLINE
How the text packages models newlines. |
Constructor Summary | |
---|---|
protected |
AbstractWriter
(
Writer
w,
Document
doc) Creates a new AbstractWriter. |
protected |
AbstractWriter
(
Writer
w,
Document
doc, int pos, int len) Creates a new AbstractWriter. |
protected |
AbstractWriter
(
Writer
w,
Element
root) Creates a new AbstractWriter. |
protected |
AbstractWriter
(
Writer
w,
Element
root, int pos, int len) Creates a new AbstractWriter. |
Method Summary | |
---|---|
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
elem) 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
next) 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
value) Sets the String used to reprsent newlines. |
protected void |
text
(
Element
elem) 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
content) Writes out a string. |
protected void |
writeAttributes
(
AttributeSet
attr) Writes out the set of attributes as " |
protected void |
writeLineSeparator
() Writes the line separator. |
Methods inherited from class java.lang. Object |
---|
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
Field Detail |
---|
protected static final char NEWLINE
Constructor Detail |
---|
protected AbstractWriter(Writer w, Document doc)
protected AbstractWriter(Writer w, Document doc, int pos, int len)
protected AbstractWriter(Writer w, Element root)
protected AbstractWriter(Writer w, Element root, int pos, int len)
Method Detail |
---|
public int getStartOffset()
public int getEndOffset()
protected ElementIterator getElementIterator()
protected Writer getWriter()
protected Document getDocument()
protected boolean inRange(Element next)
protected abstract void write() throws IOException, BadLocationException
protected String getText(Element elem) throws BadLocationException
protected void text(Element elem) throws BadLocationException, IOException
protected void setLineLength(int l)
protected int getLineLength()
protected void setCurrentLineLength(int length)
protected int getCurrentLineLength()
protected boolean isLineEmpty()
protected void setCanWrapLines(boolean newValue)
protected boolean getCanWrapLines()
protected void setIndentSpace(int space)
protected int getIndentSpace()
public void setLineSeparator(String value)
public String getLineSeparator()
protected void incrIndent()
protected void decrIndent()
protected int getIndentLevel()
protected void indent() throws IOException
protected void write(char ch) throws IOException
protected void write(String content) throws IOException
protected void writeLineSeparator() throws IOException
protected void write(char[] chars, int startIndex, int length) throws IOException
protected void writeAttributes(AttributeSet attr) throws IOException
protected void output(char[] content, int start, int length) throws IOException
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.