1 22 23 package org.xquark.extractor.sql; 24 25 import java.util.Iterator ; 26 import java.util.List ; 27 28 public class SqlBinOpOuterJoin extends SqlBinaryOperator 29 { 30 31 private static final String RCSRevision = "$Revision: 1.5 $"; 32 private static final String RCSName = "$Name: $"; 33 34 35 36 public static final int LEFT_OUTER_jOIN = 0; 37 public static final int RIGHT_OUTER_jOIN = 0; 38 39 protected int _outerJoinType ; 40 protected List _predicateList; 41 42 45 public SqlBinOpOuterJoin() { 46 } 47 48 49 public SqlBinOpOuterJoin(SqlExpression leftOperand, SqlExpression rightOperand, int outerJoinType, List predicateList) 50 { 51 super (leftOperand, rightOperand); 52 setOuterJoinType(outerJoinType); 53 setPredicateList(predicateList); 54 } 55 56 public int getOuterJoinType() { 57 return _outerJoinType; 58 } 59 60 public void setOuterJoinType(int outerJoinType) { 61 _outerJoinType = outerJoinType; 62 } 63 64 public List getPredicateList() 65 { 66 return _predicateList; 67 } 68 69 70 public void setPredicateList(List predicateList) 71 { 72 _predicateList = predicateList; 73 } 74 75 public String toSql (Context context) 76 { 77 79 StringBuffer retVal = new StringBuffer (); 80 81 retVal.append(getLeftOperand().toSql(context)); 82 83 if ( getOuterJoinType() == Constants.LEFT_OUTER_JOIN ) { 84 retVal.append(" LEFT OUTER JOIN "); 85 } 86 else { 87 retVal.append(" RIGHT OUTER JOIN "); 88 } 89 90 retVal.append(getRightOperand().toSql(context)); 91 92 retVal.append(" ON "); 93 94 predicteListToSql(retVal, context); 95 96 return retVal.toString(); 98 } 99 100 protected StringBuffer predicteListToSql(StringBuffer statementBuffer, Context context) { 101 103 Iterator tmpItr = null; 104 if ( null != _predicateList) 105 { 106 tmpItr = _predicateList.iterator(); 107 while (tmpItr.hasNext()) { 108 statementBuffer.append('('); 109 statementBuffer.append(((SqlExpression)tmpItr.next()).toSql(context)); 110 statementBuffer.append(") AND "); 111 } 112 statementBuffer.setLength(statementBuffer.length() - 5); 113 } 114 115 return statementBuffer; 117 } 118 } 119 | Popular Tags |