org.netbeans.modules.editor.bracesmatching/0 1.22

org.netbeans.spi.editor.bracesmatching
Class MatcherContext

java.lang.Object
  extended by org.netbeans.spi.editor.bracesmatching.MatcherContext

public final class MatcherContext
extends Object

An immutable context for a BracesMatcher. This context is created by the editor infrastructure when it needs to create a matcher by using a registered BracesMatcherFactory. The context provides a matcher with information essential to perform the search.


Method Summary
 Document getDocument()
          Gets a document that should be searched for matching areas.
 int getLimitOffset()
          Gets an offset in a document towards which the search should go.
 int getSearchLookahead()
          Gets the number of characters to search through when looking for an original area.
 int getSearchOffset()
          Gets an offset in a document where searching should start.
 boolean isSearchingBackward()
          Gets the direction to search in for an original area.
static boolean isTaskCanceled()
          Determines if a braces matching task was canceled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDocument

public Document getDocument()
Gets a document that should be searched for matching areas.

Returns:
The document to search in.

getSearchOffset

public int getSearchOffset()
Gets an offset in a document where searching should start. It's usually a position of a caret.

Returns:
The caret's position.

isSearchingBackward

public boolean isSearchingBackward()
Gets the direction to search in for an original area. The search always begins at the caret offset.

Returns:
true to search backward towards the beginning of a document or false to search forward towards the end of a document.

getLimitOffset

public int getLimitOffset()
Gets an offset in a document towards which the search should go. This is basically searchOffset ± searchLookahead depending on the search direction.

Returns:
The offset limiting the search, searchOffset ± searchLookahead.

getSearchLookahead

public int getSearchLookahead()
Gets the number of characters to search through when looking for an original area. When searching for an original area matchers should not look further from the caret offset then the number of characters returned from this method.

Returns:
A small positive number to limit the search for an original area.

isTaskCanceled

public static boolean isTaskCanceled()
Determines if a braces matching task was canceled.

IMPORTANT: This method may only be called from the thread running a braces matching task, ie. the one that calls your BracesMatcher's findOrigin and findMatches methods. Calling this method from a different thread will assert and fail.

Returns:
true if the task was canceled, false otherwise
Since:
1.3

org.netbeans.modules.editor.bracesmatching/0 1.22

Built on May 22 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.