1 22 23 package org.xquark.extractor.sql; 24 25 26 public class SqlBinOpArithmetic extends SqlBinaryOperator 27 { 28 29 private static final String RCSRevision = "$Revision: 1.4 $"; 30 private static final String RCSName = "$Name: $"; 31 32 private int _operator; 33 34 40 public SqlBinOpArithmetic(int operator, SqlExpression leftOperand, SqlExpression rightOperand) 41 { 42 super ( leftOperand, rightOperand ); 43 setOperator ( operator ) ; 44 } 45 46 52 public SqlBinOpArithmetic() 53 { 54 55 } 56 57 62 public int getOperator() 63 { 64 return _operator; 65 } 66 67 72 public void setOperator(int aOperator) 73 { 74 _operator = aOperator; 75 } 76 77 81 public String toSql(Context context) 82 { 83 StringBuffer retVal = new StringBuffer (); 85 86 String lOprnd , rOprnd ; 87 88 lOprnd = getLeftOperand().toSql(context) ; 89 rOprnd = getRightOperand().toSql(context) ; 90 91 int optr = getOperator () ; 92 if (optr == Constants.MODULO_ARITHMETICS) 93 { 94 retVal.append(ARITHMETICSSTRINGS [optr]); 95 retVal.append('('); 96 retVal.append(lOprnd); 97 retVal.append(','); 98 retVal.append(rOprnd); 99 retVal.append(')'); 100 } 101 else 102 { 103 retVal.append("("); 104 retVal.append(lOprnd); 105 retVal.append(") "); 106 retVal.append(ARITHMETICSSTRINGS [optr]); 107 retVal.append(" ("); 108 retVal.append(rOprnd); 109 retVal.append(")"); 110 } 111 112 return retVal.toString(); 114 } 115 } 116 | Popular Tags |