|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.text.AbstractWriter
public abstract class AbstractWriter
This is an abstract base class for writing Document instances to a Writer. A concrete subclass must implement a method to iterate over the Elements of the Document and correctly format them.
Field Summary | |
---|---|
protected static char |
NEWLINE
The default line separator character. |
Constructor Summary | |
---|---|
protected |
AbstractWriter(Writer writer,
Document doc)
Create a new AbstractWriter with the indicated Writer and Document. |
protected |
AbstractWriter(Writer writer,
Document doc,
int pos,
int len)
Create a new AbstractWriter with the indicated Writer and Document. |
protected |
AbstractWriter(Writer writer,
Element elt)
Create a new AbstractWriter with the indicated Writer and Element. |
protected |
AbstractWriter(Writer writer,
Element elt,
int pos,
int len)
Create a new AbstractWriter with the indicated Writer and Element. |
Method Summary | |
---|---|
protected void |
decrIndent()
Decrement the indent level. |
protected boolean |
getCanWrapLines()
Return true if lines printed via write() will wrap, false otherwise. |
protected int |
getCurrentLineLength()
Return the current line length. |
protected Document |
getDocument()
Return this writer's Document. |
protected ElementIterator |
getElementIterator()
Return the ElementIterator for this writer. |
int |
getEndOffset()
Return the index of the Document at which output ends. |
protected int |
getIndentLevel()
Return the current indent level. |
protected int |
getIndentSpace()
Return the number of spaces per indent level. |
protected int |
getLineLength()
Return the maximum line length. |
String |
getLineSeparator()
Return the current line separator. |
int |
getStartOffset()
Return the index of the Document at which output starts. |
protected String |
getText(Element elt)
Return the text of the Document that is associated with the given Element. |
protected Writer |
getWriter()
Return the Writer to which we are writing. |
protected void |
incrIndent()
Increment the indent level. |
protected void |
indent()
Indent this line by emitting spaces, according to the current indent level and the current number of spaces per indent. |
protected boolean |
inRange(Element elt)
Return true if the Element's range overlaps our desired output range; false otherwise. |
protected boolean |
isLineEmpty()
Return true if the line is empty, false otherwise. |
protected void |
output(char[] data,
int start,
int len)
This method calls Writer.write on the indicated data, and updates the current line length. |
protected void |
setCanWrapLines(boolean canWrapLines)
Set the flag indicating whether lines will wrap. |
protected void |
setCurrentLineLength(int lineLength)
Set the current line length. |
protected void |
setIndentSpace(int indentSpace)
Set the number of spaces per indent level. |
protected void |
setLineLength(int maxLineLength)
Set the maximum line length. |
void |
setLineSeparator(String lineSeparator)
Set the current line separator. |
protected void |
text(Element elt)
Output the text of the indicated Element, properly clipping it to the range of the Document specified when the AbstractWriter was created. |
protected abstract void |
write()
This method must be overridden by a concrete subclass. |
protected void |
write(char ch)
Write a single character. |
protected void |
write(char[] data,
int start,
int len)
Write a character array to the output Writer, properly handling newlines and, if needed, wrapping lines as they are output. |
protected void |
write(String s)
Write a String. |
protected void |
writeAttributes(AttributeSet attrs)
Print the given AttributeSet as a sequence of assignment-like strings, e.g. |
protected void |
writeLineSeparator()
Write a line separator using the output method, and then reset the current line length. |
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 writer, Document doc)
protected AbstractWriter(Writer writer, Document doc, int pos, int len)
protected AbstractWriter(Writer writer, Element elt)
protected AbstractWriter(Writer writer, Element elt, int pos, int len)
Method Detail |
---|
protected ElementIterator getElementIterator()
protected Writer getWriter()
protected Document getDocument()
protected abstract void write() throws IOException, BadLocationException
IOException
BadLocationException
protected String getText(Element elt) throws BadLocationException
BadLocationException
- if the element is not a leafprotected void output(char[] data, int start, int len) throws IOException
IOException
protected void writeLineSeparator() throws IOException
IOException
protected void write(char ch) throws IOException
IOException
protected void write(String s) throws IOException
IOException
protected void write(char[] data, int start, int len) throws IOException
IOException
protected void indent() throws IOException
IOException
public int getStartOffset()
public int getEndOffset()
protected boolean inRange(Element elt)
protected void text(Element elt) throws BadLocationException, IOException
BadLocationException
IOException
protected void setLineLength(int maxLineLength)
protected int getLineLength()
protected void setCurrentLineLength(int lineLength)
protected int getCurrentLineLength()
protected boolean isLineEmpty()
protected void setCanWrapLines(boolean canWrapLines)
protected boolean getCanWrapLines()
protected void setIndentSpace(int indentSpace)
protected int getIndentSpace()
public void setLineSeparator(String lineSeparator)
public String getLineSeparator()
protected void incrIndent()
protected void decrIndent()
protected int getIndentLevel()
protected void writeAttributes(AttributeSet attrs) throws IOException
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |