-
Notifications
You must be signed in to change notification settings - Fork 866
/
OArrayNumberSelector.java
128 lines (107 loc) · 4.06 KB
/
OArrayNumberSelector.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* Generated By:JJTree: Do not edit this line. OArrayNumberSelector.java Version 4.3 */
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=true,NODE_PREFIX=O,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package com.orientechnologies.orient.core.sql.parser;
import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.sql.executor.OResult;
import java.util.Map;
import java.util.Set;
public class OArrayNumberSelector extends SimpleNode {
private static final Object UNSET = new Object();
private Object inputFinalValue = UNSET;
OInputParameter inputValue;
OMathExpression expressionValue;
Integer integer;
public OArrayNumberSelector(int id) {
super(id);
}
public OArrayNumberSelector(OrientSql p, int id) {
super(p, id);
}
/**
* Accept the visitor.
**/
public Object jjtAccept(OrientSqlVisitor visitor, Object data) {
return visitor.visit(this, data);
}
public void toString(Map<Object, Object> params, StringBuilder builder) {
if (inputValue != null) {
inputValue.toString(params, builder);
} else if (expressionValue != null) {
expressionValue.toString(params, builder);
} else if (integer != null) {
builder.append(integer);
}
}
public Integer getValue(OIdentifiable iCurrentRecord, Object iResult, OCommandContext ctx) {
Object result = null;
if (inputValue != null) {
result = inputValue.bindFromInputParams(ctx.getInputParameters());
} else if (expressionValue != null) {
result = expressionValue.execute(iCurrentRecord, ctx);
} else if (integer != null) {
result = integer;
}
if (result == null) {
return null;
}
if (result instanceof Number) {
return ((Number) result).intValue();
}
return null;
}
public Integer getValue(OResult iCurrentRecord, Object iResult, OCommandContext ctx) {
Object result = null;
if (inputValue != null) {
result = inputValue.bindFromInputParams(ctx.getInputParameters());
} else if (expressionValue != null) {
result = expressionValue.execute(iCurrentRecord, ctx);
} else if (integer != null) {
result = integer;
}
if (result == null) {
return null;
}
if (result instanceof Number) {
return ((Number) result).intValue();
}
return null;
}
public boolean needsAliases(Set<String> aliases) {
if (expressionValue != null) {
return expressionValue.needsAliases(aliases);
}
return false;
}
public OArrayNumberSelector copy() {
OArrayNumberSelector result = new OArrayNumberSelector(-1);
result.inputValue = inputValue == null ? null : inputValue.copy();
result.expressionValue = expressionValue == null ? null : expressionValue.copy();
result.integer = integer;
return result;
}
@Override public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
OArrayNumberSelector that = (OArrayNumberSelector) o;
if (inputFinalValue != null ? !inputFinalValue.equals(that.inputFinalValue) : that.inputFinalValue != null)
return false;
if (inputValue != null ? !inputValue.equals(that.inputValue) : that.inputValue != null)
return false;
if (expressionValue != null ? !expressionValue.equals(that.expressionValue) : that.expressionValue != null)
return false;
if (integer != null ? !integer.equals(that.integer) : that.integer != null)
return false;
return true;
}
@Override public int hashCode() {
int result = inputFinalValue != null ? inputFinalValue.hashCode() : 0;
result = 31 * result + (inputValue != null ? inputValue.hashCode() : 0);
result = 31 * result + (expressionValue != null ? expressionValue.hashCode() : 0);
result = 31 * result + (integer != null ? integer.hashCode() : 0);
return result;
}
}
/* JavaCC - OriginalChecksum=5b2e495391ede3ccdc6c25aa63c8e591 (do not edit this line) */