equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
38 private boolean debug = Boolean.getBoolean("Expression.debug"); |
38 private boolean debug = Boolean.getBoolean("Expression.debug"); |
39 private Expression left; |
39 private Expression left; |
40 private Expression right; |
40 private Expression right; |
41 private Operator operator; |
41 private Operator operator; |
42 private int ordinal = nextOrdinal++; |
42 private int ordinal = nextOrdinal++; |
|
43 private boolean required = false; |
43 |
44 |
44 Expression() { |
45 Expression() { |
45 if (debug) { |
46 if (debug) { |
46 System.out.println("Expression " + ordinal + " created"); |
47 System.out.println("Expression " + ordinal + " created"); |
47 } |
48 } |
50 void setLeft(Expression left) { |
51 void setLeft(Expression left) { |
51 if (debug) { |
52 if (debug) { |
52 System.out.println("Setting left on " + ordinal + " to " + left); |
53 System.out.println("Setting left on " + ordinal + " to " + left); |
53 } |
54 } |
54 this.left = left; |
55 this.left = left; |
|
56 this.left.setRequired(required); |
55 } |
57 } |
56 |
58 |
57 Expression getLeft() { |
59 Expression getLeft() { |
58 return left; |
60 return left; |
59 } |
61 } |
61 void setRight(Expression right) { |
63 void setRight(Expression right) { |
62 if (debug) { |
64 if (debug) { |
63 System.out.println("Setting right on " + ordinal + " to " + right); |
65 System.out.println("Setting right on " + ordinal + " to " + right); |
64 } |
66 } |
65 this.right = right; |
67 this.right = right; |
|
68 this.right.setRequired(required); |
66 } |
69 } |
67 |
70 |
68 Expression getRight() { |
71 Expression getRight() { |
69 return right; |
72 return right; |
70 } |
73 } |
76 this.operator = o; |
79 this.operator = o; |
77 } |
80 } |
78 |
81 |
79 Operator getOperator() { |
82 Operator getOperator() { |
80 return operator; |
83 return operator; |
|
84 } |
|
85 |
|
86 void setRequired(boolean r) { |
|
87 this.required = r; |
|
88 if (left != null) { |
|
89 left.setRequired(required); |
|
90 } |
|
91 if (right != null) { |
|
92 right.setRequired(required); |
|
93 } |
|
94 } |
|
95 |
|
96 boolean isRequired() { |
|
97 return required; |
81 } |
98 } |
82 |
99 |
83 public String toString() { |
100 public String toString() { |
84 StringBuilder b = new StringBuilder(); |
101 StringBuilder b = new StringBuilder(); |
85 b.append('('); |
102 b.append('('); |