001package gudusoft.gsqlparser.nodes; 002 003 004import gudusoft.gsqlparser.ESqlClause; 005import gudusoft.gsqlparser.TCustomSqlStatement; 006 007/** 008 * SQL Server table hint: 009 * <p>Syntax 1: 010 * <pre> 011 * WITH ( <table_hint> [ [, ]...n ] ) 012 * 013 * <table_hint> ::= FORCESCAN 014 * use {@link #getHint()} method get this hint:FORCESCAN 015 * 016 * <table_hint> ::= INDEX = ( index_value ) 017 * {@link #isIndex() } return true, {@link #getHint()} return index_value. 018 * 019 * <table_hint> ::= INDEX ( index_value [ ,...n ] ) 020 * {@link #isIndex() } return true, {@link #getExprList()} return index_value list. 021 * </pre> 022 * 023 */ 024public class TTableHint extends TParseTreeNode { 025 public void setHint(TObjectName hint) { 026 this.hint = hint; 027 } 028 029 private TObjectName hint; 030 private TExpressionList exprList; //TPTNodeList <TExpression> 031 private boolean isIndex; 032 private TConstant hintValue; 033 private TTable ownerTable; 034 035 public void setOwnerTable(TTable ownerTable) { 036 this.ownerTable = ownerTable; 037 } 038 039 public TConstant getHintValue() { 040 return hintValue; 041 } 042 043 public TExpressionList getExprList() { 044 return exprList; 045 } 046 047 public TObjectName getHint() { 048 return hint; 049 } 050 051 public boolean isIndex() { 052 return isIndex; 053 } 054 055 public void setIndex(boolean index) { 056 057 isIndex = index; 058 } 059 060 public void init (Object arg1){ 061 if (arg1 instanceof TObjectName){ 062 hint = (TObjectName)arg1; 063 }else if (arg1 instanceof TExpressionList){ 064 exprList = (TExpressionList)arg1; 065 isIndex = true; 066 }else if (arg1 instanceof TConstant){ 067 hintValue = (TConstant)arg1; 068 } 069 } 070 071 public void doParse(TCustomSqlStatement psql, ESqlClause plocation){ 072 if (hint != null){ 073 //psql.linkColumnReferenceToTable(hint,plocation); 074 hint.setLocation(plocation); 075 // ownerTable.getObjectNameReferences().addObjectName(hint); 076 // ownerTable.getLinkedColumns().addObjectName(hint); 077 // hint.setSourceTable(ownerTable); 078 }else if (exprList != null){ 079 exprList.doParse(psql,plocation); 080 } 081 } 082 083 public void accept(TParseTreeVisitor v){ 084 v.preVisit(this); 085 v.postVisit(this); 086 } 087 088 public void acceptChildren(TParseTreeVisitor v){ 089 v.preVisit(this); 090 v.postVisit(this); 091 } 092 093 public void setExprList(TExpressionList exprList) { 094 this.exprList = exprList; 095 } 096 097 public void setHintValue(TConstant hintValue) { 098 this.hintValue = hintValue; 099 } 100}