| 
 | JavaTM Platform Standard Ed. 6 | |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.swing.text.StringContent
public final class StringContent
AbstractDocument.Content 接口的一个实现,这是一个对相对于较小的文档和/或调试很有用的强制实现。它只能管理简单字符数组中的字符内容。而且其效率很低。
通常建议使用间隙缓冲区或拼凑表实现。此缓冲区无法扩展为大尺寸。
警告:此类的已序列化对象与以后的 Swing 版本不兼容。当前序列化支持适用于短期存储或运行相同 Swing 版本的应用程序之间的 RMI。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder。
| 构造方法摘要 | |
|---|---|
| StringContent()创建新的 StringContent 对象。 | |
| StringContent(int initialLength)创建具有指定初始大小的新 StringContent。 | |
| 方法摘要 | |
|---|---|
|  Position | createPosition(int offset)在内容中创建一个位置,让其跟踪随内容的变化而进行的更改。 | 
|  void | getChars(int where,
         int len,
         Segment chars)检索内容的某一部分,where + len 必须 <= length() | 
| protected  Vector | getPositionsInRange(Vector v,
                    int offset,
                    int length)返回一个包含 UndoPosRef 实例的 Vector,其 Position 的范围从 offset到offset+length。 | 
|  String | getString(int where,
          int len)检索内容的某一部分,where + len 必须 <= length()。 | 
|  UndoableEdit | insertString(int where,
             String str)将字符串插入到内容中。 | 
|  int | length()返回内容的长度。 | 
|  UndoableEdit | remove(int where,
       int nitems)移除部分内容,其中 where + nitems 必须 < length()。 | 
| protected  void | updateUndoPositions(Vector positions)在 positions处重新设置所有 UndoPosRef 实例的位置。 | 
| 从类 java.lang.Object 继承的方法 | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| 构造方法详细信息 | 
|---|
public StringContent()
public StringContent(int initialLength)
initialLength - 初始大小| 方法详细信息 | 
|---|
public int length()
AbstractDocument.Content 中的 lengthAbstractDocument.Content.length()
public UndoableEdit insertString(int where,
                                 String str)
                          throws BadLocationException
AbstractDocument.Content 中的 insertStringwhere - 起始位置,该值 >= 0 且 < length()str - 要插入的非 null 字符串
BadLocationException - 如果指定位置无效AbstractDocument.Content.insertString(int, java.lang.String)
public UndoableEdit remove(int where,
                           int nitems)
                    throws BadLocationException
AbstractDocument.Content 中的 removewhere - 起始位置,该值 >= 0nitems - 要移除的字符数,该值 >= 0
BadLocationException - 如果指定位置无效AbstractDocument.Content.remove(int, int)
public String getString(int where,
                        int len)
                 throws BadLocationException
AbstractDocument.Content 中的 getStringwhere - 起始位置,该值 >= 0len - 要检索的长度,该值 >= 0
BadLocationException - 如果指定位置无效AbstractDocument.Content.getString(int, int)
public void getChars(int where,
                     int len,
                     Segment chars)
              throws BadLocationException
AbstractDocument.Content 中的 getCharswhere - 起始位置,该值 >= 0len - 要检索的字符数,该值 >= 0chars - 要在其中返回字符的 Segment 对象
BadLocationException - 如果指定位置无效AbstractDocument.Content.getChars(int, int, javax.swing.text.Segment)
public Position createPosition(int offset)
                        throws BadLocationException
AbstractDocument.Content 中的 createPositionoffset - 所创建位置的偏移量,该值 >= 0
BadLocationException - 如果指定位置无效
protected Vector getPositionsInRange(Vector v,
                                     int offset,
                                     int length)
offset 到 offset + length。如果 v 不为 null,则在此处放置匹配的 Position。返回具有结果 Position 的向量。
 这里指的是内部用法,通常不适合子类。
v - 要使用的 Vector,其位置是向量为 null 时创建的新位置offset - 起始偏移量,该值 >= 0length - 长度,该值 >= 0
protected void updateUndoPositions(Vector positions)
positions 处重新设置所有 UndoPosRef 实例的位置。
 这里指的是内部用法,通常不适合子类。
positions - 实例的位置| 
 | JavaTM Platform Standard Ed. 6 | |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。