站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

MarkBlock (Editor Library) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.lib/1 1.14.0 3

org.netbeans.editor
Class MarkBlock

java.lang.Object
  extended by org.netbeans.editor.MarkBlock

public class MarkBlock
extends Object

Block of text created using two marks. These blocks can be chained. Existing block can be compared to other block (better pair of positions) and there's extensive list of result values of such comparison.


Field Summary
static int AFTER
          Tested block completely after THIS mark block.
static int BEFORE
          Tested block completely before THIS mark block.
static int CONTINUE
          Single bit value that means that the tested block doesn't overlap with THIS block, but either its start position is equal to end position of THIS block or its end position is equal to the start position of THIS block.
static int CONTINUE_BEGIN
          Tested block completely before THIS mark block but its end position equals to the start position of THIS block.
static int CONTINUE_END
          Tested block completely after THIS mark block but its start position equals to the end position of THIS block.
protected  BaseDocument doc
           
static int EMPTY
          Single bit value meaning that the tested block has zero size.
 Mark endMark
           
static int EXTEND
          Two bit value meaning that the tested block fully includes THIS block.
static int EXTEND_BEGIN
          Start position of the tested block is lower than the start position of THIS block and both end positions are the same.
static int EXTEND_END
          End position of the tested block is greater than the end position of THIS block and both start positions are the same.
static int IGNORE_EMPTY
          This value can be used to clear the two bits saying if the tested or THIS block are empty (The EMPTY and THIS_EMPTY are cleared).
static int INCLUDE
          Tested block fully includes THIS block and extends it by at least one character in both directions.
static int INNER
          Tested block is fully inside THIS block and there is at least one more character left in THIS block after the end of the tested block in both directions.
static int INSIDE
          Two bit value meaning that the tested block is fully inside THIS block.
static int INSIDE_BEGIN
          Tested block completely inside THIS block and its end position is lower than end position of THIS block and start positions are the same.
static int INSIDE_END
          Tested block completely inside THIS block and its start position is greater than THIS block start position and end positions are the same.
static int INVALID
          This value is not used directly in this class but can be used by other classes to report that the comparison of blocks has no sense for some reason.
protected  MarkBlock next
          Next block in the chain
static int OVERLAP
          Single bit value that means that tested block and THIS block partially or fully overlap.
static int OVERLAP_BEGIN
          Tested block partly covers begining of THIS mark block.
static int OVERLAP_END
          Tested block partly covers end of THIS mark block.
protected  MarkBlock prev
          Previous block in the chain
static int SAME
          The blocks have exactly the same start and end positions.
 Mark startMark
           
static int THIS_EMPTY
          Single bit value meaning that THIS block has zero size.
 
Constructor Summary
MarkBlock(BaseDocument doc, int startPos, int endPos)
          Construct block with given marks
MarkBlock(BaseDocument doc, Mark startMark, Mark endMark)
           
MarkBlock(BaseDocument doc, Mark startMark, Mark endMark, int startPos, int endPos)
          Construct block from positions on some document
 
Method Summary
 MarkBlock addChain(MarkBlock blk)
          Add block after this one
 boolean checkReverse()
           
 int compare(int startPos, int endPos)
          Compares the position of the given block against current block.
static String debugRelation(int rel)
           
 boolean extend(int startPos, int endPos, boolean concat)
          Extend this mark block by start and end positions.
 boolean extend(MarkBlock blk, boolean concat)
          Extend this mark block by some other block.
 int extendEnd(int endPos)
          Possibly move end mark if its position is above the given number.
 int extendStart(int startPos)
          Possibly move start mark if its position is above the given number.
protected  void finalize()
          Destroy the marks if necessary
 Document getDocument()
           
 int getEndOffset()
           
 MarkBlock getNext()
           
 MarkBlock getPrev()
           
 int getStartOffset()
           
 MarkBlock insertChain(MarkBlock blk)
          Insert block before this one
 boolean isReverse()
           
 MarkBlock removeChain()
          Remove this block from the chain
 void reverse()
           
 void setNext(MarkBlock b)
           
 void setNextChain(MarkBlock b)
          Set the next block of this one in the chain.
 void setPrev(MarkBlock b)
           
 void setPrevChain(MarkBlock b)
          Set the previous block of this one in the chain
 int shrink(int startPos, int endPos)
          Shrink this mark block by the block specified.
 String toString()
          Debugs this mark block
 String toStringChain()
          Debug possibly whole chain of marks
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INVALID

public static final int INVALID
This value is not used directly in this class but can be used by other classes to report that the comparison of blocks has no sense for some reason.

See Also:
Constant Field Values

OVERLAP

public static final int OVERLAP
Single bit value that means that tested block and THIS block partially or fully overlap. If this bit is not set then the blocks don't overlap at all. The values for which this bit is set are: OVERLAP_BEGIN, OVERLAP_END, EXTEND_BEGIN, EXTEND_END, INCLUDE, INSIDE_BEGIN, INSIDE_END, SAME, INNER. The values for which this bit is not set are: BEFORE, AFTER, CONTINUE_BEGIN, CONTINUE_END.

See Also:
Constant Field Values

CONTINUE

public static final int CONTINUE
Single bit value that means that the tested block doesn't overlap with THIS block, but either its start position is equal to end position of THIS block or its end position is equal to the start position of THIS block. Simply they together make one continuous block. The values for which this bit is set are: CONTINUE_BEGIN, CONTINUE_END.

See Also:
Constant Field Values

EMPTY

public static final int EMPTY
Single bit value meaning that the tested block has zero size.

See Also:
Constant Field Values

THIS_EMPTY

public static final int THIS_EMPTY
Single bit value meaning that THIS block has zero size.

See Also:
Constant Field Values

EXTEND

public static final int EXTEND
Two bit value meaning that the tested block fully includes THIS block. The block must be extended at least by one character, otherwise the 'inside' values will be used. It is included in the following values: EXTEND_BEGIN, INCLUDE, EXTEND_END. The value includes OVERLAP.

See Also:
Constant Field Values

INSIDE

public static final int INSIDE
Two bit value meaning that the tested block is fully inside THIS block. It is included in the following values: INSIDE_BEGIN, SAME, INSIDE_END. The value includes OVERLAP.

See Also:
Constant Field Values

BEFORE

public static final int BEFORE
Tested block completely before THIS mark block.

See Also:
Constant Field Values

AFTER

public static final int AFTER
Tested block completely after THIS mark block.

See Also:
Constant Field Values

CONTINUE_BEGIN

public static final int CONTINUE_BEGIN
Tested block completely before THIS mark block but its end position equals to the start position of THIS block. They together make one continuous block. The value is BEFORE | CONTINUE.

See Also:
Constant Field Values

CONTINUE_END

public static final int CONTINUE_END
Tested block completely after THIS mark block but its start position equals to the end position of THIS block. They together make one continuous block. The value is AFTER | CONTINUE.

See Also:
Constant Field Values

OVERLAP_BEGIN

public static final int OVERLAP_BEGIN
Tested block partly covers begining of THIS mark block. The value includes OVERLAP.

See Also:
Constant Field Values

OVERLAP_END

public static final int OVERLAP_END
Tested block partly covers end of THIS mark block. The value includes OVERLAP.

See Also:
Constant Field Values

EXTEND_BEGIN

public static final int EXTEND_BEGIN
Start position of the tested block is lower than the start position of THIS block and both end positions are the same. The value is OVERLAP_BEGIN | EXTEND.

See Also:
Constant Field Values

EXTEND_END

public static final int EXTEND_END
End position of the tested block is greater than the end position of THIS block and both start positions are the same. The value is OVERLAP_END | EXTEND.

See Also:
Constant Field Values

INCLUDE

public static final int INCLUDE
Tested block fully includes THIS block and extends it by at least one character in both directions. The value is EXTEND_BEGIN | EXTEND_END.

See Also:
Constant Field Values

INSIDE_BEGIN

public static final int INSIDE_BEGIN
Tested block completely inside THIS block and its end position is lower than end position of THIS block and start positions are the same. The value includes INSIDE.

See Also:
Constant Field Values

INSIDE_END

public static final int INSIDE_END
Tested block completely inside THIS block and its start position is greater than THIS block start position and end positions are the same. The value includes INSIDE.

See Also:
Constant Field Values

INNER

public static final int INNER
Tested block is fully inside THIS block and there is at least one more character left in THIS block after the end of the tested block in both directions. The value includes INSIDE.

See Also:
Constant Field Values

SAME

public static final int SAME
The blocks have exactly the same start and end positions. They simply cover exactly the same area. The value is INSIDE_BEGIN | INSIDE_END.

See Also:
Constant Field Values

IGNORE_EMPTY

public static final int IGNORE_EMPTY
This value can be used to clear the two bits saying if the tested or THIS block are empty (The EMPTY and THIS_EMPTY are cleared). To do that, use value ANDed by IGNORE_EMPTY expression.

See Also:
Constant Field Values

next

protected MarkBlock next
Next block in the chain


prev

protected MarkBlock prev
Previous block in the chain


startMark

public Mark startMark

endMark

public Mark endMark

doc

protected BaseDocument doc
Constructor Detail

MarkBlock

public MarkBlock(BaseDocument doc,
                 Mark startMark,
                 Mark endMark)

MarkBlock

public MarkBlock(BaseDocument doc,
                 int startPos,
                 int endPos)
          throws BadLocationException
Construct block with given marks

Throws:
BadLocationException

MarkBlock

public MarkBlock(BaseDocument doc,
                 Mark startMark,
                 Mark endMark,
                 int startPos,
                 int endPos)
          throws BadLocationException
Construct block from positions on some document

Throws:
BadLocationException
Method Detail

insertChain

public MarkBlock insertChain(MarkBlock blk)
Insert block before this one

Returns:
inserted block

addChain

public MarkBlock addChain(MarkBlock blk)
Add block after this one

Returns:
added block

removeChain

public MarkBlock removeChain()
Remove this block from the chain

Returns:
next chain member or null for end of chain

compare

public int compare(int startPos,
                   int endPos)
Compares the position of the given block against current block.

Parameters:
startPos - starting position of the compared block
endPos - ending position of the compared block or it is the same as startPos when testing just for insert
Returns:
relation of compared block against this guarded block

getNext

public final MarkBlock getNext()

setNext

public final void setNext(MarkBlock b)

setNextChain

public void setNextChain(MarkBlock b)
Set the next block of this one in the chain.


getPrev

public final MarkBlock getPrev()

setPrev

public final void setPrev(MarkBlock b)

setPrevChain

public void setPrevChain(MarkBlock b)
Set the previous block of this one in the chain


isReverse

public boolean isReverse()

reverse

public void reverse()

checkReverse

public boolean checkReverse()

extendStart

public int extendStart(int startPos)
                throws BadLocationException
Possibly move start mark if its position is above the given number.

Returns:
new position
Throws:
BadLocationException

extendEnd

public int extendEnd(int endPos)
              throws BadLocationException
Possibly move end mark if its position is above the given number.

Returns:
new position
Throws:
BadLocationException

extend

public boolean extend(int startPos,
                      int endPos,
                      boolean concat)
               throws BadLocationException
Extend this mark block by start and end positions. First test whether the given block intersects with this mark block. If not nothing is done.

Returns:
whether this mark block has been extended
Throws:
BadLocationException

extend

public boolean extend(MarkBlock blk,
                      boolean concat)
Extend this mark block by some other block.

Returns:
whether the block was extended. If it was, the caller is responsible for possibly removing blk from the chain

shrink

public int shrink(int startPos,
                  int endPos)
           throws BadLocationException
Shrink this mark block by the block specified. startMark is moved to the endPos if OVERLAP_BEGIN or INSIDE_BEGIN is returned from compare(). endMark is moved to the startPos if OVERLAP_END or INSIDE_END is returned from compare(). If other status is returned or either block is empty, then no action is taken. It's up to caller to handle these situations.

Returns:
relation of tested block to mark block
Throws:
BadLocationException

getDocument

public Document getDocument()

getStartOffset

public int getStartOffset()

getEndOffset

public int getEndOffset()

finalize

protected void finalize()
                 throws Throwable
Destroy the marks if necessary

Overrides:
finalize in class Object
Throws:
Throwable

toString

public String toString()
Debugs this mark block

Overrides:
toString in class Object

toStringChain

public String toStringChain()
Debug possibly whole chain of marks


debugRelation

public static String debugRelation(int rel)

org.netbeans.modules.editor.lib/1 1.14.0 3

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.