public class Analyzer extends Object
Modifier and Type | Field and Description |
---|---|
static char[] |
EMPTY_CHAR_ARRAY
Empty char array
|
Modifier and Type | Method and Description |
---|---|
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.
|
public static Object getPlatformLS()
public static String testLS(char[] chars, int len)
seg
- segment where analyzes are performedpublic static int convertLSToLF(char[] chars, int len)
chars
- char array with data to convertlen
- valid portion of chars arraypublic static String convertLSToLF(String text)
text
- string to convertpublic static boolean isSpace(String s)
public static boolean isSpace(char[] chars, int offset, int len)
public static boolean isWhitespace(char[] chars, int offset, int len)
public static int findFirstNonTab(char[] chars, int offset, int len)
public static int findFirstNonSpace(char[] chars, int offset, int len)
public static int findFirstNonWhite(char[] chars, int offset, int len)
public static int findLastNonWhite(char[] chars, int offset, int len)
public static int getLFCount(char[] chars)
public static int getLFCount(char[] chars, int offset, int len)
public static int getLFCount(String s)
public static int findFirstLFOffset(char[] chars, int offset, int len)
public static int findFirstLFOffset(String s)
public static int findFirstTab(char[] chars, int offset, int len)
public static int findFirstTabOrLF(char[] chars, int offset, int len)
public static void reverse(char[] chars, int len)
public static boolean equals(String s, char[] chars)
public static boolean equals(String s, char[] chars, int offset, int len)
public static void initialRead(BaseDocument doc, Reader reader, boolean testLS) throws IOException
doc
- document for which the initialization is performedreader
- reader from which document should be readlsType
- line separator typetestLS
- test line separator of file and if it's consistent, use itmarkDistance
- the distance between the new syntax mark is putIOException
public static int getColumn(char[] buffer, int offset, int len, int tabSize, int startCol)
public static char[] getSpacesBuffer(int numSpaces)
numSpaces
- number of spacespublic static String getSpacesString(int numSpaces)
numSpaces
- number of spaces determining the resulting size of the string.public static char[] createSpacesBuffer(int numSpaces)
numSpaces
- number of spaces in the returned character buffer.public static char[] getTabsBuffer(int numTabs)
numSpaces
- number of spacespublic static String getIndentString(int indent, boolean expandTabs, int tabSize)
indent
- indentation levelexpandTabs
- whether tabs should be expanded to spaces or nottabSize
- size substituted visually for the '\t' characterpublic static String getWhitespaceString(int startCol, int endCol, boolean expandTabs, int tabSize)
indent
- indentation levelexpandTabs
- whether tabs should be expanded to spaces or nottabSize
- size of the '\t' characterpublic static char[] createWhiteSpaceFillBuffer(int startCol, int endCol, int tabSize)
public static char[] createWhitespaceFillBuffer(int startCol, int endCol, int tabSize)
startCol
- starting visual column of the whitespace on the lineendCol
- ending visual column of the whitespace on the linetabSize
- size substituted visually for the '\t' characterpublic static char[] loadFile(String fileName) throws IOException
fileName
- the name of the file to loadIOException
public static int convertLFToLS(char[] src, int len, char[] tgt, String lsType)
src
- source chars to convert fromlen
- length of valid part of src datatgt
- target chars to convert to. The array MUST have twice
the size of src otherwise index exception can be thrownlsType
- line separator type to be used i.e. LS_LF, LS_CR, LS_CRLFpublic static boolean startsWith(char[] chars, char[] prefix)
public static boolean endsWith(char[] chars, char[] suffix)
public static char[] concat(char[] chars1, char[] chars2)
public static char[] extract(char[] chars, int offset, int len)
public static boolean blocksHit(int[] blocks, int startPos, int endPos)
public static int blocksIndex(int[] blocks, int startPos, int endPos)
Built on June 4 2024. | Copyright © 2017-2024 Apache Software Foundation. All Rights Reserved.