1 module hunt.sql.ast.SQLDeclareItem;
2 
3 import hunt.sql.ast.SQLObjectImpl;
4 import hunt.sql.ast.SQLObjectWithDataType;
5 import hunt.sql.ast.SQLName;
6 import hunt.sql.ast.SQLDataType;
7 import hunt.sql.ast.SQLExpr;
8 import hunt.sql.ast.SQLObject;
9 import hunt.sql.visitor.SQLASTVisitor;
10 import hunt.sql.ast.statement.SQLTableElement;
11 
12 import hunt.collection;
13 
14 
15 
16 
17 public class SQLDeclareItem : SQLObjectImpl , SQLObjectWithDataType {
18 
19     protected Type                  type;
20 
21     protected SQLName               name;
22 
23     protected SQLDataType           dataType;
24 
25     protected SQLExpr               value;
26 
27     protected List!SQLTableElement tableElementList ;
28 
29     protected SQLObject             resolvedObject;
30 
31     public this() {
32         tableElementList = new ArrayList!SQLTableElement();
33     }
34 
35     public this(SQLName name, SQLDataType dataType) {
36         this();
37         this.setName(name);
38         this.setDataType(dataType);
39     }
40 
41     public this(SQLName name, SQLDataType dataType, SQLExpr value) {
42         this();
43         this.setName(name);
44         this.setDataType(dataType);
45         this.setValue(value);
46     }
47 
48     protected override void accept0(SQLASTVisitor visitor) {
49         if (visitor.visit(this)) {
50             acceptChild(visitor, this.name);
51             acceptChild(visitor, this.dataType);
52             acceptChild(visitor, this.value);
53             acceptChild!SQLTableElement(visitor, this.tableElementList);
54         }
55         visitor.endVisit(this);
56     }
57 
58     public SQLName getName() {
59         return name;
60     }
61 
62     public void setName(SQLName name) {
63         if (name !is null) {
64             name.setParent(this);
65         }
66         this.name = name;
67     }
68 
69     public SQLDataType getDataType() {
70         return dataType;
71     }
72 
73     public void setDataType(SQLDataType dataType) {
74         if (dataType !is null) {
75             dataType.setParent(this);
76         }
77         this.dataType = dataType;
78     }
79 
80     public SQLExpr getValue() {
81         return value;
82     }
83 
84     public void setValue(SQLExpr value) {
85         if (value !is null) {
86             value.setParent(this);
87         }
88         this.value = value;
89     }
90 
91     public List!SQLTableElement getTableElementList() {
92         return tableElementList;
93     }
94 
95     public void setTableElementList(List!SQLTableElement tableElementList) {
96         this.tableElementList = tableElementList;
97     }
98 
99     public enum Type {
100         TABLE, LOCAL, CURSOR
101     }
102 
103     public Type getType() {
104         return type;
105     }
106 
107     public void setType(Type type) {
108         this.type = type;
109     }
110 
111     public SQLObject getResolvedObject() {
112         return resolvedObject;
113     }
114 
115     public void setResolvedObject(SQLObject resolvedObject) {
116         this.resolvedObject = resolvedObject;
117     }
118 }