Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

oracle.javatools.editor
Class Utilities

java.lang.Object
  extended by oracle.javatools.editor.Utilities

public final class Utilities
extends java.lang.Object

The Utilities just defines convenient utility routines.


Constructor Summary
Utilities()
           
 
Method Summary
static int clearBit(int value, int flag)
          Returns the value with the indicated bit flag off.
static int getColumnFromOffset(TextBuffer textBuffer, int offset, int tabSize)
          Fetches the column (0-based) of the given offset in the buffer based on a certain tab size.
static int getColumnFromOffset(TextBuffer textBuffer, int line, int offset, int tabSize)
          Fetches the column (0-based) of the given offset in the buffer based on a certain tab size.
static int getNextTabStop(int tabSize, int startColumn)
          Fetches the next tab stop (column) based on the given tab size and start column.
static int getNextWordEnd(BasicDocument document, int offset)
          Determines the next occurrence of the end of a word for the given location.
static int getNextWordStart(BasicDocument document, int offset)
          Determines the next occurrence of the start of a word for the given location.
static int getOffsetFromColumn(TextBuffer textBuffer, int line, int column, int tabSize)
          Fetches the offset corresponding to a given line and column (both 0-based) and given tab size.
static int getPreviousWordEnd(BasicDocument document, int offset)
          Determines the previous occurrence of the end of a word for the given location.
static int getPreviousWordStart(BasicDocument document, int offset)
          Determines the previous occurrence of the start of a word for the given location.
static int getRowEnd(BasicDocument document, int offset)
          Determines the ending row model position of the row that contains the specified model position.
static int getRowStart(BasicDocument document, int offset)
          Determines the starting row model position of the row that contains the specified model position.
static int getTextWidth(TextBuffer textBuffer, int startOffset, int endOffset, int tabSize, int startColumn)
          Fetches the width of the given range of text in the text buffer in columns (not pixels.) This will take into account any tabs in the text and what the specified tab size is.
static int getWordEnd(BasicDocument document, int offset)
          Determines the end of a word for the given location.
static int getWordStart(BasicDocument document, int offset)
          Determines the start of a word for the given model location.
static int setBit(int value, int flag)
          Returns the value with the indicated bit flag on.
static boolean testBit(int value, int flag)
          Determines whether the given bit flag (i.e., 0x0001000) is set in the value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utilities

public Utilities()
Method Detail

getTextWidth

public static int getTextWidth(TextBuffer textBuffer,
                               int startOffset,
                               int endOffset,
                               int tabSize,
                               int startColumn)
Fetches the width of the given range of text in the text buffer in columns (not pixels.) This will take into account any tabs in the text and what the specified tab size is. Note that the column provided (startColumn) and the column returned are both 0-based.

Parameters:
textBuffer - the text buffer the data is in
startOffset - the start of the range of text (inclusive)
endOffset - the end of the range of text (exclusive)
tabSize - the tab size or tab stop (i.e., tab size 4)
startColumn - the current column that startOffset corresponds to
Returns:
the column width of the given text

getNextTabStop

public static int getNextTabStop(int tabSize,
                                 int startColumn)
Fetches the next tab stop (column) based on the given tab size and start column. If the startColumn is already at a tab stop, the next tab stop is returned.

Parameters:
tabSize - the current tab size
startColumn - the starting column

getColumnFromOffset

public static int getColumnFromOffset(TextBuffer textBuffer,
                                      int offset,
                                      int tabSize)
Fetches the column (0-based) of the given offset in the buffer based on a certain tab size.

Parameters:
textBuffer - the text buffer of the data
offset - the offset to map
tabSize - the current tab size
Returns:
the column (0-based) that the given character offset occurs at

getColumnFromOffset

public static int getColumnFromOffset(TextBuffer textBuffer,
                                      int line,
                                      int offset,
                                      int tabSize)
Fetches the column (0-based) of the given offset in the buffer based on a certain tab size.

Parameters:
textBuffer - the text buffer of the data
line - the line the data is contained on
offset - the offset to map
tabSize - the current tab size
Returns:
the column (0-based) that the given character offset occurs at

getOffsetFromColumn

public static int getOffsetFromColumn(TextBuffer textBuffer,
                                      int line,
                                      int column,
                                      int tabSize)
Fetches the offset corresponding to a given line and column (both 0-based) and given tab size. If the given column occurs after we reach the end of the line, the last offset (before the new line) is returned.

Parameters:
textBuffer - the text buffer of the data
line - the line the text is on (which we are trying to map)
column - the column we are trying to map
tabSize - the current tab size

getRowStart

public static int getRowStart(BasicDocument document,
                              int offset)
Determines the starting row model position of the row that contains the specified model position. Assumes the row(s) are currently displayed in a view.

Parameters:
document - the document
offset - the offset in the document >= 0
Returns:
the position >= 0

getRowEnd

public static int getRowEnd(BasicDocument document,
                            int offset)
Determines the ending row model position of the row that contains the specified model position. Assumes the row(s) are currently displayed in a view.

Parameters:
document - the document
offset - the offset in the document >= 0
Returns:
the position >= 0

getWordStart

public static int getWordStart(BasicDocument document,
                               int offset)
Determines the start of a word for the given model location.

Parameters:
document - the document
offset - offset in the document >= 0
Returns:
the location in the model of the word start >= 0.

getWordEnd

public static int getWordEnd(BasicDocument document,
                             int offset)
Determines the end of a word for the given location.

Parameters:
document - the document
offset - offset in the document >= 0
Returns:
the location in the model of the word end >= 0.

getNextWordStart

public static int getNextWordStart(BasicDocument document,
                                   int offset)
Determines the next occurrence of the start of a word for the given location.

Parameters:
document - the document
offset - offset in the document >= 0
Returns:
the location in the model of the next word start >= 0.

getNextWordEnd

public static int getNextWordEnd(BasicDocument document,
                                 int offset)
Determines the next occurrence of the end of a word for the given location.

Parameters:
document - the document
offset - offset in the document >= 0
Returns:
the location in the model of the next word end >= 0.

getPreviousWordStart

public static int getPreviousWordStart(BasicDocument document,
                                       int offset)
Determines the previous occurrence of the start of a word for the given location.

Parameters:
document - the document
offset - offset in the document >= 0
Returns:
the location in the model of the previous word start >= 0.

getPreviousWordEnd

public static int getPreviousWordEnd(BasicDocument document,
                                     int offset)
Determines the previous occurrence of the end of a word for the given location.

Parameters:
document - the document
offset - offset in the document >= 0
Returns:
the location in the model of the previous word end >= 0.

testBit

public static boolean testBit(int value,
                              int flag)
Determines whether the given bit flag (i.e., 0x0001000) is set in the value.

Parameters:
value - value to test
flag - the bit flag to test for
Returns:
true if bit flag is set

setBit

public static int setBit(int value,
                         int flag)
Returns the value with the indicated bit flag on.

Parameters:
value - value to set the bit in
flag - the bit flag to turn on
Returns:
modified value with the bit on

clearBit

public static int clearBit(int value,
                           int flag)
Returns the value with the indicated bit flag off.

Parameters:
value - value to clear the bit in
flag - the bit flag to clear
Returns:
modified value with the bit off

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

Copyright © 1997, 2013, Oracle. All rights reserved.