org.eigenbase.sql.parser
Class SqlParserPos

java.lang.Object
  extended by org.eigenbase.sql.parser.SqlParserPos
All Implemented Interfaces:
Serializable

public class SqlParserPos
extends Object
implements Serializable

SqlParserPos represents the position of a parsed token within SQL statement text.

Since:
Jun 1, 2004
Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/parser/SqlParserPos.java#20 $
Author:
Kinkoi Lo
See Also:
Serialized Form

Field Summary
private  int columnNumber
           
private  int endColumnNumber
           
private  int endLineNumber
           
private  int lineNumber
           
private static long serialVersionUID
           
static SqlParserPos ZERO
          SqlParserPos representing line one, character one.
 
Constructor Summary
SqlParserPos(int lineNumber, int columnNumber)
          Creates a new parser position.
SqlParserPos(int startLineNumber, int startColumnNumber, int endLineNumber, int endColumnNumber)
          Creates a new parser range.
 
Method Summary
 boolean equals(Object obj)
           
 int getColumnNum()
           
 int getEndColumnNum()
           
 int getEndLineNum()
           
 int getLineNum()
           
 int hashCode()
           
 SqlParserPos plus(SqlParserPos pos)
          Combines this parser position with another to create a position which spans from the first point in the first to the last point in the other.
 SqlParserPos plusAll(Collection<SqlNode> nodeList)
          Combines this parser position with a list of positions.
 SqlParserPos plusAll(SqlNode[] nodes)
          Combines this parser position with an array of positions to create a position which spans from the first point in the first to the last point in the other.
static SqlParserPos sum(List<SqlNode> nodes)
          Combines the parser positions of a list of nodes to create a position which spans from the beginning of the first to the end of the last.
static SqlParserPos sum(SqlNode[] nodes)
          Combines the parser positions of an array of nodes to create a position which spans from the beginning of the first to the end of the last.
private static SqlParserPos sum(SqlNode[] nodes, int line, int column, int endLine, int endColumn)
          Computes the parser position which is the sum of the positions of an array of parse tree nodes and of a parser position represented by (line, column, endLine, endColumn).
static SqlParserPos sum(SqlParserPos[] poses)
          Combines an array of parser positions to create a position which spans from the beginning of the first to the end of the last.
private static SqlParserPos sum(SqlParserPos[] poses, int line, int column, int endLine, int endColumn)
          Computes the parser position which is the sum of an array of parser positions and of a parser position represented by (line, column, endLine, endColumn).
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final SqlParserPos ZERO
SqlParserPos representing line one, character one. Use this if the node doesn't correspond to a position in piece of SQL text.


serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

lineNumber

private final int lineNumber

columnNumber

private final int columnNumber

endLineNumber

private final int endLineNumber

endColumnNumber

private final int endColumnNumber
Constructor Detail

SqlParserPos

public SqlParserPos(int lineNumber,
                    int columnNumber)
Creates a new parser position.


SqlParserPos

public SqlParserPos(int startLineNumber,
                    int startColumnNumber,
                    int endLineNumber,
                    int endColumnNumber)
Creates a new parser range.

Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getLineNum

public int getLineNum()
Returns:
1-based starting line number

getColumnNum

public int getColumnNum()
Returns:
1-based starting column number

getEndLineNum

public int getEndLineNum()
Returns:
1-based end line number (same as starting line number if the ParserPos is a point, not a range)

getEndColumnNum

public int getEndColumnNum()
Returns:
1-based end column number (same as starting column number if the ParserPos is a point, not a range)

toString

public String toString()
Overrides:
toString in class Object

plus

public SqlParserPos plus(SqlParserPos pos)
Combines this parser position with another to create a position which spans from the first point in the first to the last point in the other.


plusAll

public SqlParserPos plusAll(SqlNode[] nodes)
Combines this parser position with an array of positions to create a position which spans from the first point in the first to the last point in the other.


plusAll

public SqlParserPos plusAll(Collection<SqlNode> nodeList)
Combines this parser position with a list of positions.


sum

public static SqlParserPos sum(SqlNode[] nodes)
Combines the parser positions of an array of nodes to create a position which spans from the beginning of the first to the end of the last.


sum

public static SqlParserPos sum(List<SqlNode> nodes)
Combines the parser positions of a list of nodes to create a position which spans from the beginning of the first to the end of the last.


sum

private static SqlParserPos sum(SqlNode[] nodes,
                                int line,
                                int column,
                                int endLine,
                                int endColumn)
Computes the parser position which is the sum of the positions of an array of parse tree nodes and of a parser position represented by (line, column, endLine, endColumn).

Parameters:
nodes - Array of parse tree nodes
line - Start line
column - Start column
endLine - End line
endColumn - End column
Returns:
Sum of parser positions

sum

public static SqlParserPos sum(SqlParserPos[] poses)
Combines an array of parser positions to create a position which spans from the beginning of the first to the end of the last.


sum

private static SqlParserPos sum(SqlParserPos[] poses,
                                int line,
                                int column,
                                int endLine,
                                int endColumn)
Computes the parser position which is the sum of an array of parser positions and of a parser position represented by (line, column, endLine, endColumn).

Parameters:
poses - Array of parser positions
line - Start line
column - Start column
endLine - End line
endColumn - End column
Returns:
Sum of parser positions