public interface Snippet extends Iterable<TokenInfo>, Snippetable
| Modifier and Type | Field and Description |
|---|---|
static int |
NOT_FOUND
Constant for not found result
|
| Modifier and Type | Method and Description |
|---|---|
void |
addToken(TokenInfo tokenInfo)
Add token to the snippet
|
void |
addTokens(Snippet snippet)
Add tokens to the current snippet
|
default String |
asSource()
Get snippet as source.
|
default boolean |
contains(Token... tokens)
Check if snippet contains at least one of the given token
|
default TokenInfo |
get(int index)
Get token at the given position
|
default TokenInfo |
getFirst()
Get the first token
|
default TokenInfo |
getLast()
Get the last token
|
default @Nullable TokenInfo |
getLast(int lastIndex)
Get token at the given index counting backwards of snippet
|
default Snippet |
getLine(int line)
Get tokens at the given line as a snippet
|
default Location |
getLocation()
Get
Location of first token in snippet |
List<? extends TokenInfo> |
getTokensRepresentations()
Get tokens as list
|
default boolean |
hasElement(int index)
Check if snippet contains token at the given index
|
default int |
indexOf(Token token)
Get index of the given token in snippet
|
default boolean |
isEmpty()
Check if snippet is empty
|
default Iterator<TokenInfo> |
iterator()
Snippet supports iterations
|
default TokenInfo |
remove(int index)
Remove token at the given index
|
default void |
removeToken(TokenInfo tokenInfo)
Remove token from snippet
|
default Snippet |
reversed()
Reverse tokens and get'em as a new snippet
|
default int |
size()
Get size of snippet
|
default Snippet[] |
split(Token delimiter)
Split snippet using the given delimiter.
|
default boolean |
startsWith(Token... tokens)
Check if snippet starts with the given tokens
|
default Snippet |
subSource(int fromIndex,
int toIndex)
Returns a view of the portion of this snippet between the specified fromIndex, inclusive, and toIndex exclusive.
|
TokenInfo[] |
toArray()
Convert snippet into the array of tokens
|
default Snippet |
toSnippet()
Converts current object into the
Snippet |
forEach, spliteratortoStreamstatic final int NOT_FOUND
default Snippet reversed()
default Snippet subSource(int fromIndex, int toIndex)
fromIndex - the start indextoIndex - the end indexdefault Snippet[] split(Token delimiter)
delimiter - the delimiting tokendefault boolean startsWith(Token... tokens)
tokens - the tokens to compare withdefault boolean contains(Token... tokens)
tokens - the tokens to search fordefault int indexOf(Token token)
token - the token to search forNOT_FOUND valuevoid addTokens(Snippet snippet)
snippet - the snippet (collection of tokens) to addvoid addToken(TokenInfo tokenInfo)
tokenInfo - the token to adddefault void removeToken(TokenInfo tokenInfo)
tokenInfo - the token to removedefault TokenInfo remove(int index)
index - the index to usedefault int size()
default boolean isEmpty()
default boolean hasElement(int index)
index - the index to checkdefault TokenInfo get(int index)
index - the index to useSnippetIndexOutOfBoundsException - when index is out of boundsdefault TokenInfo getFirst()
@Nullable default @Nullable TokenInfo getLast(int lastIndex)
lastIndex - the index to usedefault TokenInfo getLast()
default Snippet getLine(int line)
line - the line to search fordefault Location getLocation()
Location of first token in snippetdefault String asSource()
List<? extends TokenInfo> getTokensRepresentations()
TokenInfo[] toArray()
default Snippet toSnippet()
SnippetableSnippettoSnippet in interface SnippetableCopyright © 2020. All rights reserved.