Package com.helger.commons.string.util
Class StringScanner
- java.lang.Object
-
- com.helger.commons.string.util.StringScanner
-
@NotThreadSafe public class StringScanner extends Object
Simple string scanner.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description StringScanner(String sInput)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intfindFirstIndex(char... aChars)chargetCharAtIndex(int nIndex)chargetCurrentChar()intgetCurrentIndex()intgetRemainingChars()StringgetRest()Get all remaining chars, and set the index to the end of the input stringStringgetUntil(char cEndExcl)Get the string until the specified end character, but excluding the end character.StringgetUntilBalanced(int nStartLevel, char cOpenChar, char cCloseChar)StringgetUntilIndex(int nEndIndex)StringgetUntilWhiteSpace()booleanisCurrentChar(char c)StringScannersetIndex(int nIndex)StringScannerskip(int nCount)StringScannerskipbackWhitespaces()StringScannerskipWhitespaces()StringtoString()
-
-
-
Method Detail
-
getCurrentIndex
@Nonnegative public int getCurrentIndex()
-
getRemainingChars
@Nonnegative public int getRemainingChars()
-
skipWhitespaces
@Nonnull public StringScanner skipWhitespaces()
-
skipbackWhitespaces
@Nonnull public StringScanner skipbackWhitespaces()
-
skip
@Nonnull public StringScanner skip(int nCount)
-
findFirstIndex
public int findFirstIndex(@Nonnull char... aChars)
-
getCharAtIndex
public char getCharAtIndex(int nIndex)
-
getCurrentChar
public char getCurrentChar()
-
isCurrentChar
public boolean isCurrentChar(char c)
-
setIndex
@Nonnull public StringScanner setIndex(@Nonnegative int nIndex)
-
getRest
@Nonnull public String getRest()
Get all remaining chars, and set the index to the end of the input string- Returns:
- The remaining string. May not be
nullbut may be empty.
-
getUntil
@Nonnull public String getUntil(char cEndExcl)
Get the string until the specified end character, but excluding the end character.- Parameters:
cEndExcl- The end character to search.- Returns:
- A non-
nullstring with all characters from the current index until the end character, but not including the end character.
-
getUntilBalanced
@Nonnull public String getUntilBalanced(int nStartLevel, char cOpenChar, char cCloseChar)
-
-