21
21
*/
22
22
package net .sf .jsqlparser .expression ;
23
23
24
- import net .sf .jsqlparser .schema .Column ;
25
24
import net .sf .jsqlparser .statement .select .OrderByElement ;
26
25
27
26
import java .util .List ;
38
37
*/
39
38
public class AnalyticExpression implements Expression {
40
39
41
- //private List<Column> partitionByColumns;
40
+ //private List<Column> partitionByColumns;
42
41
private ExpressionList partitionExpressionList ;
43
- private List <OrderByElement > orderByElements ;
44
- private String name ;
45
- private Expression expression ;
42
+ private List <OrderByElement > orderByElements ;
43
+ private String name ;
44
+ private Expression expression ;
46
45
private Expression offset ;
47
46
private Expression defaultValue ;
48
- private boolean allColumns = false ;
47
+ private boolean allColumns = false ;
49
48
private WindowElement windowElement ;
49
+ private KeepExpression keep = null ;
50
50
51
- @ Override
52
- public void accept (ExpressionVisitor expressionVisitor ) {
53
- expressionVisitor .visit (this );
54
- }
51
+ @ Override
52
+ public void accept (ExpressionVisitor expressionVisitor ) {
53
+ expressionVisitor .visit (this );
54
+ }
55
55
56
- public List <OrderByElement > getOrderByElements () {
57
- return orderByElements ;
58
- }
56
+ public List <OrderByElement > getOrderByElements () {
57
+ return orderByElements ;
58
+ }
59
59
60
- public void setOrderByElements (List <OrderByElement > orderByElements ) {
61
- this .orderByElements = orderByElements ;
62
- }
60
+ public void setOrderByElements (List <OrderByElement > orderByElements ) {
61
+ this .orderByElements = orderByElements ;
62
+ }
63
63
64
- // public List<Column> getPartitionByColumns () {
65
- // return partitionByColumns ;
66
- // }
67
- //
68
- // public void setPartitionByColumns(List<Column> partitionByColumns ) {
69
- // this.partitionByColumns = partitionByColumns ;
70
- // }
64
+ public KeepExpression getKeep () {
65
+ return keep ;
66
+ }
67
+
68
+ public void setKeep ( KeepExpression keep ) {
69
+ this .keep = keep ;
70
+ }
71
71
72
72
public ExpressionList getPartitionExpressionList () {
73
73
return partitionExpressionList ;
@@ -76,24 +76,22 @@ public ExpressionList getPartitionExpressionList() {
76
76
public void setPartitionExpressionList (ExpressionList partitionExpressionList ) {
77
77
this .partitionExpressionList = partitionExpressionList ;
78
78
}
79
-
80
-
81
79
82
- public String getName () {
83
- return name ;
84
- }
80
+ public String getName () {
81
+ return name ;
82
+ }
85
83
86
- public void setName (String name ) {
87
- this .name = name ;
88
- }
84
+ public void setName (String name ) {
85
+ this .name = name ;
86
+ }
89
87
90
- public Expression getExpression () {
91
- return expression ;
92
- }
88
+ public Expression getExpression () {
89
+ return expression ;
90
+ }
93
91
94
- public void setExpression (Expression expression ) {
95
- this .expression = expression ;
96
- }
92
+ public void setExpression (Expression expression ) {
93
+ this .expression = expression ;
94
+ }
97
95
98
96
public Expression getOffset () {
99
97
return offset ;
@@ -120,61 +118,65 @@ public void setWindowElement(WindowElement windowElement) {
120
118
}
121
119
122
120
@ Override
123
- public String toString () {
124
- StringBuilder b = new StringBuilder ();
121
+ public String toString () {
122
+ StringBuilder b = new StringBuilder ();
125
123
126
- b .append (name ).append ("(" );
127
- if (expression != null ) {
128
- b .append (expression .toString ());
124
+ b .append (name ).append ("(" );
125
+ if (expression != null ) {
126
+ b .append (expression .toString ());
129
127
if (offset != null ) {
130
128
b .append (", " ).append (offset .toString ());
131
129
if (defaultValue != null ) {
132
130
b .append (", " ).append (defaultValue .toString ());
133
131
}
134
132
}
135
- } else if (isAllColumns ()) {
136
- b .append ("*" );
137
- }
138
- b .append (") OVER (" );
139
-
140
- toStringPartitionBy (b );
141
- toStringOrderByElements (b );
142
-
143
- b .append (")" );
144
-
145
- return b .toString ();
146
- }
147
-
148
- public boolean isAllColumns () {
149
- return allColumns ;
150
- }
151
-
152
- public void setAllColumns (boolean allColumns ) {
153
- this .allColumns = allColumns ;
154
- }
155
-
156
- private void toStringPartitionBy (StringBuilder b ) {
157
- if (partitionExpressionList != null && !partitionExpressionList .getExpressions ().isEmpty ()) {
158
- b .append ("PARTITION BY " );
159
- b .append (PlainSelect .getStringList (partitionExpressionList .getExpressions (), true , false ));
160
- b .append (" " );
161
- }
162
- }
163
-
164
- private void toStringOrderByElements (StringBuilder b ) {
165
- if (orderByElements != null && !orderByElements .isEmpty ()) {
166
- b .append ("ORDER BY " );
167
- for (int i = 0 ; i < orderByElements .size (); i ++) {
168
- if (i > 0 ) {
169
- b .append (", " );
170
- }
171
- b .append (orderByElements .get (i ).toString ());
172
- }
173
-
174
- if (windowElement != null ){
133
+ } else if (isAllColumns ()) {
134
+ b .append ("*" );
135
+ }
136
+ b .append (") " );
137
+ if (keep != null ) {
138
+ b .append (keep .toString ()).append (" " );
139
+ }
140
+ b .append ("OVER (" );
141
+
142
+ toStringPartitionBy (b );
143
+ toStringOrderByElements (b );
144
+
145
+ b .append (")" );
146
+
147
+ return b .toString ();
148
+ }
149
+
150
+ public boolean isAllColumns () {
151
+ return allColumns ;
152
+ }
153
+
154
+ public void setAllColumns (boolean allColumns ) {
155
+ this .allColumns = allColumns ;
156
+ }
157
+
158
+ private void toStringPartitionBy (StringBuilder b ) {
159
+ if (partitionExpressionList != null && !partitionExpressionList .getExpressions ().isEmpty ()) {
160
+ b .append ("PARTITION BY " );
161
+ b .append (PlainSelect .getStringList (partitionExpressionList .getExpressions (), true , false ));
162
+ b .append (" " );
163
+ }
164
+ }
165
+
166
+ private void toStringOrderByElements (StringBuilder b ) {
167
+ if (orderByElements != null && !orderByElements .isEmpty ()) {
168
+ b .append ("ORDER BY " );
169
+ for (int i = 0 ; i < orderByElements .size (); i ++) {
170
+ if (i > 0 ) {
171
+ b .append (", " );
172
+ }
173
+ b .append (orderByElements .get (i ).toString ());
174
+ }
175
+
176
+ if (windowElement != null ) {
175
177
b .append (' ' );
176
178
b .append (windowElement );
177
179
}
178
- }
179
- }
180
+ }
181
+ }
180
182
}
0 commit comments