public Value add(Value v1, Value v2) { return new Math((Val) v1, (Val) v2, Math.ADD); }
public void orderBy(Select sel, ExpContext ctx, ExpState state, boolean asc) { sel.orderBy(newSQLBuffer(sel, ctx, state), asc, false, getSelectAs()); }
private Object handleMathVal(Object value, Object ob, Object[] params, OpenJPAStateManager sm) { org.apache.openjpa.jdbc.kernel.exps.Math mathVal = (org.apache.openjpa.jdbc.kernel.exps.Math) value; Val value1 = mathVal.getVal1(); Object val1 = getValue(value1, ob, params, sm); Class c1 = value1.getType(); Val value2 = mathVal.getVal2(); Object val2 = getValue(value2, ob, params, sm); Class c2 = value2.getType(); String op = mathVal.getOperation(); if (op.equals(org.apache.openjpa.jdbc.kernel.exps.Math.ADD)) return Filters.add(val1, c1, val2, c2); else if (op.equals( org.apache.openjpa.jdbc.kernel.exps.Math.SUBTRACT)) return Filters.subtract(val1, c1, val2, c2); else if (op.equals( org.apache.openjpa.jdbc.kernel.exps.Math.MULTIPLY)) return Filters.multiply(val1, c1, val2, c2); else if (op.equals( org.apache.openjpa.jdbc.kernel.exps.Math.DIVIDE)) return Filters.divide(val1, c1, val2, c2); else if (op.equals(org.apache.openjpa.jdbc.kernel.exps.Math.MOD)) return Filters.mod(val1, c1, val2, c2); throw new UnsupportedException(); }
private SQLBuffer newSQLBuffer(Select sel, ExpContext ctx, ExpState state) { calculateValue(sel, ctx, state, null, null); SQLBuffer buf = new SQLBuffer(ctx.store.getDBDictionary()); appendTo(sel, ctx, state, buf, 0); return buf; }
public void groupBy(Select sel, ExpContext ctx, ExpState state) { sel.groupBy(newSQLBuffer(sel, ctx, state)); }
public Object load(ExpContext ctx, ExpState state, Result res) throws SQLException { return Filters.convert(res.getObject(this, JavaSQLTypes.JDBC_DEFAULT, null), getType()); }
private Object handleMathVal(Object value, Object ob, Object[] params, OpenJPAStateManager sm) { org.apache.openjpa.jdbc.kernel.exps.Math mathVal = (org.apache.openjpa.jdbc.kernel.exps.Math) value; Val value1 = mathVal.getVal1(); Object val1 = getValue(value1, ob, params, sm); Class c1 = value1.getType(); Val value2 = mathVal.getVal2(); Object val2 = getValue(value2, ob, params, sm); Class c2 = value2.getType(); String op = mathVal.getOperation(); if (op.equals(org.apache.openjpa.jdbc.kernel.exps.Math.ADD)) return Filters.add(val1, c1, val2, c2); else if (op.equals( org.apache.openjpa.jdbc.kernel.exps.Math.SUBTRACT)) return Filters.subtract(val1, c1, val2, c2); else if (op.equals( org.apache.openjpa.jdbc.kernel.exps.Math.MULTIPLY)) return Filters.multiply(val1, c1, val2, c2); else if (op.equals( org.apache.openjpa.jdbc.kernel.exps.Math.DIVIDE)) return Filters.divide(val1, c1, val2, c2); else if (op.equals(org.apache.openjpa.jdbc.kernel.exps.Math.MOD)) return Filters.mod(val1, c1, val2, c2); throw new UnsupportedException(); }
private SQLBuffer newSQLBuffer(Select sel, ExpContext ctx, ExpState state) { calculateValue(sel, ctx, state, null, null); SQLBuffer buf = new SQLBuffer(ctx.store.getDBDictionary()); appendTo(sel, ctx, state, buf, 0); return buf; }
public void select(Select sel, ExpContext ctx, ExpState state, boolean pks) { sel.select(newSQLBuffer(sel, ctx, state), this); }
public Object load(ExpContext ctx, ExpState state, Result res) throws SQLException { return Filters.convert(res.getObject(this, JavaSQLTypes.JDBC_DEFAULT, null), getType()); }
public Value divide(Value v1, Value v2) { return new Math((Val) v1, (Val) v2, Math.DIVIDE); }
private Object handleMathVal(Object value, Object ob, Object[] params, OpenJPAStateManager sm) { org.apache.openjpa.jdbc.kernel.exps.Math mathVal = (org.apache.openjpa.jdbc.kernel.exps.Math) value; Val value1 = mathVal.getVal1(); Object val1 = getValue(value1, ob, params, sm); Class c1 = value1.getType(); Val value2 = mathVal.getVal2(); Object val2 = getValue(value2, ob, params, sm); Class c2 = value2.getType(); String op = mathVal.getOperation(); if (op.equals(org.apache.openjpa.jdbc.kernel.exps.Math.ADD)) return Filters.add(val1, c1, val2, c2); else if (op.equals( org.apache.openjpa.jdbc.kernel.exps.Math.SUBTRACT)) return Filters.subtract(val1, c1, val2, c2); else if (op.equals( org.apache.openjpa.jdbc.kernel.exps.Math.MULTIPLY)) return Filters.multiply(val1, c1, val2, c2); else if (op.equals( org.apache.openjpa.jdbc.kernel.exps.Math.DIVIDE)) return Filters.divide(val1, c1, val2, c2); else if (op.equals(org.apache.openjpa.jdbc.kernel.exps.Math.MOD)) return Filters.mod(val1, c1, val2, c2); throw new UnsupportedException(); }
private SQLBuffer newSQLBuffer(Select sel, ExpContext ctx, ExpState state) { calculateValue(sel, ctx, state, null, null); SQLBuffer buf = new SQLBuffer(ctx.store.getDBDictionary()); appendTo(sel, ctx, state, buf, 0); return buf; }
public void orderBy(Select sel, ExpContext ctx, ExpState state, boolean asc) { sel.orderBy(newSQLBuffer(sel, ctx, state), asc, false, getSelectAs()); }
public void select(Select sel, ExpContext ctx, ExpState state, boolean pks) { sel.select(newSQLBuffer(sel, ctx, state), this); }
public Object load(ExpContext ctx, ExpState state, Result res) throws SQLException { return Filters.convert(res.getObject(this, JavaSQLTypes.JDBC_DEFAULT, null), getType()); }
new Math() {{ double x = sin(23.65); double y = log(x); ... }};
private Object handleMathVal(Object value, Object ob, Object[] params, OpenJPAStateManager sm) { org.apache.openjpa.jdbc.kernel.exps.Math mathVal = (org.apache.openjpa.jdbc.kernel.exps.Math) value; Val value1 = mathVal.getVal1(); Object val1 = getValue(value1, ob, params, sm); Class c1 = value1.getType(); Val value2 = mathVal.getVal2(); Object val2 = getValue(value2, ob, params, sm); Class c2 = value2.getType(); String op = mathVal.getOperation(); if (op.equals(org.apache.openjpa.jdbc.kernel.exps.Math.ADD)) return Filters.add(val1, c1, val2, c2); else if (op.equals( org.apache.openjpa.jdbc.kernel.exps.Math.SUBTRACT)) return Filters.subtract(val1, c1, val2, c2); else if (op.equals( org.apache.openjpa.jdbc.kernel.exps.Math.MULTIPLY)) return Filters.multiply(val1, c1, val2, c2); else if (op.equals( org.apache.openjpa.jdbc.kernel.exps.Math.DIVIDE)) return Filters.divide(val1, c1, val2, c2); else if (op.equals(org.apache.openjpa.jdbc.kernel.exps.Math.MOD)) return Filters.mod(val1, c1, val2, c2); throw new UnsupportedException(); }
private SQLBuffer newSQLBuffer(Select sel, ExpContext ctx, ExpState state) { calculateValue(sel, ctx, state, null, null); SQLBuffer buf = new SQLBuffer(ctx.store.getDBDictionary()); appendTo(sel, ctx, state, buf, 0); return buf; }
public void orderBy(Select sel, ExpContext ctx, ExpState state, boolean asc) { sel.orderBy(newSQLBuffer(sel, ctx, state), asc, false, getSelectAs()); }