001package gudusoft.gsqlparser.nodes; 002 003/** 004 * Postgresql attribute_option = value 005 * 006 * #Todo: this class needs to be replaced by {@link TNameValuePair} later 007 */ 008 009public class TAttributeOption extends TParseTreeNode { 010 011 public enum EValueType {vtDataType,vtConstant,vtExpression}; 012 013 private TObjectName optionName; 014 private TTypeName optionValueDataType; 015 private TConstant optionValueConstant; 016 private EValueType valueType; 017 018 private String optionValue; 019 020 public String getOptionValue() { 021 return optionValue; 022 } 023 024 public TObjectName getOptionName() { 025 return optionName; 026 } 027 028 public TConstant getOptionValueConstant() { 029 return optionValueConstant; 030 } 031 032 public TTypeName getOptionValueDataType() { 033 return optionValueDataType; 034 } 035 036 public EValueType getValueType() { 037 return valueType; 038 } 039 040 public void init(Object arg1, Object arg2){ 041 optionName = (TObjectName)arg1; 042 if (arg2 instanceof TTypeName){ 043 valueType = TAttributeOption.EValueType.vtDataType; 044 optionValueDataType = (TTypeName)arg2; 045 optionValue = optionValueDataType.toString(); 046 }else if (arg2 instanceof TConstant){ 047 valueType = TAttributeOption.EValueType.vtConstant; 048 optionValueConstant = (TConstant)arg2; 049 optionValue = optionValueConstant.toString(); 050 }else if (arg2 instanceof TExpression){ 051 valueType = TAttributeOption.EValueType.vtExpression; 052 optionValue = ((TExpression)arg2).toString(); 053 } 054 } 055 056 public void setOptionName(TObjectName optionName) { 057 this.optionName = optionName; 058 } 059 060 public void setOptionValueDataType(TTypeName optionValueDataType) { 061 this.optionValueDataType = optionValueDataType; 062 } 063 064 public void setOptionValueConstant(TConstant optionValueConstant) { 065 this.optionValueConstant = optionValueConstant; 066 } 067 068 public void setValueType(EValueType valueType) { 069 this.valueType = valueType; 070 } 071 072 public void accept(TParseTreeVisitor v){ 073 v.preVisit(this); 074 v.postVisit(this); 075 } 076 public void acceptChildren(TParseTreeVisitor v){ 077 v.preVisit(this); 078 v.postVisit(this); 079 } 080}