/home/mario/oci/jnb/dataaccess/source/src/java/com/ociweb/service/Expression.java

1    /** 
2     * This software program, Simple Data Access Layer (SDAL), is copyrighted by Object 
3     * Computing inc of St. Louis MO USA. It is provided under the open-source model 
4     * and is free of license fees. You are free to modify this code for your own use 
5     * but you may not claim copyright. 
6     * 
7     * Since SDAL is open source and free of licensing fees, you are free to use, 
8     * modify, and distribute the source code, as long as you include this copyright 
9     * statement. 
10    * 
11    * In particular, you can use SDAL to build proprietary software and are under no 
12    * obligation to redistribute any of your source code that is built using SDAL. 
13    * Note, however, that you may not do anything to the SDAL code, such as 
14    * copyrighting it yourself or claiming authorship of the SDAL code, that will 
15    * prevent SDAL from being distributed freely using an open source development 
16    * model. 
17    * 
18    * Warranty 
19    * LICENSED PRODUCT, SDAL, IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 
20    * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE, 
21    * NONINFRINGEMENT, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 
22    * 
23    * Support 
24    * LICENSED PRODUCT, SDAL, IS PROVIDED WITH NO SUPPORT AND WITHOUT ANY OBLIGATION ON THE 
25    * PART OF OCI OR ANY OF ITS SUBSIDIARIES OR AFFILIATES TO ASSIST IN ITS USE, 
26    * CORRECTION, MODIFICATION OR ENHANCEMENT. 
27    * 
28    * Support may be available from OCI to users who have agreed to a support 
29    * contract. 
30    * 
31    * Liability 
32    * OCI OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH 
33    * RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY 
34    * LICENSED PRODUCT OR ANY PART THEREOF. 
35    * 
36    * IN NO EVENT WILL OCI OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR ANY 
37    * LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL DAMAGES, 
38    * EVEN IF OCI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 
39    * 
40    * Copyright OCI. St. Louis MO USA, 2004 
41    * 
42    */ 
43   package com.ociweb.service; 
44    
45   import java.util.Collection; 
46   import java.util.Map; 
47    
48   public class Expression { 
49       private net.sf.hibernate.expression.Expression expression; 
50    
51       private Expression(net.sf.hibernate.expression.Expression exp) { 
52           expression = exp; 
53       } 
54    
55       net.sf.hibernate.expression.Expression getExpression() { 
56           return expression; 
57       } 
58       /** 
59        * Apply an "equal" constraint to the named property 
60        * @param propertyName 
61        * @param value 
62        * @return ExpressionIntf 
63        */ 
64       public static Expression eq(String propertyName, Object value) { 
65           return new Expression(net.sf.hibernate.expression.Expression.eq(propertyName, value)); 
66       } 
67       /** 
68        * Apply a "like" constraint to the named property 
69        * @param propertyName 
70        * @param value 
71        * @return ExpressionIntf 
72        */ 
73       public static Expression like(String propertyName, Object value) { 
74           return new Expression(net.sf.hibernate.expression.Expression.like(propertyName, value)); 
75       } 
76       /** 
77        * A case-insensitive "like", similar to Postgres <tt>ilike</tt> 
78        * operator 
79        * 
80        * @param propertyName 
81        * @param value 
82        * @return ExpressionIntf 
83        */ 
84       public static Expression ilike(String propertyName, Object value) { 
85           return new Expression(net.sf.hibernate.expression.Expression.ilike(propertyName, value)); 
86       } 
87       /** 
88        * Apply a "greater than" constraint to the named property 
89        * @param propertyName 
90        * @param value 
91        * @return ExpressionIntf 
92        */ 
93       public static Expression gt(String propertyName, Object value) { 
94           return new Expression(net.sf.hibernate.expression.Expression.gt(propertyName, value)); 
95       } 
96       /** 
97        * Apply a "less than" constraint to the named property 
98        * @param propertyName 
99        * @param value 
100       * @return ExpressionIntf 
101       */ 
102      public static Expression lt(String propertyName, Object value) { 
103          return new Expression(net.sf.hibernate.expression.Expression.lt(propertyName, value)); 
104      } 
105      /** 
106       * Apply a "less than or equal" constraint to the named property 
107       * @param propertyName 
108       * @param value 
109       * @return ExpressionIntf 
110       */ 
111      public static Expression le(String propertyName, Object value) { 
112          return new Expression(net.sf.hibernate.expression.Expression.le(propertyName, value)); 
113      } 
114      /** 
115       * Apply a "greater than or equal" constraint to the named property 
116       * @param propertyName 
117       * @param value 
118       * @return ExpressionIntf 
119       */ 
120      public static Expression ge(String propertyName, Object value) { 
121          return new Expression(net.sf.hibernate.expression.Expression.ge(propertyName, value)); 
122      } 
123      /** 
124       * Apply a "between" constraint to the named property 
125       * @param propertyName 
126       * @param lo 
127       * @param hi 
128       * @return ExpressionIntf 
129       */ 
130      public static Expression between(String propertyName, Object lo, Object hi) { 
131          return new Expression(net.sf.hibernate.expression.Expression.between(propertyName, lo, hi)); 
132      } 
133      /** 
134       * Apply an "in" constraint to the named property 
135       * @param propertyName 
136       * @param values 
137       * @return ExpressionIntf 
138       */ 
139      public static Expression in(String propertyName, Object[] values) { 
140          return new Expression(net.sf.hibernate.expression.Expression.in(propertyName, values)); 
141      } 
142      /** 
143       * Apply an "in" constraint to the named property 
144       * @param propertyName 
145       * @param values 
146       * @return ExpressionIntf 
147       */ 
148      public static Expression in(String propertyName, Collection values) { 
149          return new Expression(net.sf.hibernate.expression.Expression.in(propertyName, values)); 
150      } 
151      /** 
152       * Apply an "is null" constraint to the named property 
153       * @return ExpressionIntf 
154       */ 
155      public static Expression isNull(String propertyName) { 
156          return new Expression(net.sf.hibernate.expression.Expression.isNull(propertyName)); 
157      } 
158      /** 
159       * Apply an "equal" constraint to two properties 
160       */ 
161      public static Expression eqProperty(String propertyName, String otherPropertyName) { 
162          return new Expression(net.sf.hibernate.expression.Expression.eqProperty(propertyName, otherPropertyName)); 
163      } 
164      /** 
165       * Apply a "less than" constraint to two properties 
166       */ 
167      public static Expression ltProperty(String propertyName, String otherPropertyName) { 
168          return new Expression(net.sf.hibernate.expression.Expression.ltProperty(propertyName, otherPropertyName)); 
169      } 
170      /** 
171       * Apply a "less than or equal" constraint to two properties 
172       */ 
173      public static Expression leProperty(String propertyName, String otherPropertyName) { 
174          return new Expression(net.sf.hibernate.expression.Expression.leProperty(propertyName, otherPropertyName)); 
175      } 
176      /** 
177       * Apply an "is not null" constraint to the named property 
178       * @return ExpressionIntf 
179       */ 
180      public static Expression isNotNull(String propertyName) { 
181          return new Expression(net.sf.hibernate.expression.Expression.isNotNull(propertyName)); 
182      } 
183      /** 
184       * Return the conjuction of two expressions 
185       * 
186       * @param lhs 
187       * @param rhs 
188       * @return ExpressionIntf 
189       */ 
190      public static Expression and(Expression lhs, Expression rhs) { 
191          return new Expression(net.sf.hibernate.expression.Expression.and(lhs.getExpression(), rhs.getExpression())); 
192      } 
193      /** 
194       * Return the disjuction of two expressions 
195       * 
196       * @param lhs 
197       * @param rhs 
198       * @return ExpressionIntf 
199       */ 
200      public static Expression or(Expression lhs, Expression rhs) { 
201          return new Expression(net.sf.hibernate.expression.Expression.or(lhs.getExpression(), rhs.getExpression())); 
202      } 
203      /** 
204       * Return the negation of an expression 
205       * 
206       * @param expression 
207       * @return ExpressionIntf 
208       */ 
209      public Expression not(Expression expression) { 
210          return new Expression(net.sf.hibernate.expression.Expression.not(expression.getExpression())); 
211      } 
212      /** 
213       * Apply a constraint expressed in SQL. Any occurrences of <tt>$alias</tt> 
214       * will be replaced by the table alias. 
215       * 
216       * @param sql 
217       * @return ExpressionIntf 
218       */ 
219      public static Expression sql(String sql) { 
220          return new Expression(net.sf.hibernate.expression.Expression.sql(sql)); 
221      } 
222      /** 
223       * Apply an "equals" constraint to each property in the 
224       * key set of a <tt>Map</tt> 
225       * 
226       * @param propertyNameValues a map from property names to values 
227       * @return ExpressionIntf 
228       */ 
229      public static Expression allEq(Map propertyNameValues) { 
230          return new Expression(net.sf.hibernate.expression.Expression.allEq(propertyNameValues)); 
231      } 
232  } 
233