org.basex.util
Class InputParser

java.lang.Object
  extended by org.basex.util.InputParser
Direct Known Subclasses:
CommandParser, JsonParser, QueryParser

public class InputParser
extends java.lang.Object

Abstract class for parsing various inputs, such as database commands or queries.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
 java.lang.String file
          File reference.
 java.lang.String input
          Input to be parsed.
 int length
          Query length.
 int mark
          Marked input position.
 int pos
          Current input position.
 
Constructor Summary
InputParser(java.lang.String in)
          Constructor.
 
Method Summary
 char consume()
          Returns next character.
 boolean consume(int ch)
          Peeks forward and consumes the character if it equals the specified one.
 boolean consume(java.lang.String str)
          Peeks forward and consumes the string if it equals the specified one.
 char curr()
          Returns the current character.
 boolean curr(int ch)
          Checks if the current character equals the specified one.
protected  void file(IO f, Context c)
          Sets a file reference.
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  char next()
          Returns the next character.
protected static boolean quote(int ch)
          Checks if the specified character is a quote.
protected  java.lang.String rest()
          Returns the remaining, unscanned query substring.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

input

public final java.lang.String input
Input to be parsed.


length

public final int length
Query length.


file

public java.lang.String file
File reference.


pos

public int pos
Current input position.


mark

public int mark
Marked input position.

Constructor Detail

InputParser

public InputParser(java.lang.String in)
Constructor.

Parameters:
in - input
Method Detail

file

protected void file(IO f,
                    Context c)
Sets a file reference.

Parameters:
f - file
c - database context

more

public final boolean more()
Checks if more characters are found.

Returns:
current character

curr

public final char curr()
Returns the current character.

Returns:
current character

curr

public final boolean curr(int ch)
Checks if the current character equals the specified one.

Parameters:
ch - character to be checked
Returns:
result of check

mark

protected final void mark()
Remembers the current position.


next

protected final char next()
Returns the next character.

Returns:
result of check

consume

public final char consume()
Returns next character.

Returns:
next character

consume

public final boolean consume(int ch)
Peeks forward and consumes the character if it equals the specified one.

Parameters:
ch - character to consume
Returns:
true if character was found

quote

protected static final boolean quote(int ch)
Checks if the specified character is a quote.

Parameters:
ch - character to be checked
Returns:
result

consume

public final boolean consume(java.lang.String str)
Peeks forward and consumes the string if it equals the specified one.

Parameters:
str - string to consume
Returns:
true if string was found

found

protected final byte[] found()
Returns a "found" string, containing the current character.

Returns:
completion

rest

protected final java.lang.String rest()
Returns the remaining, unscanned query substring.

Returns:
query substring

info

public final InputInfo info()
Creates input information.

Returns:
input information