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

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

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

org.netbeans.editor
Class Analyzer

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

public class Analyzer
extends Object

Various text analyzes over the document


Field Summary
static char[] EMPTY_CHAR_ARRAY
          Empty char array
 
Method Summary
static boolean blocksHit(int[] blocks, int startPos, int endPos)
           
static int blocksIndex(int[] blocks, int startPos, int endPos)
           
static char[] concat(char[] chars1, char[] chars2)
           
static int convertLFToLS(char[] src, int len, char[] tgt, String lsType)
          Convert text with LF line separators to text that uses line separators of the document.
static int convertLSToLF(char[] chars, int len)
          Convert text with generic line separators to line feeds (LF).
static String convertLSToLF(String text)
          Convert string with generic line separators to line feeds (LF).
static char[] createSpacesBuffer(int numSpaces)
          Get buffer of the requested size filled entirely with space character.
static char[] createWhitespaceFillBuffer(int startCol, int endCol, int tabSize)
          Get buffer filled with spaces/tabs so that it reaches from some column to some other column.
static char[] createWhiteSpaceFillBuffer(int startCol, int endCol, int tabSize)
          Deprecated.  
static boolean endsWith(char[] chars, char[] suffix)
           
static boolean equals(String s, char[] chars)
           
static boolean equals(String s, char[] chars, int offset, int len)
           
static char[] extract(char[] chars, int offset, int len)
           
static int findFirstLFOffset(char[] chars, int offset, int len)
           
static int findFirstLFOffset(String s)
           
static int findFirstNonSpace(char[] chars, int offset, int len)
          Return the first index that is not space
static int findFirstNonTab(char[] chars, int offset, int len)
          Return the first index that is not space
static int findFirstNonWhite(char[] chars, int offset, int len)
          Return the first index that is not space or tab or new-line char
static int findFirstTab(char[] chars, int offset, int len)
           
static int findFirstTabOrLF(char[] chars, int offset, int len)
           
static int findLastNonWhite(char[] chars, int offset, int len)
          Return the last index that is not space or tab or new-line char
static int getColumn(char[] buffer, int offset, int len, int tabSize, int startCol)
          Get visual column.
static String getIndentString(int indent, boolean expandTabs, int tabSize)
          Get the string that should be used for indentation of the given level.
static int getLFCount(char[] chars)
          Count the number of line feeds in char array.
static int getLFCount(char[] chars, int offset, int len)
           
static int getLFCount(String s)
           
static Object getPlatformLS()
          Get platform default line separator
static char[] getSpacesBuffer(int numSpaces)
          Get buffer filled with appropriate number of spaces.
static String getSpacesString(int numSpaces)
          Get string filled with space characters.
static char[] getTabsBuffer(int numTabs)
          Get buffer filled with appropriate number of tabs.
static String getWhitespaceString(int startCol, int endCol, boolean expandTabs, int tabSize)
          Get the string that should be used for indentation of the given level.
static void initialRead(BaseDocument doc, Reader reader, boolean testLS)
          Do initial reading of document.
static boolean isSpace(char[] chars, int offset, int len)
          Return true if the array contains only space chars
static boolean isSpace(String s)
           
static boolean isWhitespace(char[] chars, int offset, int len)
          Return true if the array contains only space or tab chars
static char[] loadFile(String fileName)
          Loads the file and performs conversion of line separators to LF.
static String removeSpaces(String s)
          Remove all spaces from the given string.
static void reverse(char[] chars, int len)
          Reverses the order of characters in the array.
static boolean startsWith(char[] chars, char[] prefix)
           
static String testLS(char[] chars, int len)
          Test line separator on given semgment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_CHAR_ARRAY

public static final char[] EMPTY_CHAR_ARRAY
Empty char array

Method Detail

getPlatformLS

public static Object getPlatformLS()
Get platform default line separator


testLS

public static String testLS(char[] chars,
                            int len)
Test line separator on given semgment. This implementation simply checks the first line of file but it can be redefined to do more thorough test.

Parameters:
seg - segment where analyzes are performed
Returns:
line separator type found in the file

convertLSToLF

public static int convertLSToLF(char[] chars,
                                int len)
Convert text with generic line separators to line feeds (LF). As the linefeeds are one char long there is no need to allocate another buffer since the only possibility is that the returned length will be smaller than previous (if there were some CRLF separators.

Parameters:
chars - char array with data to convert
len - valid portion of chars array
Returns:
new valid portion of chars array after conversion

convertLSToLF

public static String convertLSToLF(String text)
Convert string with generic line separators to line feeds (LF).

Parameters:
text - string to convert
Returns:
new string with converted LSs to LFs

isSpace

public static boolean isSpace(String s)

isSpace

public static boolean isSpace(char[] chars,
                              int offset,
                              int len)
Return true if the array contains only space chars


isWhitespace

public static boolean isWhitespace(char[] chars,
                                   int offset,
                                   int len)
Return true if the array contains only space or tab chars


findFirstNonTab

public static int findFirstNonTab(char[] chars,
                                  int offset,
                                  int len)
Return the first index that is not space


findFirstNonSpace

public static int findFirstNonSpace(char[] chars,
                                    int offset,
                                    int len)
Return the first index that is not space


findFirstNonWhite

public static int findFirstNonWhite(char[] chars,
                                    int offset,
                                    int len)
Return the first index that is not space or tab or new-line char


findLastNonWhite

public static int findLastNonWhite(char[] chars,
                                   int offset,
                                   int len)
Return the last index that is not space or tab or new-line char


getLFCount

public static int getLFCount(char[] chars)
Count the number of line feeds in char array.

Returns:
number of LF characters contained in array.

getLFCount

public static int getLFCount(char[] chars,
                             int offset,
                             int len)

getLFCount

public static int getLFCount(String s)

findFirstLFOffset

public static int findFirstLFOffset(char[] chars,
                                    int offset,
                                    int len)

findFirstLFOffset

public static int findFirstLFOffset(String s)

findFirstTab

public static int findFirstTab(char[] chars,
                               int offset,
                               int len)

findFirstTabOrLF

public static int findFirstTabOrLF(char[] chars,
                                   int offset,
                                   int len)

reverse

public static void reverse(char[] chars,
                           int len)
Reverses the order of characters in the array. It works from the begining of the array, so no offset is given.


equals

public static boolean equals(String s,
                             char[] chars)

equals

public static boolean equals(String s,
                             char[] chars,
                             int offset,
                             int len)

initialRead

public static void initialRead(BaseDocument doc,
                               Reader reader,
                               boolean testLS)
                        throws IOException
Do initial reading of document. Translate any line separators found in document to line separators used by document. It also cares for elements that were already created on the empty document. Although the document must be empty there can be already marks created. Initial read is equivalent to inserting the string array of the whole document size at position 0 in the document. Therefore all the marks that are not insertAfter are removed and reinserted to the end of the document after the whole initial read is finished.

Parameters:
doc - document for which the initialization is performed
reader - reader from which document should be read
lsType - line separator type
testLS - test line separator of file and if it's consistent, use it
markDistance - the distance between the new syntax mark is put
Throws:
IOException

getColumn

public static int getColumn(char[] buffer,
                            int offset,
                            int len,
                            int tabSize,
                            int startCol)
Get visual column.


getSpacesBuffer

public static char[] getSpacesBuffer(int numSpaces)
Get buffer filled with appropriate number of spaces. The buffer can have actually more spaces than requested.

Parameters:
numSpaces - number of spaces

getSpacesString

public static String getSpacesString(int numSpaces)
Get string filled with space characters. There is optimization to return the same string instance for up to ceratin number of spaces.

Parameters:
numSpaces - number of spaces determining the resulting size of the string.

createSpacesBuffer

public static char[] createSpacesBuffer(int numSpaces)
Get buffer of the requested size filled entirely with space character.

Parameters:
numSpaces - number of spaces in the returned character buffer.

getTabsBuffer

public static char[] getTabsBuffer(int numTabs)
Get buffer filled with appropriate number of tabs. The buffer can have actually more tabs than requested.

Parameters:
numSpaces - number of spaces

getIndentString

public static String getIndentString(int indent,
                                     boolean expandTabs,
                                     int tabSize)
Get the string that should be used for indentation of the given level.

Parameters:
indent - indentation level
expandTabs - whether tabs should be expanded to spaces or not
tabSize - size substituted visually for the '\t' character

getWhitespaceString

public static String getWhitespaceString(int startCol,
                                         int endCol,
                                         boolean expandTabs,
                                         int tabSize)
Get the string that should be used for indentation of the given level.

Parameters:
indent - indentation level
expandTabs - whether tabs should be expanded to spaces or not
tabSize - size of the '\t' character

createWhiteSpaceFillBuffer

public static char[] createWhiteSpaceFillBuffer(int startCol,
                                                int endCol,
                                                int tabSize)
Deprecated. 

createWhitespaceFillBuffer() with the non-capital 's' should be used.


createWhitespaceFillBuffer

public static char[] createWhitespaceFillBuffer(int startCol,
                                                int endCol,
                                                int tabSize)
Get buffer filled with spaces/tabs so that it reaches from some column to some other column.

Parameters:
startCol - starting visual column of the whitespace on the line
endCol - ending visual column of the whitespace on the line
tabSize - size substituted visually for the '\t' character

loadFile

public static char[] loadFile(String fileName)
                       throws IOException
Loads the file and performs conversion of line separators to LF. This method can be used in debuging of syntax scanner or somewhere else.

Parameters:
fileName - the name of the file to load
Returns:
array of loaded characters with '\n' as line separator
Throws:
IOException

convertLFToLS

public static int convertLFToLS(char[] src,
                                int len,
                                char[] tgt,
                                String lsType)
Convert text with LF line separators to text that uses line separators of the document. This function is used when saving text into the file. Segment's data are converted inside the segment's data or new segment's data array is allocated. NOTE: Source segment must have just LFs as separators! Otherwise the conversion won't work correctly.

Parameters:
src - source chars to convert from
len - length of valid part of src data
tgt - target chars to convert to. The array MUST have twice the size of src otherwise index exception can be thrown
lsType - line separator type to be used i.e. LS_LF, LS_CR, LS_CRLF
Returns:
length of valid chars in tgt array

startsWith

public static boolean startsWith(char[] chars,
                                 char[] prefix)

endsWith

public static boolean endsWith(char[] chars,
                               char[] suffix)

concat

public static char[] concat(char[] chars1,
                            char[] chars2)

extract

public static char[] extract(char[] chars,
                             int offset,
                             int len)

blocksHit

public static boolean blocksHit(int[] blocks,
                                int startPos,
                                int endPos)

blocksIndex

public static int blocksIndex(int[] blocks,
                              int startPos,
                              int endPos)

removeSpaces

public static String removeSpaces(String s)
Remove all spaces from the given string.

Parameters:
s - original string
Returns:
string with all spaces removed

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.