01: /**********************************************************************
02: Copyright (c) 2004 Erik Bengtson and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15: Contributors:
16: ...
17: **********************************************************************/package org.jpox.store.expression;
18:
19: /**
20: * Concatenate two expressions. This implements the SQL standard concatenation operator.
21: * e.g. EXPR1 || EXPR2
22: *
23: * @version $Revision: 1.8 $
24: **/
25: public class ConcatOperatorExpression extends StringExpression {
26: /**
27: * Performs a concatenation on two operands.
28: * op(operand1,operand2)
29: * operand1 op operand2
30: * @param operand1 the left-hand expression
31: * @param operand2 the right-hand expression
32: */
33: public ConcatOperatorExpression(ScalarExpression operand1,
34: ScalarExpression operand2) {
35: super (operand1.qs);
36: if (ScalarExpression.OP_CONCAT
37: .isHigherThanLeftSide(operand1.lowestOperator)) {
38: st.append('(').append(operand1).append(')');
39: } else {
40: st.append(operand1);
41: }
42:
43: st.append(operand1.qs.getStoreManager().getDatastoreAdapter()
44: .getOperatorConcat());
45:
46: if (ScalarExpression.OP_CONCAT
47: .isHigherThanRightSide(operand2.lowestOperator)) {
48: st.append('(').append(operand2).append(')');
49: } else {
50: st.append(operand2);
51: }
52: }
53: }
|