|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.4.0) E13403-05 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.javatools.editor.language.DefaultWordLocator
public final class DefaultWordLocator
A simple WordLocator
implementation suitable for most artificial
languages. The implementation is particularly targetted to Java, but in
practice works for a wide variety of languages, including XML. Characters
fit into either identifier, punctuation, or space categories. In general,
a word is a run of identifier characters followed by a punctuation or space
character, or a run of punctuation characters followed by an identifier or
space character. Space characters are never part of a word.
Subclasses can redefine what characters are identifier characters by
overriding isIdentifierCharacter(int, boolean)
and what characters are space
characters by overriding isSpaceCharacter(int)
; punctuation characters
are everything else. Subclasses can redefine how word boundaries are
recognized by overriding isWordStart(int,boolean,boolean,boolean,boolean)
and/or isWordEnd(int,boolean,boolean,boolean,boolean)
.
WordLocator
,
LanguageSupport.getWordLocator()
Constructor Summary | |
---|---|
DefaultWordLocator(LanguageSupport support)
Constructs a new DefaultWordLocator. |
Method Summary | |
---|---|
int |
getNextWordEnd(int offset)
Gets the offset of the word end after an offset. |
int |
getNextWordStart(int offset)
Gets the offset of the word start after an offset. |
int |
getPreviousWordEnd(int offset)
Gets the offset of the word end before an offset. |
int |
getPreviousWordStart(int offset)
Gets the offset of the word start before an offset. |
protected ReadTextBuffer |
getTextBuffer()
Gets the text buffer to which this locator is bound. |
int |
getWordEnd(int offset)
Gets the offset of the word end at or after an offset. |
int |
getWordStart(int offset)
Gets the offset of the word start at or before an offset. |
protected boolean |
isIdentifierCharacter(int c,
boolean caseChange)
Gets whether a character is an identifier character. |
protected boolean |
isSpaceCharacter(int c)
Gets whether a character is a space character. |
protected boolean |
isWordEnd(int offset,
boolean caseChange,
boolean spaceChange,
boolean lineStart,
boolean lineEnd)
Gets whether an offset is at the end of a word. |
protected boolean |
isWordStart(int offset,
boolean caseChange,
boolean spaceChange,
boolean lineStart,
boolean lineEnd)
Gets whether an offset is the start of a word. |
protected static boolean |
useCaseChangeForWordBoundary()
Gets whether change of case should be considered a word boundary. |
protected static boolean |
useLineEndForWordBoundary()
Gets whether line end should be considered a word boundary. |
protected static boolean |
useLineStartForWordBoundary()
Gets whether line start should be considered a word boundary. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultWordLocator(LanguageSupport support)
support
- the language support and document this locator is used forMethod Detail |
---|
public int getWordStart(int offset)
getWordStart
in interface WordLocator
offset
- the specified document offset
public int getPreviousWordStart(int offset)
getPreviousWordStart
in interface WordLocator
offset
- the specified document offset
public int getNextWordStart(int offset)
getNextWordStart
in interface WordLocator
offset
- the specified document offset
public int getWordEnd(int offset)
getWordEnd
in interface WordLocator
offset
- the specified document offset
public int getPreviousWordEnd(int offset)
getPreviousWordEnd
in interface WordLocator
offset
- the specified document offset
public int getNextWordEnd(int offset)
getNextWordEnd
in interface WordLocator
offset
- the specified document offset
protected final ReadTextBuffer getTextBuffer()
protected boolean isSpaceCharacter(int c)
DefaultWordLocator
implementation uses Character.isWhitespace(char)
.
protected boolean isIdentifierCharacter(int c, boolean caseChange)
DefaultWordLocator
implementation uses Character.isJavaIdentifierPart(char)
except that an underscore is
not considered an identifier if caseChange
is true.
caseChange
- recognize a word start at change of case.protected boolean isWordStart(int offset, boolean caseChange, boolean spaceChange, boolean lineStart, boolean lineEnd)
DefaultWordLocator
never invokes this method with those
offsets).
offset
- the offset of the character to test.caseChange
- recognize a word start at change of case.spaceChange
- recognize a word start at start of run of spaces.lineStart
- recognize a word start at line start.lineEnd
- recognize a word start at line end.protected boolean isWordEnd(int offset, boolean caseChange, boolean spaceChange, boolean lineStart, boolean lineEnd)
DefaultWordLocator
never invokes this method with those
offsets).
offset
- the offset of the character to test.caseChange
- recognize a word end at change of case.spaceChange
- recognize a word end at end of run of spaces.lineStart
- recognize a word end at line start.lineEnd
- recognize a word end at line end.protected static boolean useCaseChangeForWordBoundary()
protected static boolean useLineStartForWordBoundary()
protected static boolean useLineEndForWordBoundary()
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.4.0) E13403-05 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |