| Constructor and Description |
|---|
CharIterator(String value) |
| Modifier and Type | Method and Description |
|---|---|
String |
context()
Returns context of cursor (text around the cursor)
|
String |
context(int index)
Returns context around passed index
|
boolean |
hasNext() |
char |
lastChar()
Returns last character that would be iterated over
|
void |
modifyBound(int offset)
Move the bound until which iterator will iterate
|
Character |
next()
Returns next character and advances the cursor
|
String |
next(int length)
Return next
length characters as a substring and advance cursor |
String |
nextUntil(char c)
Returns substring from 'next' character UP TO first not escaped character
c
Cursor is advanced to a position after character c |
String |
nextUntil(String s)
Returns substring from next character up to next occurrence of
s
Cursor is advanced to a position after last character in s |
char |
peek()
Return next character, without advancing cursor
|
char |
peek(int offset)
Return character by offset from the next, without advancing cursor
|
int |
prevPos()
Return position of last symbol returned by next()
|
int |
remaining()
Calculate number of characters remaining to iterate over
|
void |
skip()
Skip next character
|
void |
skip(int n)
Skip next
n characters |
String |
substringToCurrPos(int pos) |
String |
takeWhile(Predicate<Character> condition)
Create substring starting from next character while
condition is true
Cursor is advanced to the first character which does not match condition |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemaining, removepublic CharIterator(String value)
public void skip(int n)
n charactersn - number of characters to skippublic void skip()
public char peek()
public char peek(int offset)
offset - offset value.public Character next()
public String next(int length)
length characters as a substring and advance cursorlength - number of characters to returnlength characterspublic String context()
public String context(int index)
index - center point of contextpublic int remaining()
public String nextUntil(char c)
c
Cursor is advanced to a position after character c
Example:
For text '0123456789', nextUntil('8') will return '01234567' and put cursor before '9'
c - character to search forcNoSuchElementException - if no such character present after next characterpublic String nextUntil(String s)
s
Cursor is advanced to a position after last character in s
Example:
For text '0123456789', nextUntil("456") will return '0123' and put cursor before '7'
s - string to search forpublic String takeWhile(Predicate<Character> condition)
condition is true
Cursor is advanced to the first character which does not match conditioncondition - condition to test each character withpublic char lastChar()
public void modifyBound(int offset)
offset - offset in respect to current boundpublic int prevPos()
public String substringToCurrPos(int pos)
Copyright © 2022. All rights reserved.