Index: api/src/main/java/javax/jdo/JDOQLTypedQuery.java =================================================================== --- api/src/main/java/javax/jdo/JDOQLTypedQuery.java (revision 1841021) +++ api/src/main/java/javax/jdo/JDOQLTypedQuery.java (working copy) @@ -22,8 +22,6 @@ import java.util.List; import java.util.Map; -import javax.jdo.FetchPlan; -import javax.jdo.PersistenceManager; import javax.jdo.query.BooleanExpression; import javax.jdo.query.CharacterExpression; import javax.jdo.query.CollectionExpression; @@ -30,6 +28,7 @@ import javax.jdo.query.DateExpression; import javax.jdo.query.DateTimeExpression; import javax.jdo.query.Expression; +import javax.jdo.query.IfThenElseExpression; import javax.jdo.query.ListExpression; import javax.jdo.query.MapExpression; import javax.jdo.query.NumericExpression; @@ -170,6 +169,63 @@ JDOQLTypedQuery filter(BooleanExpression expr); /** + * Method to return an "IF (...) ... ELSE ..." expression for use in this query. + * @param type The type returned by the IfElse. + * @param cond The if condition + * @param thenValueExpr Expression for value to return when the if expression is met + * @param elseValueExpr Expression for value to return when the if expression is not met + * @return The IfThenElse expression + */ + IfThenElseExpression ifThenElse(Class type, BooleanExpression cond, + Expression thenValueExpr, Expression elseValueExpr); + + /** + * Method to return an "IF (...) ... ELSE ..." expression for use in this query. + * @param cond The if condition + * @param thenValue Value to return when the if expression is met + * @param elseValueExpr Expression to return when the if expression is not met + * @return The IfThenElse expression + */ + IfThenElseExpression ifThenElse(BooleanExpression cond, V thenValue, Expression elseValueExpr); + + /** + * Method to return an "IF (...) ... ELSE ..." expression for use in this query. + * @param cond The if condition + * @param thenValueExpr Expression to return when the if expression is met + * @param elseValue Value to return when the if expression is not met + * @return The IfThenElse expression + */ + IfThenElseExpression ifThenElse(BooleanExpression cond, Expression thenValueExpr, V elseValue); + + /** + * Method to return an "IF (...) ... ELSE ..." expression for use in this query. + * @param cond The if condition + * @param thenValue Value to return when the if expression is met + * @param elseValue Value to return when the if expression is not met + * @return The IfThenElse expression + */ + IfThenElseExpression ifThenElse(BooleanExpression cond, V thenValue, V elseValue); + + /** + * Method to return an "IF (...) ... ELSE ..." expression for use in this query. + * @param type The type returned by the IfElse. + * @param cond The if condition + * @param thenValueExpr Expression for value to return when the if expression is met + * @param + * @return + */ + IfThenElseExpression ifThen(Class type, BooleanExpression cond, Expression thenValueExpr); + + /** + * Method to return an "IF (...) ... ELSE ..." expression for use in this query. + * @param cond The if condition + * @param thenValue Value to return when the if expression is met + * @param + * @return + */ + IfThenElseExpression ifThen(BooleanExpression cond, V thenValue); + + /** * Method to set the grouping(s) for the query. * @param exprs Grouping expression(s) * @return The query Index: api/src/main/java/javax/jdo/query/IfThenElseExpression.java =================================================================== --- api/src/main/java/javax/jdo/query/IfThenElseExpression.java (nonexistent) +++ api/src/main/java/javax/jdo/query/IfThenElseExpression.java (working copy) @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package javax.jdo.query; + +/** + * Representation of an IF-THEN-ELSE expression. + * + * @param Java type + */ +public interface IfThenElseExpression extends ComparableExpression { + + /** + * Method to add an "IF (...) ..." clause. + * If called multiple times, will add extra "IF (...) ..." or "ELSE IF (...) ..." + * @param cond The if expression + * @param thenValueExpr Expression to return when the if expression is met + * @return This expression + */ + IfThenElseExpression ifThen(BooleanExpression cond, Expression thenValueExpr); + + /** + * Method to add an "IF (...) ..." clause. + * If called multiple times, will add extra "IF (...) ..." or "ELSE IF (...) ..." + * @param cond The if condition + * @param thenValue Value to return when the if expression is met + * @return This expression + */ + IfThenElseExpression ifThen(BooleanExpression cond, T thenValue); + + /** + * Method to add the "ELSE ..." clause. + * If called multiple times will replace the previous else clause + * @param elseValueExpr Expression for value to return when the if expression is not met + * @return This expression + */ + IfThenElseExpression elseEnd(Expression elseValueExpr); + + /** + * Method to add the "ELSE ..." clause. + * If called multiple times will replace the previous else clause + * @param elseValue Value to return when the if expression is not met + * @return This expression + */ + IfThenElseExpression elseEnd(T elseValue); + +} Index: api/src/main/java/javax/jdo/query/ComparableExpression.java =================================================================== --- api/src/main/java/javax/jdo/query/ComparableExpression.java (revision 1841021) +++ api/src/main/java/javax/jdo/query/ComparableExpression.java (working copy) @@ -81,15 +81,15 @@ /** * Method to return a numeric expression representing the aggregated minimum of this expression. - * @return Numeric expression for the minimum + * @return expression for the minimum */ - NumericExpression min(); + ComparableExpression min(); /** * Method to return a numeric expression representing the aggregated maximum of this expression. - * @return Numeric expression for the maximum + * @return expression for the maximum */ - NumericExpression max(); + ComparableExpression max(); /** * Method to return an order expression for this expression in ascending order. Index: api/src/main/java/javax/jdo/query/NumericExpression.java =================================================================== --- api/src/main/java/javax/jdo/query/NumericExpression.java (revision 1841021) +++ api/src/main/java/javax/jdo/query/NumericExpression.java (working copy) @@ -21,7 +21,7 @@ * * @param Number type */ -public interface NumericExpression extends ComparableExpression +public interface NumericExpression extends ComparableExpression { /** * Method to return an expression for this expression added to the passed expression. @@ -28,7 +28,7 @@ * @param expr The other expression * @return The summation */ - NumericExpression add(Expression expr); + NumericExpression add(Expression expr); /** * Method to return an expression for this expression added to the passed number. @@ -35,7 +35,7 @@ * @param num Number to add * @return The summation */ - NumericExpression add(Number num); + NumericExpression add(Number num); /** * Method to return an expression for this expression subtracting the passed expression. @@ -42,7 +42,7 @@ * @param expr The other expression * @return The difference */ - NumericExpression sub(Expression expr); + NumericExpression sub(Expression expr); /** * Method to return an expression for this expression subtracting the passed number. @@ -49,7 +49,7 @@ * @param num Number to subtract * @return The difference */ - NumericExpression sub(Number num); + NumericExpression sub(Number num); /** * Method to return an expression for this expression multiplied by the passed expression. @@ -56,7 +56,7 @@ * @param expr The other expression * @return The multiplication */ - NumericExpression mul(Expression expr); + NumericExpression mul(Expression expr); /** * Method to return an expression for this expression multiplied by the passed number. @@ -63,7 +63,7 @@ * @param num Number * @return The multiplication */ - NumericExpression mul(Number num); + NumericExpression mul(Number num); /** * Method to return an expression for this expression divided by the passed expression. @@ -70,7 +70,7 @@ * @param expr The other expression * @return The division */ - NumericExpression div(Expression expr); + NumericExpression div(Expression expr); /** * Method to return an expression for this expression divided by the passed number. @@ -77,7 +77,7 @@ * @param num Number to divide by * @return The division */ - NumericExpression div(Number num); + NumericExpression div(Number num); /** * Method to return an expression for this expression modulus the passed expression (
a % b
). @@ -84,7 +84,7 @@ * @param expr The other expression * @return The modulus */ - NumericExpression mod(Expression expr); + NumericExpression mod(Expression expr); /** * Method to return an expression for this expression modulus the passed number. @@ -91,19 +91,19 @@ * @param num Number * @return The modulus */ - NumericExpression mod(Number num); + NumericExpression mod(Number num); /** * Method to return an expression that is the current expression negated. * @return The negated expression */ - NumericExpression neg(); + NumericExpression neg(); /** * Method to return an expression that is the complement of the current expression. * @return The complement expression */ - NumericExpression com(); + NumericExpression com(); /** * Method to return a numeric expression representing the aggregated average of this expression. @@ -115,79 +115,79 @@ * Method to return a numeric expression representing the aggregated sum of this expression. * @return Numeric expression for the sum */ - NumericExpression sum(); + NumericExpression sum(); /** * Method to return the absolute value expression of this expression. * @return The absolute value expression */ - NumericExpression abs(); + NumericExpression abs(); /** * Method to return the square-root value expression of this expression. * @return The square-root value expression */ - NumericExpression sqrt(); + NumericExpression sqrt(); /** * Method to return the arc cosine value expression of this expression. * @return The arc cosine value expression */ - NumericExpression acos(); + NumericExpression acos(); /** * Method to return the arc sine value expression of this expression. * @return The arc sine value expression */ - NumericExpression asin(); + NumericExpression asin(); /** * Method to return the arc tangent value expression of this expression. * @return The arc tangent value expression */ - NumericExpression atan(); + NumericExpression atan(); /** * Method to return the sine value expression of this expression. * @return The sine value expression */ - NumericExpression sin(); + NumericExpression sin(); /** * Method to return the cosine value expression of this expression. * @return The cosine value expression */ - NumericExpression cos(); + NumericExpression cos(); /** * Method to return the tangent value expression of this expression. * @return The tangent value expression */ - NumericExpression tan(); + NumericExpression tan(); /** * Method to return the exponential value expression of this expression. * @return The exponential value expression */ - NumericExpression exp(); + NumericExpression exp(); /** * Method to return the logarithm value expression of this expression. * @return The logarithm value expression */ - NumericExpression log(); + NumericExpression log(); /** * Method to return the ceiling value expression of this expression. * @return The ceiling value expression */ - NumericExpression ceil(); + NumericExpression ceil(); /** * Method to return the floor value expression of this expression. * @return The floor value expression */ - NumericExpression floor(); + NumericExpression floor(); /** * Method to return a bitwise AND expression for this expression with the supplied bit path. @@ -194,7 +194,7 @@ * @param bitExpr Bit expression * @return Bitwise AND expression */ - NumericExpression bAnd(NumericExpression bitExpr); + NumericExpression bAnd(NumericExpression bitExpr); /** * Method to return a bitwise OR expression for this expression with the supplied bit path. @@ -201,7 +201,7 @@ * @param bitExpr Bit expression * @return Bitwise OR expression */ - NumericExpression bOr(NumericExpression bitExpr); + NumericExpression bOr(NumericExpression bitExpr); /** * Method to return a bitwise XOR expression for this expression with the supplied bit path. @@ -208,5 +208,5 @@ * @param bitExpr Bit expression * @return Bitwise XOR expression */ - NumericExpression bXor(NumericExpression bitExpr); + NumericExpression bXor(NumericExpression bitExpr); }