1 28 29 package com.caucho.ejb.ql; 30 31 import com.caucho.config.ConfigException; 32 import com.caucho.ejb.cfg.EjbEntityBean; 33 import com.caucho.util.CharBuffer; 34 35 import java.lang.reflect.Method ; 36 37 40 class EmptyExpr extends Expr { 41 private CollectionExpr _collection; 43 private boolean _isNot; 45 private Query _parent; 47 48 54 EmptyExpr(Expr collection, boolean isNot) 55 throws ConfigException 56 { 57 _isNot = isNot; 58 59 if (collection instanceof CollectionExpr) 60 _collection = (CollectionExpr) collection; 61 else 62 throw error(L.l("IS EMPTY needs a collection-path at `{0}'.", 63 collection)); 64 65 evalTypes(); 66 } 67 68 71 void evalTypes() 72 throws ConfigException 73 { 74 setJavaType(boolean.class); 75 } 76 77 public String addRelation(EjbEntityBean bean, FieldExpr id) 78 throws ConfigException 79 { 80 return null; 81 } 82 83 public Method getMethod() 84 { 85 throw new UnsupportedOperationException (); 87 } 88 89 public EjbEntityBean getPersistentBean() 90 { 91 throw new UnsupportedOperationException (); 93 } 94 95 public void addArg(Expr arg) 96 { 97 throw new UnsupportedOperationException (); 99 } 100 101 106 void generateWhere(CharBuffer cb) 107 { 108 if (_collection != null) { 109 _collection.generateSelect(cb); 110 111 if (_isNot) 112 cb.append(" IS NOT EMPTY"); 113 else 114 cb.append(" IS EMPTY"); 115 116 137 } 138 else { 139 cb.append("TRUE"); 140 } 141 } 142 143 public String toString() 144 { 145 String str = _collection.toString(); 146 147 if (_isNot) 148 return str + " IS NOT EMPTY"; 149 else 150 return str + " IS EMPTY"; 151 } 152 } 153 | Popular Tags |