|  
      JavaTM Platform Standard Ed. 6  |  
    |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.swing.text.AbstractWriter
public abstract class AbstractWriter
     AbstractWriter 是一个抽象类,它实际执行元素树(包括属性)的写出工作。在每行写出的元素数方面,writer 默认值是 100。但是子类可设置此值。
| 字段摘要 | |
|---|---|
 protected static char |  
     NEWLINE text 包模拟新行的方式。  |  
    
| 构造方法摘要 | |
|---|---|
 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。  |  
    
| 方法摘要 | |
|---|---|
 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() 返回用于表示换行的 String。  |  
    
  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) 设置用于表示换行的 String。  |  
    
 protected  void |  
     text(Element elem) 写出文本。  |  
    
 protected abstract  void |  
     write() 需要由子类实现此抽象方法。  |  
    
 protected  void |  
     write(char ch) 写出字符。  |  
    
 protected  void |  
     write(char[] chars, int startIndex, int length) 所有 write 方法都调用到此方法。  |  
    
 protected  void |  
     write(String content) 写出字符串。  |  
    
 protected  void |  
     writeAttributes(AttributeSet attr) 以 "  |  
    
 protected  void |  
     writeLineSeparator() 写入行分隔符。  |  
    
| 从类 java.lang.Object 继承的方法 | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |  
    
| 字段详细信息 | 
|---|
protected static final char NEWLINE
getLineSeparator(), 
      常量字段值
     | 构造方法详细信息 | 
|---|
protected AbstractWriter(Writer w,
                         Document doc) 
  
w - Writer。
     document - Document。
     
protected AbstractWriter(Writer w,
                         Document doc,
                         int pos,
                         int len) 
  
w - Writer
     doc - Element
     pos - 在文档中获取内容的位置。
     len - 写出量。
     
protected AbstractWriter(Writer w,
                         Element root) 
  
w - Writer
     root - Element
     
protected AbstractWriter(Writer w,
                         Element root,
                         int pos,
                         int len) 
  
w - Writer
     root - Element
     pos - 在文档中获取内容的位置。
     len - 写出量。
     | 方法详细信息 | 
|---|
public int getStartOffset()
public int getEndOffset()
protected ElementIterator getElementIterator()
protected Writer getWriter()
protected Document getDocument()
protected boolean inRange(Element next)
next - Element。 
     
protected abstract void write()
                       throws IOException,
                              BadLocationException 
  
IOException 
     BadLocationException
     
protected String getText(Element elem)
                  throws BadLocationException 
  
elem - 
      Element 
     String 形式的文本 
     BadLocationException - 如果 pos 表示文档内的无效位置
     
protected void text(Element elem)
             throws BadLocationException,
                    IOException 
  
elem - Element。 
     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 时返回值仍为 true。 
    
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 - 一个 char。 
     IOException - 如果发生任何 I/O 错误
     
protected void write(String content)
              throws IOException 
  write 方法来实现字符的写出。 
    
content - String。 
     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,则将使用不包含 NEWLINE 的每个 
    chars 序列调用 
    output,然后调用 
    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
      
        
      
  |  
      JavaTM Platform Standard Ed. 6  |  
    |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。