use of org.datanucleus.query.expression.InvokeExpression in project datanucleus-api-jdo by datanucleus.
the class StringExpressionImpl method indexOf.
/* (non-Javadoc)
* @see org.datanucleus.query.typesafe.StringExpression#indexOf(java.lang.String, int)
*/
public NumericExpression indexOf(String str, int pos) {
List<org.datanucleus.query.expression.Expression> args = new ArrayList();
args.add(new Literal(str));
args.add(new Literal(pos));
org.datanucleus.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "indexOf", args);
return new NumericExpressionImpl<Integer>(invokeExpr);
}
use of org.datanucleus.query.expression.InvokeExpression in project datanucleus-api-jdo by datanucleus.
the class StringExpressionImpl method startsWith.
/* (non-Javadoc)
* @see org.datanucleus.query.typesafe.StringExpression#startsWith(java.lang.String)
*/
public BooleanExpression startsWith(String str) {
List<org.datanucleus.query.expression.Expression> args = new ArrayList();
args.add(new Literal(str));
org.datanucleus.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "startsWith", args);
return new BooleanExpressionImpl(invokeExpr);
}
use of org.datanucleus.query.expression.InvokeExpression in project datanucleus-api-jdo by datanucleus.
the class StringExpressionImpl method equalsIgnoreCase.
/* (non-Javadoc)
* @see org.datanucleus.query.typesafe.StringExpression#equalsIgnoreCase(java.lang.String)
*/
public BooleanExpression equalsIgnoreCase(String str) {
List<org.datanucleus.query.expression.Expression> args = new ArrayList();
args.add(new Literal(str));
org.datanucleus.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "equalsIgnoreCase", args);
return new BooleanExpressionImpl(invokeExpr);
}
use of org.datanucleus.query.expression.InvokeExpression in project datanucleus-api-jdo by datanucleus.
the class StringExpressionImpl method indexOf.
/* (non-Javadoc)
* @see org.datanucleus.query.typesafe.StringExpression#indexOf(java.lang.String)
*/
public NumericExpression<Integer> indexOf(String str) {
List<org.datanucleus.query.expression.Expression> args = new ArrayList();
args.add(new Literal(str));
org.datanucleus.query.expression.Expression invokeExpr = new InvokeExpression(queryExpr, "indexOf", args);
return new NumericExpressionImpl<Integer>(invokeExpr);
}
use of org.datanucleus.query.expression.InvokeExpression in project datanucleus-core by datanucleus.
the class TemporalSecondMethod method evaluate.
/* (non-Javadoc)
* @see org.datanucleus.query.evaluator.memory.InvocationEvaluator#evaluate(org.datanucleus.query.expression.InvokeExpression, org.datanucleus.query.evaluator.memory.InMemoryExpressionEvaluator)
*/
public Object evaluate(InvokeExpression expr, Object invokedValue, InMemoryExpressionEvaluator eval) {
if (invokedValue == null && expr.getArguments() != null) {
// Specified as static function, so use argument of InvokeExpression
List<Expression> argExprs = expr.getArguments();
if (argExprs.size() > 1) {
throw new NucleusUserException("Incorrect number of arguments to SECOND");
}
Expression argExpr = argExprs.get(0);
invokedValue = eval.getValueForExpression(argExpr);
}
if (invokedValue == null) {
return Boolean.FALSE;
}
if (!(invokedValue instanceof Date)) {
throw new NucleusException(Localiser.msg("021011", expr.getOperation(), invokedValue.getClass().getName()));
}
if (invokedValue instanceof Date) {
Calendar cal = Calendar.getInstance();
cal.setTime((Date) invokedValue);
return Integer.valueOf(cal.get(Calendar.SECOND));
} else if (invokedValue instanceof Calendar) {
return Integer.valueOf(((Calendar) invokedValue).get(Calendar.SECOND));
} else if (invokedValue instanceof LocalTime) {
return ((LocalTime) invokedValue).getSecond();
} else if (invokedValue instanceof LocalDateTime) {
return ((LocalDateTime) invokedValue).getSecond();
} else {
throw new NucleusUserException("We do not currently support SECOND() with argument of type " + invokedValue.getClass().getName());
}
}
Aggregations