public Filter(String filter, boolean extended) throws IllegalArgumentException { this.filter = filter; this.extended = extended; this.tail = filter; if (filter == null || filter.length() == 0) throw new IllegalArgumentException("Null query"); Node node = null; Exception parseException = null; try { node = new Query().doQuery(); if (tail.length() > 0) error(GARBAGE); } catch (Exception e) { parseException = e; } this.node = node; this.parseException = parseException; }
public Filter(String filter, boolean extended) throws IllegalArgumentException { this.filter = filter; this.extended = extended; this.tail = filter; if (filter == null || filter.length() == 0) throw new IllegalArgumentException("Null query"); Node node = null; Exception parseException = null; try { node = new Query().doQuery(); if (tail.length() > 0) error(GARBAGE); } catch (Exception e) { parseException = e; } this.node = node; this.parseException = parseException; }
public Filter(String filter, boolean extended) throws IllegalArgumentException { this.filter = filter; this.extended = extended; this.tail = filter; if (filter == null || filter.length() == 0) throw new IllegalArgumentException("Null query"); Node node = null; Exception parseException = null; try { node = new Query().doQuery(); if (tail.length() > 0) error(GARBAGE); } catch (Exception e) { parseException = e; } this.node = node; this.parseException = parseException; }
private Node doOr() throws Exception { tail = skip(1); boolean val = false; if (!tail.startsWith("(")) error(EMPTY); Or or = new Or(); do { or.children.add(doQuery()); } while (tail.startsWith("(")); return or; }
private Node doAnd() throws Exception { tail = skip(1); boolean val = true; if (!tail.startsWith("(")) error(EMPTY); And and = new And(); do { and.children.add(doQuery()); } while (tail.startsWith("(")); return and; }
private Node doAnd() throws Exception { tail = skip(1); boolean val = true; if (!tail.startsWith("(")) error(EMPTY); And and = new And(); do { and.children.add(doQuery()); } while (tail.startsWith("(")); return and; }
private Node doOr() throws Exception { tail = skip(1); boolean val = false; if (!tail.startsWith("(")) error(EMPTY); Or or = new Or(); do { or.children.add(doQuery()); } while (tail.startsWith("(")); return or; }
private Node doAnd() throws Exception { tail = skip(1); boolean val = true; if (!tail.startsWith("(")) error(EMPTY); And and = new And(); do { and.children.add(doQuery()); } while (tail.startsWith("(")); return and; }
private Node doOr() throws Exception { tail = skip(1); boolean val = false; if (!tail.startsWith("(")) error(EMPTY); Or or = new Or(); do { or.children.add(doQuery()); } while (tail.startsWith("(")); return or; }
private Node doNot() throws Exception { tail = skip(1); if (!tail.startsWith("(")) error(SUBEXPR); return new Not(doQuery()); }
private Node doNot() throws Exception { tail = skip(1); if (!tail.startsWith("(")) error(SUBEXPR); return new Not(doQuery()); }
private Node doNot() throws Exception { tail = skip(1); if (!tail.startsWith("(")) error(SUBEXPR); return new Not(doQuery()); }
private Node doQuery() throws Exception { if (tail.length() < 3 || !prefix("(")) error(MALFORMED); Node val; switch (tail.charAt(0)) { case '&' : val = doAnd(); break; case '|' : val = doOr(); break; case '!' : val = doNot(); break; default : val = doSimple(); break; } if (!prefix(")")) error(MALFORMED); return val; }
private Node doQuery() throws Exception { if (tail.length() < 3 || !prefix("(")) error(MALFORMED); Node val; switch (tail.charAt(0)) { case '&' : val = doAnd(); break; case '|' : val = doOr(); break; case '!' : val = doNot(); break; default : val = doSimple(); break; } if (!prefix(")")) error(MALFORMED); return val; }
private Node doQuery() throws Exception { if (tail.length() < 3 || !prefix("(")) error(MALFORMED); Node val; switch (tail.charAt(0)) { case '&' : val = doAnd(); break; case '|' : val = doOr(); break; case '!' : val = doNot(); break; default : val = doSimple(); break; } if (!prefix(")")) error(MALFORMED); return val; }
Node doSimple() throws Exception { int op = 0; String key = getKey(); if (prefix("=")) op = EQ; else if (prefix("<=")) op = LE; else if (prefix(">=")) op = GE; else if (prefix("~=")) op = APPROX; else if (extended && prefix("!=")) op = NEQ; else if (extended && prefix(">")) op = GT; else if (extended && prefix("<")) op = LT; else error(OPERATOR); return new Simple(key, op, getValue()); }
Node doSimple() throws Exception { int op = 0; String key = getKey(); if (prefix("=")) op = EQ; else if (prefix("<=")) op = LE; else if (prefix(">=")) op = GE; else if (prefix("~=")) op = APPROX; else if (extended && prefix("!=")) op = NEQ; else if (extended && prefix(">")) op = GT; else if (extended && prefix("<")) op = LT; else error(OPERATOR); return new Simple(key, op, getValue()); }
Node doSimple() throws Exception { int op = 0; String key = getKey(); if (prefix("=")) op = EQ; else if (prefix("<=")) op = LE; else if (prefix(">=")) op = GE; else if (prefix("~=")) op = APPROX; else if (extended && prefix("!=")) op = NEQ; else if (extended && prefix(">")) op = GT; else if (extended && prefix("<")) op = LT; else error(OPERATOR); return new Simple(key, op, getValue()); }