public boolean parse(CharSequence s) { boolean retval = false; int pos = eatWhite(s); if (pos + 1 < s.length()) { if (s.charAt(pos++) == '"') { StringBuffer str = new StringBuffer(""); for(; (pos < s.length()) && (s.charAt(pos) != '"');pos++) { if ((pos < s.length()) && (s.charAt(pos) == '\\')) { pos++; } str.append(s.charAt(pos)); } if (s.charAt(pos) == '"') { pos++; retval = true; value = new LiteralNode(str.toString()); } } setRemaining(s.subSequence(pos, s.length())); } return retval; } }
public void visit(LiteralNode node) { if (state == null ) return; if (!(node.getValue() instanceof Long)) { throw new IllegalArgumentException("Literal " + node + " is not supported"); } }
public OrderingSpecification getOrdering(IdNode lhs, LiteralNode rhs, String operator, int order) { if (lhs.getWidthBits() == -1 || lhs.getDivisionBits() == -1 || !(rhs.getValue() instanceof Long)) { return null; } if (operator.equals("==") || operator.equals("=")) { return new OrderingSpecification(order, (Long)rhs.getValue(), lhs.getWidthBits(), lhs.getDivisionBits()); } if (order == OrderingSpecification.ASCENDING) { if ((operator.equals("<") || operator.equals("<="))) { return new OrderingSpecification(order, 0, lhs.getWidthBits(), lhs.getDivisionBits()); } if (operator.equals(">")) { return new OrderingSpecification(order, (Long)rhs.getValue() + 1, lhs.getWidthBits(), lhs.getDivisionBits()); } if (operator.equals(">=")) { return new OrderingSpecification(order, (Long)rhs.getValue(), lhs.getWidthBits(), lhs.getDivisionBits()); } } else { if (operator.equals("<")) { return new OrderingSpecification(order, (Long)rhs.getValue() - 1, lhs.getWidthBits(), lhs.getDivisionBits()); } if (operator.equals("<=")) { return new OrderingSpecification(order, (Long)rhs.getValue(), lhs.getWidthBits(), lhs.getDivisionBits()); } } return null; }
value = new LiteralNode(v);
private BucketSet compare(BucketIdFactory factory, IdNode id, LiteralNode literal, String operator) { String field = id.getField(); Object value = literal.getValue(); if (field == null) { if (value instanceof String) {
final public ExpressionNode expression() throws ParseException {ExpressionNode ret = new LiteralNode(true); switch (jj_nt.kind) { case INTEGER:
/** * Compares a search column node with a literal node. * * @param factory The bucket id factory used. * @param node The search column node. * @param literal The literal node to compare to. * @return The bucket set containing the buckets covered. */ private BucketSet compare(BucketIdFactory factory, SearchColumnNode node, LiteralNode literal) { Object value = literal.getValue(); int bucketCount = (int) Math.pow(2, 16); if (value instanceof Long) { BucketSet ret = new BucketSet(); for (int i = 0; i < bucketCount; i++) { BucketId id = new BucketId(16, i); if ((Long)value == node.getDistribution().getColumn(id)) { ret.add(new BucketId(16, i)); } } return ret; } return null; }
throw new ParseException(); {if ("" != null) return new LiteralNode(ret);} throw new IllegalStateException ("Missing return statement in function");