Spec-Zone .ru
спецификации, руководства, описания, API
|
|
Java™ Platform Standard Ed. 6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.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
getLineSeparator()
,
Constant Field ValuesConstructor Detail |
---|
protected AbstractWriter(Writer w, Document doc)
w
- a Writer.doc
- a Documentprotected AbstractWriter(Writer w, Document doc, int pos, int len)
w
- a Writerdoc
- an Elementpos
- The location in the document to fetch the
content.len
- The amount to write out.protected AbstractWriter(Writer w, Element root)
w
- a Writerroot
- an Elementprotected AbstractWriter(Writer w, Element root, int pos, int len)
w
- a Writerroot
- an Elementpos
- The location in the document to fetch the
content.len
- The amount to write out.Method Detail |
---|
public int getStartOffset()
public int getEndOffset()
protected ElementIterator getElementIterator()
protected Writer getWriter()
protected Document getDocument()
protected boolean inRange(Element next)
next
- an Element.
protected abstract void write() throws IOException, BadLocationException
IOException
BadLocationException
protected String getText(Element elem) throws BadLocationException
elem
- an Element
String
BadLocationException
- if pos represents an invalid
location within the documentprotected void text(Element elem) 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(String value)
public String getLineSeparator()
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 errorprotected void write(char ch) throws IOException
write
method that takes a char[].
ch
- a char.
IOException
- on any I/O errorprotected void write(String content) throws IOException
write
method that takes a char[].
content
- a String.
IOException
- on any I/O errorprotected 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(AttributeSet attr) throws IOException
attr
- an AttributeSet.
IOException
- on any I/O errorprotected 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
|
Java™ Platform Standard Ed. 6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the