1 15 package org.josql.expressions; 16 17 import java.util.Collection ; 18 import java.util.Iterator ; 19 import java.util.List ; 20 21 import org.josql.Query; 22 import org.josql.QueryExecutionException; 23 24 import org.josql.internal.Utilities; 25 26 42 public class GTLTExpression extends BinaryExpression 43 { 44 45 private int type = -1; 46 private boolean ignoreCase = false; 47 48 public int getType () 49 { 50 51 return this.type; 52 53 } 54 55 61 public void setType (int t) 62 { 63 64 this.type = t; 65 66 } 67 68 public void setIgnoreCase (boolean v) 69 { 70 71 this.ignoreCase = v; 72 73 } 74 75 public boolean isIgnoreCase () 76 { 77 78 return this.ignoreCase; 79 80 } 81 82 92 public boolean isTrue (Object o, 93 Query q) 94 throws QueryExecutionException 95 { 96 97 Object l = this.left.getValue (o, 99 q); 100 101 Object r = this.right.getValue (o, 102 q); 103 104 if ((l == null) 105 && 106 (r == null) 107 ) 108 { 109 110 if ((this.type == 1) 111 || 112 (this.type == 3) 113 ) 114 { 115 116 return true; 117 118 } 119 120 } 121 122 if ((l == null) 123 || 124 (r == null) 125 ) 126 { 127 128 return false; 129 130 } 131 132 return Utilities.matches (l, 133 r, 134 this.ignoreCase, 135 this.type, 136 false); 137 138 } 139 140 146 public String toString () 147 { 148 149 String pred = "<"; 150 151 if (this.type == Utilities.GT) 152 { 153 154 pred = ">"; 155 156 } 157 158 if (this.type == Utilities.GTE) 159 { 160 161 pred = ">="; 162 163 } 164 165 if (this.type == Utilities.LTE) 166 { 167 168 pred = "<="; 169 170 } 171 172 if (this.ignoreCase) 173 { 174 175 pred = "$" + pred; 176 177 } 178 179 if (this.isBracketed ()) 180 { 181 182 return "(" + this.left.toString () + " " + pred + " " + this.right.toString () + ")"; 183 184 } 185 186 return this.left.toString () + " " + pred + " " + this.right.toString (); 187 188 } 189 190 } 191 | Popular Tags |