Class ColumnReference

Object
gudusoft.gsqlparser.resolver2.model.ColumnReference

public class ColumnReference extends Object
Column reference record - preserves original AST node information for traceability.

When multiple syntactically different identifiers refer to the same semantic column (e.g., "Column1" and column1 in Oracle), this class allows tracing back from the normalized column name to all original occurrences in the SQL text.

Example: For SQL SELECT "Column1", column1 FROM dual:

  • Both references resolve to the same column COLUMN1
  • Each creates a separate ColumnReference with its original text and position
  • The ColumnSourceWithReferences holds both references
Since:
3.1.0.9
  • Constructor Details

    • ColumnReference

      public ColumnReference(TObjectName objectName)
      Create a column reference from a TObjectName AST node.
      Parameters:
      objectName - the original AST node
    • ColumnReference

      public ColumnReference(TObjectName objectName, String originalText, int startOffset, int endOffset, int lineNumber, int columnNumber)
      Create a column reference with explicit values (for testing or special cases).
      Parameters:
      objectName - the original AST node (may be null)
      originalText - the original text
      startOffset - start offset
      endOffset - end offset
      lineNumber - line number
      columnNumber - column number
  • Method Details

    • getObjectName

      Get the original AST node.
      Returns:
      the TObjectName node, or null if not available
    • getOriginalText

      Get the original text as it appears in SQL.
      Returns:
      original text (e.g., "Column1" with quotes, or column1 without)
    • getStartOffset

      public int getStartOffset()
      Get the start offset in the SQL text.
      Returns:
      start offset (0-based), or -1 if not available
    • getEndOffset

      public int getEndOffset()
      Get the end offset in the SQL text.
      Returns:
      end offset (0-based, exclusive), or -1 if not available
    • getLineNumber

      public int getLineNumber()
      Get the line number.
      Returns:
      line number (1-based), or -1 if not available
    • getColumnNumber

      public int getColumnNumber()
      Get the column number.
      Returns:
      column number (1-based), or -1 if not available
    • hasPositionInfo

      public boolean hasPositionInfo()
      Check if position information is available.
      Returns:
      true if position information is valid
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object