oracle.javatools.parser.generic
Class BraceHelper
java.lang.Object
|
+--oracle.javatools.parser.generic.BraceHelper
- public final class BraceHelper
- extends java.lang.Object
The BraceHelper
class is a helper class that can
be used by brace matching implementations for language definitions
based on the Language
API.
Field Summary |
static int |
INVALID_BRACE
The index returned for an invalid brace. |
Method Summary |
int |
getBraceIndex(ReadTextBuffer buffer,
int startOffset,
int endOffset)
Fetches the index of the brace at the specified location in the
buffer. |
int |
getBraceLength(int index)
Fetches the length of the brace. |
int |
getBracePairsCount()
Fetches the number of matching brace pairs in this language. |
int |
getMatchingBraceIndex(int index)
Fetches the index of the matching brace for the specified index. |
boolean |
isCloseIndex(int index)
Fetch whether the given index is a valid index for a close brace. |
boolean |
isOpenIndex(int index)
Fetch whether the given index is a valid index for an open brace. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INVALID_BRACE
public static final int INVALID_BRACE
- The index returned for an invalid brace.
BraceHelper
public BraceHelper(Language language)
- Construct a new
BraceHelper
instance.
- Parameters:
language
- the language definition
isOpenIndex
public boolean isOpenIndex(int index)
- Fetch whether the given index is a valid index for an open brace.
- Parameters:
index
- the index to validate- Returns:
- true if the given index is an open index
isCloseIndex
public boolean isCloseIndex(int index)
- Fetch whether the given index is a valid index for a close brace.
- Parameters:
index
- the index to validate- Returns:
- true if the given index is a close index
getBraceLength
public int getBraceLength(int index)
- Fetches the length of the brace. Returns -1 if the brace index
is invalid.
- Parameters:
index
- the brace index- Returns:
- the length of the brace given by the index.
getBracePairsCount
public int getBracePairsCount()
- Fetches the number of matching brace pairs in this language.
- Returns:
- the number of matching brace pairs.
getBraceIndex
public int getBraceIndex(ReadTextBuffer buffer,
int startOffset,
int endOffset)
- Fetches the index of the brace at the specified location in the
buffer.
- Parameters:
buffer
- the buffer where the brace is locatedstartOffset
- the start of the brace (inclusive)endOffset
- the end of the brace (exclusive)- Returns:
- the index of the brace, or -1 if it is not a valid brace
getMatchingBraceIndex
public int getMatchingBraceIndex(int index)
- Fetches the index of the matching brace for the specified index.
If the specified index is invalid (no matching brace), then -1
is returned.
- Parameters:
index
- the index of the brace to get the matching brace index for- Returns:
- the index of the matching brace, or -1 if the index is invalid