001 002package gudusoft.gsqlparser.dlineage.dataflow.model; 003 004import gudusoft.gsqlparser.TSourceToken; 005import gudusoft.gsqlparser.dlineage.util.Pair3; 006import gudusoft.gsqlparser.util.SQLUtil; 007import gudusoft.gsqlparser.nodes.TParseTreeNode; 008 009public class Constant 010{ 011 012 protected long id; 013 014 protected String fullName; 015 protected String name; 016 017 protected Pair3<Long, Long, String> startPosition; 018 protected Pair3<Long, Long, String> endPosition; 019 020 protected TParseTreeNode constant; 021 022 public Constant( TParseTreeNode constant ) 023 { 024 if ( constant == null ) 025 throw new IllegalArgumentException( "Constant arguments can't be null." ); 026 027 id = ++ModelBindingManager.get( ).TABLE_COLUMN_ID; 028 029 this.constant = constant; 030 031 TSourceToken startToken = constant.getStartToken( ); 032 TSourceToken endToken = constant.getEndToken( ); 033 034 this.name = constant.toString( ); 035 036 this.name = SQLUtil.trimColumnStringQuote(name); 037 038 this.fullName = constant.toString( ); 039 040 this.startPosition = new Pair3<Long, Long, String>( startToken.lineNo, 041 startToken.columnNo, ModelBindingManager.getGlobalHash()); 042 this.endPosition = new Pair3<Long, Long, String>( endToken.lineNo, 043 endToken.columnNo + endToken.astext.length( ), ModelBindingManager.getGlobalHash()); 044 } 045 046 public long getId( ) 047 { 048 return id; 049 } 050 051 public String getFullName( ) 052 { 053 return fullName; 054 } 055 056 public Pair3<Long, Long, String> getStartPosition( ) 057 { 058 return startPosition; 059 } 060 061 public Pair3<Long, Long, String> getEndPosition( ) 062 { 063 return endPosition; 064 } 065 066 public TParseTreeNode getConstantObject( ) 067 { 068 return constant; 069 } 070 071 public String getName( ) 072 { 073 return name; 074 } 075 076}