public class GapContent extends Object implements AbstractDocument.Content, Serializable
的位置跟踪变化也普遍便宜,以保持。位置实现(标记)存储数组索引,并可以很容易地计算从当前的间隙位置的顺序位置。改变只需要更新到旧的和新的差距边界之间的标志时,差距是移动,所以一般更新的标志是相当便宜的。标记存储排序,所以它们可以很快地找到一个二进制搜索。这增加了增加一个标记的成本,并降低保持标记更新的成本。
| Constructor and Description |
|---|
GapContent()
创建一个新的gapcontent对象。
|
GapContent(int initialLength)
创建一个新的gapcontent对象,指定的初始大小。
|
| Modifier and Type | Method and Description |
|---|---|
protected Object |
allocateArray(int len)
分配一个数组来存储类型的项目(由子类决定)。
|
Position |
createPosition(int offset)
在内容被突变的内容中创建一个将跟踪更改的内容。
|
protected Object |
getArray()
访问数组。
|
protected int |
getArrayLength()
获取所分配的数组的长度。
|
void |
getChars(int where, int len, Segment chars)
检索内容的一部分。
|
protected int |
getGapEnd()
访问结束的差距。
|
protected int |
getGapStart()
访问开始的差距。
|
protected Vector |
getPositionsInRange(Vector v, int offset, int length)
返回一个向量,包含的范围
offset位置
offset +
length的undoposref实例。
|
String |
getString(int where, int len)
检索内容的一部分。
|
UndoableEdit |
insertString(int where, String str)
在内容中插入一个字符串。
|
int |
length()
返回内容的长度。
|
UndoableEdit |
remove(int where, int nitems)
删除内容的一部分。
|
protected void |
replace(int position, int rmSize, Object addItems, int addSize)
在给定的新项目的存储中替换给定的逻辑位置。
|
protected void |
resetMarksAtZero()
重置所有的标志,有0有一个零指数以及偏移。
|
protected void |
shiftEnd(int newSize)
使间隙更大,移动任何必要的数据并更新相应的标志
|
protected void |
shiftGap(int newGapStart)
将间隙的开始移动到一个新的位置,而不改变间隙的大小。
|
protected void |
shiftGapEndUp(int newGapEnd)
调整间隙向上。
|
protected void |
shiftGapStartDown(int newGapStart)
调整间隙端向下。
|
protected void |
updateUndoPositions(Vector positions, int offset, int length)
在
positions重置所有undoposref实例的位置。
|
public GapContent()
public GapContent(int initialLength)
initialLength -初始大小
protected Object allocateArray(int len)
protected int getArrayLength()
public int length()
length 接口
AbstractDocument.Content
AbstractDocument.Content.length()
public UndoableEdit insertString(int where, String str) throws BadLocationException
insertString 接口
AbstractDocument.Content
where -起始位置> = 0,P<0.05 length()
str -非空字符串插入
BadLocationException -如果指定的位置是无效的
AbstractDocument.Content.insertString(int, java.lang.String)
public UndoableEdit remove(int where, int nitems) throws BadLocationException
remove 接口
AbstractDocument.Content
where -起始位置> = 0,其中+ nitems < length()
nitems -字符数删除> = 0
BadLocationException -如果指定的位置是无效的
AbstractDocument.Content.remove(int, int)
public String getString(int where, int len) throws BadLocationException
getString 接口
AbstractDocument.Content
where -起始位置> = 0
len长度-检索> = 0
BadLocationException -如果指定的位置是无效的
AbstractDocument.Content.getString(int, int)
public void getChars(int where,
int len,
Segment chars)
throws BadLocationException
getChars 接口
AbstractDocument.Content
where -起始位置> = 0,其中+ len <= length()
len -字符数检索> = 0
chars -段对象返回的字符
BadLocationException -如果指定的位置是无效的
AbstractDocument.Content.getChars(int, int, javax.swing.text.Segment)
public Position createPosition(int offset) throws BadLocationException
createPosition 接口
AbstractDocument.Content
offset -偏移跟踪> = 0
BadLocationException -如果指定的位置是无效的
protected void shiftEnd(int newSize)
protected void shiftGap(int newGapStart)
protected void resetMarksAtZero()
protected void shiftGapStartDown(int newGapStart)
protected void shiftGapEndUp(int newGapEnd)
protected Vector getPositionsInRange(Vector v, int offset, int length)
offset位置
offset +
length的undoposref实例。如果
v不是空的配合位置放在那里。返回的位置的向量。
v的载体使用,以创建一个新的空
offset -起始偏移> = 0
length -长度> = 0
protected void updateUndoPositions(Vector positions, int offset, int length)
positions重置所有undoposref实例的位置。
这是为了内部使用,通常是不感兴趣的子类。
positions - undoposref实例重置
protected final Object getArray()
protected final int getGapStart()
protected final int getGapEnd()
protected void replace(int position,
int rmSize,
Object addItems,
int addSize)
position -位置进行更换。这不是底层存储数组中的位置,而是在相邻的空间中被建模的位置。
rmSize -数项删除
addItems -放置在储存新项目。
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.