|
JavaTM 2 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 - Writerdoc - Elementpos - 在文檔中獲取內容的位置。len - 寫出量。
protected AbstractWriter(Writer w,
Element root)
w - Writerroot - Element
protected AbstractWriter(Writer w,
Element root,
int pos,
int len)
w - Writerroot - Elementpos - 在文檔中獲取內容的位置。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 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。