Package org.basex.util
Class InputParser
- java.lang.Object
-
- org.basex.util.InputParser
-
- Direct Known Subclasses:
JsonParser
,QueryParser
public class InputParser extends Object
Abstract class for parsing various inputs, such as database commands or queries.- Author:
- BaseX Team 2005-24, BSD License, Christian Gruen
-
-
Constructor Summary
Constructors Constructor Description InputParser(String input)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
consume()
Consumes the next character.boolean
consume(int cp)
Peeks forward and consumes the character if it equals the specified one.boolean
consume(String string)
Peeks forward and consumes the string if it equals the specified one.int
current()
Returns the current character.boolean
current(int cp)
Checks if the current character equals the specified one.protected String
currentAsString()
Returns the current character as string.protected byte[]
found()
Returns a "found" string, containing the current character.InputInfo
info()
Creates input information.protected void
mark()
Remembers the current position.boolean
more()
Checks if more characters are found.protected int
next()
Returns the next character.protected static boolean
quote(int cp)
Checks if the specified character is a quote.protected String
remaining()
Returns a maximum of 15 remaining characters that have not yet been parsed.TokenBuilder
substring(int s, int e)
Returns an input substring.
-
-
-
Field Detail
-
input
public final int[] input
Codepoints of normalized input string.
-
length
public final int length
Input length.
-
file
public String file
File reference.
-
pos
public int pos
Current input position.
-
mark
public int mark
Marked input position.
-
-
Constructor Detail
-
InputParser
public InputParser(String input)
Constructor.- Parameters:
input
- input
-
-
Method Detail
-
more
public final boolean more()
Checks if more characters are found.- Returns:
- current character
-
current
public final int current()
Returns the current character.- Returns:
- current character
-
current
public final boolean current(int cp)
Checks if the current character equals the specified one.- Parameters:
cp
- character to be checked- Returns:
- result of check
-
mark
protected final void mark()
Remembers the current position.
-
next
protected final int next()
Returns the next character.- Returns:
- next character, or
0
if string is exhausted
-
consume
public final int consume()
Consumes the next character.- Returns:
- next character, or
0
if string is exhausted
-
consume
public final boolean consume(int cp)
Peeks forward and consumes the character if it equals the specified one.- Parameters:
cp
- character to consume- Returns:
- true if character was found
-
quote
protected static boolean quote(int cp)
Checks if the specified character is a quote.- Parameters:
cp
- character to be checked- Returns:
- result
-
consume
public final boolean consume(String string)
Peeks forward and consumes the string if it equals the specified one.- Parameters:
string
- string to consume- Returns:
- true if string was found
-
found
protected final byte[] found()
Returns a "found" string, containing the current character.- Returns:
- completion
-
remaining
protected final String remaining()
Returns a maximum of 15 remaining characters that have not yet been parsed.- Returns:
- query substring
-
substring
public final TokenBuilder substring(int s, int e)
Returns an input substring.- Parameters:
s
- start indexe
- end index- Returns:
- substring
-
currentAsString
protected final String currentAsString()
Returns the current character as string.- Returns:
- current character
-
info
public InputInfo info()
Creates input information.- Returns:
- input info
-
-