public abstract class AbstractWriter extends Object
| Modifier and Type | Field and Description | 
|---|---|
| protected static char | NEWLINE
              文本包如何模型换行。 
             | 
| Modifier | Constructor and Description | 
|---|---|
| protected  | AbstractWriter(Writer w, Document doc)
              创建一个新的AbstractWriter。 
             | 
| protected  | AbstractWriter(Writer w, Document doc, int pos, int len)
              创建一个新的AbstractWriter。 
             | 
| protected  | AbstractWriter(Writer w, Element root)
              创建一个新的AbstractWriter。 
             | 
| protected  | AbstractWriter(Writer w, Element root, int pos, int len)
              创建一个新的AbstractWriter。 
             | 
| Modifier and Type | Method and Description | 
|---|---|
| protected void | decrIndent()
              减少缩进级别。 
             | 
| protected boolean | getCanWrapLines()
              返回是否可以包装线。 
             | 
| protected int | getCurrentLineLength()
              返回当前行长度。 
             | 
| protected Document | getDocument()
              获取文档。 
             | 
| protected ElementIterator | getElementIterator()
              获取ElementIterator。 
             | 
| int | getEndOffset()
              返回要输出的最后一个偏移量。 
             | 
| protected int | getIndentLevel()
              返回当前缩进级别。 
             | 
| protected int | getIndentSpace()
              返回要缩进的空间量。 
             | 
| protected int | getLineLength()
              返回最大行长度。 
             | 
| String | getLineSeparator()
              返回用于表示换行符的字符串。 
             | 
| int | getStartOffset()
              返回要输出的第一个偏移量。 
             | 
| protected String | getText(Element elem)
              返回与元素关联的文本。 
             | 
| protected Writer | getWriter()
              返回用于输出内容的Writer。 
             | 
| protected void | incrIndent()
              增加缩进级别。 
             | 
| protected void | indent()
              缩进 
             | 
| protected boolean | inRange(Element next)
              此方法确定当前元素是否在指定的范围内。 
             | 
| protected boolean | isLineEmpty()
              如果当前行被视为空,则返回true。 
             | 
| protected void | output(char[] content, int start, int length)
              写出内容的最后一站。 
             | 
| protected void | setCanWrapLines(boolean newValue)
              设置是否可以包装线。 
             | 
| protected void | setCurrentLineLength(int length)
              设置当前行长度。 
             | 
| protected void | setIndentSpace(int space)
              启用子类来指定缩进映射到的空格。 
             | 
| protected void | setLineLength(int l)
              启用子类来设置每行要写入的字符数。 
             | 
| void | setLineSeparator(String value)
              设置用于表示换行符的字符串。 
             | 
| protected void | text(Element elem)
              写出文字。 
             | 
| protected abstract void | write()
              这个抽象方法需要由子类实现。 
             | 
| protected void | write(char ch)
              写出一个字符 
             | 
| protected void | write(char[] chars, int startIndex, int length)
              所有写入方法都调用到这一个中。 
             | 
| protected void | write(String content)
              写出一个字符串。 
             | 
| protected void | writeAttributes(AttributeSet attr)
              将属性集写入“<name> = <value>”对。 
             | 
| protected void | writeLineSeparator()
              写行分隔符。 
             | 
protected AbstractWriter(Writer w, Document doc)
w - 作家。 
           doc - 一份文件 
           protected AbstractWriter(Writer w, Document doc, int pos, int len)
w - 作家 
           doc - 一个元素 
           pos - 文档中获取内容的位置。 
           len - 写出的金额。 
           protected AbstractWriter(Writer w, Element root)
w - 作家 
           root - 一个元素 
           public int getStartOffset()
public int getEndOffset()
protected ElementIterator getElementIterator()
protected Writer getWriter()
protected Document getDocument()
protected boolean inRange(Element next)
next - 元素。 
           protected abstract void write()
                       throws IOException,
                              BadLocationException 
          protected String getText(Element elem) throws BadLocationException
elem - 
            Element 
           String 
           BadLocationException - 如果pos表示文档中的无效位置 
           protected void text(Element elem) throws BadLocationException, IOException
elem - 元素。 
           IOException - 在任何I / O错误 
           BadLocationException - 如果pos表示文档中的无效位置。 
           protected void setLineLength(int l)
l - 最大线路长度。 
           protected int getLineLength()
protected void setCurrentLineLength(int length)
protected int getCurrentLineLength()
protected boolean isLineEmpty()
getCurrentLineLength == 0 || 
           indent已被空白行调用。 
          protected void setCanWrapLines(boolean newValue)
protected boolean getCanWrapLines()
protected void setIndentSpace(int space)
space - 表示缩进映射空间的int。 
           protected int getIndentSpace()
public void setLineSeparator(String value)
public String getLineSeparator()
protected void incrIndent()
getIndentSpace() * getIndentLevel() >> getLineLength()这不会造成缩进。 
          protected void decrIndent()
protected int getIndentLevel()
incrIndent减去已调用的次数decrIndent 。 
          protected void indent()
               throws IOException 
          IOException - 任何I / O错误 
           protected void write(char ch)
              throws IOException 
          write方法。 
          ch - 一个字符。 
           IOException - 在任何I / O错误 
           protected void write(String content) throws IOException
write方法。 
          content - 一个字符串。 
           IOException - 在任何I / O错误 
           protected void writeLineSeparator()
                           throws IOException 
          output直接以及设置lineLength为0。 
          IOException 
           protected void write(char[] chars,
                     int startIndex,
                     int length)
              throws IOException 
          getCanWrapLines()返回false,这将调用output与每个序列chars不包含换行,随后将呼叫writeLineSeparator 。 
           另一方面,如果getCanWrapLines()返回true,这将分割字符串,如有必要,所以getLineLength被兑现。 
           唯一的例外是如果当前字符串不包含空格,并且不适合在这种情况下行长度将超过getLineLength 。 
          IOException 
           protected void writeAttributes(AttributeSet attr) throws IOException
attr - 一个AttributeSet。 
           IOException - 在任何I / O错误 
           protected void output(char[] content,
                      int start,
                      int length)
               throws IOException 
          write 。 
            此方法还会根据length更新行长度。 如果调用此方法来输出换行符,则当前行长度将不再重新设置为不再有效。 如果由呼叫者来做到这一点。 使用writeLineSeparator写出一个换行符,它将更新当前行长度。 
IOException 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.