public static BooleanExpression createLike(Expression left, String right, String escape) { if (escape != null && escape.length() != 1) { throw new RuntimeException("The ESCAPE string literal is invalid. It can only be one character. Literal used: " + escape); } int c = -1; if (escape != null) { c = 0xFFFF & escape.charAt(0); } return new LikeExpression(left, right, c); }
/** */ LikeExpression(Expression right, String like, int escape) { super(right); StringBuffer regexp = new StringBuffer(like.length() * 2); regexp.append("\\A"); // The beginning of the input for (int i = 0; i < like.length(); i++) { char c = like.charAt(i); if (escape == (0xFFFF & c) && shouldEscapeNext(like, i, c)) { i++; char t = like.charAt(i); regexp.append("\\x"); regexp.append(Integer.toHexString(0xFFFF & t)); } else { append(regexp, c); } } regexp.append("\\z"); // The end of the input likePattern = Pattern.compile(regexp.toString(), Pattern.DOTALL); }
/** * @see org.apache.activemq.filter.Expression#evaluate(Filterable) */ @Override public Object evaluate(Filterable message) throws FilterException { Object rv = this.getRight().evaluate(message); if (rv == null) { return null; } if (!(rv instanceof String)) { return Boolean.FALSE; // throw new RuntimeException("LIKE can only operate on String // identifiers. LIKE attempted on: '" + rv.getClass()); } return likePattern.matcher((String) rv).matches() ? Boolean.TRUE : Boolean.FALSE; }
/** */ LikeExpression(Expression right, String like, int escape) { super(right); StringBuffer regexp = new StringBuffer(like.length() * 2); regexp.append("\\A"); // The beginning of the input for (int i = 0; i < like.length(); i++) { char c = like.charAt(i); if (escape == (0xFFFF & c) && shouldEscapeNext(like, i, c)) { i++; char t = like.charAt(i); regexp.append("\\x"); regexp.append(Integer.toHexString(0xFFFF & t)); } else { append(regexp, c); } } regexp.append("\\z"); // The end of the input likePattern = Pattern.compile(regexp.toString(), Pattern.DOTALL); }
/** */ LikeExpression(Expression right, String like, int escape) { super(right); StringBuffer regexp = new StringBuffer(like.length() * 2); regexp.append("\\A"); // The beginning of the input for (int i = 0; i < like.length(); i++) { char c = like.charAt(i); if (escape == (0xFFFF & c) && shouldEscapeNext(like, i, c)) { i++; char t = like.charAt(i); regexp.append("\\x"); regexp.append(Integer.toHexString(0xFFFF & t)); } else { append(regexp, c); } } regexp.append("\\z"); // The end of the input likePattern = Pattern.compile(regexp.toString(), Pattern.DOTALL); }
/** */ LikeExpression(Expression right, String like, int escape) { super(right); StringBuffer regexp = new StringBuffer(like.length() * 2); regexp.append("\\A"); // The beginning of the input for (int i = 0; i < like.length(); i++) { char c = like.charAt(i); if (escape == (0xFFFF & c) && shouldEscapeNext(like, i, c)) { i++; char t = like.charAt(i); regexp.append("\\x"); regexp.append(Integer.toHexString(0xFFFF & t)); } else { append(regexp, c); } } regexp.append("\\z"); // The end of the input likePattern = Pattern.compile(regexp.toString(), Pattern.DOTALL); }
/** */ LikeExpression(Expression right, String like, int escape) { super(right); StringBuffer regexp = new StringBuffer(like.length() * 2); regexp.append("\\A"); // The beginning of the input for (int i = 0; i < like.length(); i++) { char c = like.charAt(i); if (escape == (0xFFFF & c) && shouldEscapeNext(like, i, c)) { i++; char t = like.charAt(i); regexp.append("\\x"); regexp.append(Integer.toHexString(0xFFFF & t)); } else { append(regexp, c); } } regexp.append("\\z"); // The end of the input likePattern = Pattern.compile(regexp.toString(), Pattern.DOTALL); }
/** */ LikeExpression(Expression right, String like, int escape) { super(right); StringBuffer regexp = new StringBuffer(like.length() * 2); regexp.append("\\A"); // The beginning of the input for (int i = 0; i < like.length(); i++) { char c = like.charAt(i); if (escape == (0xFFFF & c) && shouldEscapeNext(like, i, c)) { i++; char t = like.charAt(i); regexp.append("\\x"); regexp.append(Integer.toHexString(0xFFFF & t)); } else { append(regexp, c); } } regexp.append("\\z"); // The end of the input likePattern = Pattern.compile(regexp.toString(), Pattern.DOTALL); }
/** * @see org.apache.activemq.filter.Expression#evaluate(Filterable) */ @Override public Object evaluate(Filterable message) throws FilterException { Object rv = this.getRight().evaluate(message); if (rv == null) { return null; } if (!(rv instanceof String)) { return Boolean.FALSE; // throw new RuntimeException("LIKE can only operate on String // identifiers. LIKE attempted on: '" + rv.getClass()); } return likePattern.matcher((String) rv).matches() ? Boolean.TRUE : Boolean.FALSE; }
/** * @see org.apache.activemq.filter.Expression#evaluate(Filterable) */ @Override public Object evaluate(Filterable message) throws FilterException { Object rv = this.getRight().evaluate(message); if (rv == null) { return null; } if (!(rv instanceof String)) { return Boolean.FALSE; // throw new RuntimeException("LIKE can only operate on String // identifiers. LIKE attempted on: '" + rv.getClass()); } return likePattern.matcher((String) rv).matches() ? Boolean.TRUE : Boolean.FALSE; }
/** * @see org.apache.activemq.filter.Expression#evaluate(Filterable) */ @Override public Object evaluate(Filterable message) throws FilterException { Object rv = this.getRight().evaluate(message); if (rv == null) { return null; } if (!(rv instanceof String)) { return Boolean.FALSE; // throw new RuntimeException("LIKE can only operate on String // identifiers. LIKE attempted on: '" + rv.getClass()); } return likePattern.matcher((String) rv).matches() ? Boolean.TRUE : Boolean.FALSE; }
/** * @see org.apache.activemq.filter.Expression#evaluate(Filterable) */ @Override public Object evaluate(Filterable message) throws FilterException { Object rv = this.getRight().evaluate(message); if (rv == null) { return null; } if (!(rv instanceof String)) { return Boolean.FALSE; // throw new RuntimeException("LIKE can only operate on String // identifiers. LIKE attempted on: '" + rv.getClass()); } return likePattern.matcher((String) rv).matches() ? Boolean.TRUE : Boolean.FALSE; }
/** * @see org.apache.activemq.filter.Expression#evaluate(Filterable) */ @Override public Object evaluate(Filterable message) throws FilterException { Object rv = this.getRight().evaluate(message); if (rv == null) { return null; } if (!(rv instanceof String)) { return Boolean.FALSE; // throw new RuntimeException("LIKE can only operate on String // identifiers. LIKE attempted on: '" + rv.getClass()); } return likePattern.matcher((String) rv).matches() ? Boolean.TRUE : Boolean.FALSE; }
public static BooleanExpression createLike(Expression left, String right, String escape) { if (escape != null && escape.length() != 1) { throw new RuntimeException("The ESCAPE string literal is invalid. It can only be one character. Literal used: " + escape); } int c = -1; if (escape != null) { c = 0xFFFF & escape.charAt(0); } return new LikeExpression(left, right, c); }
public static BooleanExpression createLike(Expression left, String right, String escape) { if (escape != null && escape.length() != 1) { throw new RuntimeException("The ESCAPE string literal is invalid. It can only be one character. Literal used: " + escape); } int c = -1; if (escape != null) { c = 0xFFFF & escape.charAt(0); } return new LikeExpression(left, right, c); }
@Override public boolean matches(Filterable message) throws FilterException { Object object = evaluate(message); return object == Boolean.TRUE; } }
public static BooleanExpression createLike(Expression left, String right, String escape) { if (escape != null && escape.length() != 1) { throw new RuntimeException("The ESCAPE string literal is invalid. It can only be one character. Literal used: " + escape); } int c = -1; if (escape != null) { c = 0xFFFF & escape.charAt(0); } return new LikeExpression(left, right, c); }
@Override public boolean matches(Filterable message) throws FilterException { Object object = evaluate(message); return object == Boolean.TRUE; } }
@Override public boolean matches(Filterable message) throws FilterException { Object object = evaluate(message); return object == Boolean.TRUE; } }
@Override public boolean matches(Filterable message) throws FilterException { Object object = evaluate(message); return object == Boolean.TRUE; } }