APIdia Launch Partner
Top Fields Constructors Methods
jdk.jfr.internal.util

public final Class Tokenizer

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Imports
java.text.ParseException

Field Summary

Modifier and TypeField and Description
private int
private final char[]
private final String

Constructor Summary

AccessConstructor and Description
public
Tokenizer(String
text to tokenize
text
,
char...
separator, for example ',' or ';'
separators
)

Constructs a Tokenizer.

Method Summary

Modifier and TypeMethod and Description
public boolean
accept(String match)

If the next token matches a string, it is consumed and true returned, false otherwise.

public boolean
accept(String... matches)

Similar to accept(String), but requires several tokens to match.

public boolean
acceptAny(String... matches)

Similar to accept(String...), but sufficient if one token matches.

public void
close()

Implements java.lang.AutoCloseable.close.

Closes the Tokenizer.

public void
expect(String expected)

Throws exception if the next token doesn't match.

private int
findNext(char c)

public int
getPosition()

Returns the current position in the text.

public boolean
hasNext()

Return true if there are more tokens.

private boolean
private boolean
isSeparator(char c)

public String
next()

Return the next token, or throw exception if EOF is reached.

public char
peekChar()

Return the next character without consuming it, or throw exception if EOF is reached.

public void
skipLine()

Skips all character until '\n'

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

indexback to summary
private int index
separatorsback to summary
private final char[] separators
textback to summary
private final String text

Constructor Detail

Tokenizerback to summary
public Tokenizer(String text, char... separators)

Constructs a Tokenizer.

Parameters
text:String

text to tokenize

separators:char[]

separator, for example ',' or ';'

Method Detail

acceptback to summary
public boolean accept(String match)

If the next token matches a string, it is consumed and true returned, false otherwise.

acceptback to summary
public boolean accept(String... matches)

Similar to accept(String), but requires several tokens to match.

acceptAnyback to summary
public boolean acceptAny(String... matches)

Similar to accept(String...), but sufficient if one token matches.

closeback to summary
public void close() throws ParseException

Implements java.lang.AutoCloseable.close.

Closes the Tokenizer.

Requires that all the tokens have been consumed.

Annotations
@Override
Exceptions
ParseException:
if there are tokens left
expectback to summary
public void expect(String expected) throws ParseException

Throws exception if the next token doesn't match.

findNextback to summary
private int findNext(char c) throws ParseException
getPositionback to summary
public int getPosition()

Returns the current position in the text.

hasNextback to summary
public boolean hasNext()

Return true if there are more tokens.

isQuoteCharacterback to summary
private boolean isQuoteCharacter(char c)
isSeparatorback to summary
private boolean isSeparator(char c)
nextback to summary
public String next() throws ParseException

Return the next token, or throw exception if EOF is reached.

peekCharback to summary
public char peekChar() throws ParseException

Return the next character without consuming it, or throw exception if EOF is reached.

skipLineback to summary
public void skipLine()

Skips all character until '\n'

skipWhitespaceback to summary
private void skipWhitespace()