public static Constant<Long> create(long i) { if (i >= 0 && i < CACHE_SIZE) { return LONGS[(int)i]; } else { return new ConstantImpl<Long>(Long.class, Long.valueOf(i)); } }
/** * Create a Constant expression for the given value * * @param value * @return */ public static <T> Expression<T> constant(T value) { return ConstantImpl.create(value); }
public static Constant<Integer> create(int i) { if (i >= 0 && i < CACHE_SIZE) { return INTEGERS[i]; } else { return new ConstantImpl<Integer>(Integer.class, Integer.valueOf(i)); } }
/** * Get the position of the given String in this String, the first position is 1 * * @param str * @return locate(str, this, start) */ public NumberExpression<Integer> locate(String str, int start) { return NumberOperation.create(Integer.class, Ops.StringOps.LOCATE2, ConstantImpl.create(str), mixin, ConstantImpl.create(start)); }
public static Constant<Byte> create(byte i) { if (i >= 0 && i < CACHE_SIZE) { return BYTES[i]; } else { return new ConstantImpl<Byte>(Byte.class, Byte.valueOf(i)); } }
/** * Get the given substring * * @param beginIndex * @param endIndex * @return this.substring(beginIndex, endIndex) * @see java.lang.String#substring(int, int) */ public StringExpression substring(int beginIndex, int endIndex) { return StringOperation.create(Ops.SUBSTR_2ARGS, mixin, ConstantImpl.create(beginIndex), ConstantImpl.create(endIndex)); }
public static Constant<Character> create(char i) { if (i >= 0 && i < CACHE_SIZE) { return CHARACTERS[i]; } else { return new ConstantImpl<Character>(Character.class, Character.valueOf(i)); } }
/** * Expr: {@code this like str} ignoring case * * @param str string * @param escape escape character * @return this like string */ public BooleanExpression likeIgnoreCase(String str, char escape) { return BooleanOperation.create(Ops.LIKE_ESCAPE_IC, mixin, ConstantImpl.create(str), ConstantImpl.create(escape)); }
public static Constant<Short> create(short i) { if (i >= 0 && i < CACHE_SIZE) { return SHORTS[i]; } else { return new ConstantImpl<Short>(Short.class, Short.valueOf(i)); } }
public SQLMergeClause values(Object... v) { for (Object value : v) { if (value instanceof Expression<?>) { values.add((Expression<?>) value); } else if (value != null) { values.add(ConstantImpl.create(value)); } else { values.add(Null.CONSTANT); } } return this; }
/** * divides an ordered data set into a number of buckets indicated by expr and assigns the * appropriate bucket number to each row * * @param num * @return */ public static <T extends Number & Comparable> WindowOver<T> ntile(T num) { return new WindowOver<T>((Class<T>)num.getClass(), SQLOps.NTILE, new ConstantImpl<T>(num)); }
/** * Returns true if the given String is contained * * @param str * @return this.contains(str) * @see java.lang.String#contains(CharSequence) */ public BooleanExpression contains(String str) { return contains(ConstantImpl.create(str)); }
/** * @param arg * @return */ public static <T extends Number> WithinGroup<T> percentileCont(T arg) { if (arg.doubleValue() < 0.0 || arg.doubleValue() > 1.0) { throw new IllegalArgumentException("The percentile value should be a number between 0 and 1"); } return percentileCont(new ConstantImpl<T>(arg)); }
/** * Get the index of the given substring in this String, starting from the given index * * @param str * @param i * @return this.indexOf(str, i) * @see java.lang.String#indexOf(String, int) */ public NumberExpression<Integer> indexOf(String str, int i) { return indexOf(ConstantImpl.create(str), i); }
/** * @param arg * @return */ public static <T extends Number> WithinGroup<T> percentileDisc(T arg) { if (arg.doubleValue() < 0.0 || arg.doubleValue() > 1.0) { throw new IllegalArgumentException("The percentile value should be a number between 0 and 1"); } return percentileDisc(new ConstantImpl<T>(arg)); }
/** * Get the index of the given substring in this String, starting from the given index * * @param str * @param i * @return */ public NumberExpression<Integer> indexOf(Expression<String> str, int i) { return NumberOperation.create(Integer.class, Ops.INDEX_OF_2ARGS, mixin, str, ConstantImpl.create(i)); }
@Test public void Like_as_Matches() { visitor.setLikeAsMatches(true); visitor.handle(PredicateOperation.create(Ops.LIKE, QNODE.o, new ConstantImpl(LIT.class, new LIT("x%")))); assertEquals("regex(?o, ?_c2)", visitor.toString()); assertTrue(visitor.getConstantToLabel().containsKey(new LIT("x.*"))); }
/** * Expr: {@code this like str} ignoring case. * * @param str string * @return this like string */ public BooleanExpression likeIgnoreCase(String str) { return BooleanOperation.create(Ops.LIKE_IC, mixin, ConstantImpl.create(str)); }
/** * Get the position of the given String in this String, the first position is 1 * * @param str * @return locate(str, this) */ public NumberExpression<Integer> locate(String str) { return NumberOperation.create(Integer.class, Ops.StringOps.LOCATE, ConstantImpl.create(str), mixin); }