qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [1/3] qpid-jms git commit: remove 'convert strings' prefix and machinery, we dont use it
Date Tue, 03 Mar 2015 11:58:19 GMT
Repository: qpid-jms
Updated Branches:
  refs/heads/master fd2139c27 -> fa4dd26ec


remove 'convert strings' prefix and machinery, we dont use it


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/8540359c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/8540359c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/8540359c

Branch: refs/heads/master
Commit: 8540359c7b39ba2d3315c35891dc3d38f45271c1
Parents: fd2139c
Author: Robert Gemmell <robbie@apache.org>
Authored: Tue Mar 3 11:04:47 2015 +0000
Committer: Robert Gemmell <robbie@apache.org>
Committed: Tue Mar 3 11:04:47 2015 +0000

----------------------------------------------------------------------
 .../qpid/jms/selector/SelectorParser.java       | 30 +------------
 .../selector/filter/ArithmeticExpression.java   | 14 -------
 .../selector/filter/ComparisonExpression.java   | 44 +-------------------
 3 files changed, 3 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/8540359c/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/SelectorParser.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/SelectorParser.java
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/SelectorParser.java
index 87cfd6c..28b96d9 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/SelectorParser.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/SelectorParser.java
@@ -19,15 +19,12 @@ package org.apache.qpid.jms.selector;
 import java.io.StringReader;
 
 import org.apache.qpid.jms.selector.filter.BooleanExpression;
-import org.apache.qpid.jms.selector.filter.ComparisonExpression;
 import org.apache.qpid.jms.selector.filter.FilterException;
 import org.apache.qpid.jms.selector.strict.StrictParser;
 
 public class SelectorParser {
 
     private static final LRUCache<Object, Object> cache = new LRUCache<Object, Object>(100);
-    private static final String CONVERT_STRING_EXPRESSIONS_PREFIX = "convert_string_expressions:";
-    private static final String NO_CONVERT_STRING_EXPRESSIONS_PREFIX = "no_convert_string_expressions:";
 
     public static BooleanExpression parse(String sql) throws FilterException {
         Object result = cache.get(sql);
@@ -36,39 +33,16 @@ public class SelectorParser {
         } else if (result instanceof BooleanExpression) {
             return (BooleanExpression) result;
         } else {
-            String actual = sql;
-            boolean convertStringExpressions = false;
-            while (true) {
-                if (actual.startsWith(CONVERT_STRING_EXPRESSIONS_PREFIX)) {
-                    convertStringExpressions = true;
-                    actual = actual.substring(CONVERT_STRING_EXPRESSIONS_PREFIX.length());
-                    continue;
-                }
-                if (actual.startsWith(NO_CONVERT_STRING_EXPRESSIONS_PREFIX)) {
-                    convertStringExpressions = false;
-                    actual = actual.substring(NO_CONVERT_STRING_EXPRESSIONS_PREFIX.length());
-                    continue;
-                }
-                break;
-            }
-
-            if (convertStringExpressions) {
-                ComparisonExpression.CONVERT_STRING_EXPRESSIONS.set(true);
-            }
             try {
                 BooleanExpression e = null;
-                StrictParser parser = new StrictParser(new StringReader(actual));
+                StrictParser parser = new StrictParser(new StringReader(sql));
                 e = parser.JmsSelector();
                 cache.put(sql, e);
                 return e;
             } catch (Throwable e) {
-                FilterException fe = new FilterException(actual, e);
+                FilterException fe = new FilterException(sql, e);
                 cache.put(sql, fe);
                 throw fe;
-            } finally {
-                if (convertStringExpressions) {
-                    ComparisonExpression.CONVERT_STRING_EXPRESSIONS.remove();
-                }
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/8540359c/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/ArithmeticExpression.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/ArithmeticExpression.java
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/ArithmeticExpression.java
index 8aa0c25..7b8bb03 100755
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/ArithmeticExpression.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/ArithmeticExpression.java
@@ -24,7 +24,6 @@ public abstract class ArithmeticExpression extends BinaryExpression {
     protected static final int INTEGER = 1;
     protected static final int LONG = 2;
     protected static final int DOUBLE = 3;
-    boolean convertStringExpressions = false;
 
     /**
      * @param left
@@ -32,7 +31,6 @@ public abstract class ArithmeticExpression extends BinaryExpression {
      */
     public ArithmeticExpression(Expression left, Expression right) {
         super(left, right);
-        convertStringExpressions = ComparisonExpression.CONVERT_STRING_EXPRESSIONS.get()!=null;
     }
 
     public static Expression createPlus(Expression left, Expression right) {
@@ -173,18 +171,6 @@ public abstract class ArithmeticExpression extends BinaryExpression {
         if (value instanceof Number) {
             return (Number)value;
         } else {
-            if( convertStringExpressions && value instanceof String) {
-                String v = (String) value;
-                try {
-                    if( v.contains(".") ) {
-                        return new Double(v);
-                    } else {
-                        return Long.valueOf(v);
-                    }
-                } catch (NumberFormatException e) {
-                    throw new RuntimeException("Cannot convert value: " + value + " into
a number");
-                }
-            }
             throw new RuntimeException("Cannot convert value: " + value + " into a number");
         }
     }

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/8540359c/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/ComparisonExpression.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/ComparisonExpression.java
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/ComparisonExpression.java
index 1b00ce9..c52f288 100755
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/ComparisonExpression.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/selector/filter/ComparisonExpression.java
@@ -26,9 +26,6 @@ import java.util.regex.Pattern;
  */
 public abstract class ComparisonExpression extends BinaryExpression implements BooleanExpression
{
 
-    public static final ThreadLocal<Boolean> CONVERT_STRING_EXPRESSIONS = new ThreadLocal<Boolean>();
-
-    boolean convertStringExpressions = false;
     private static final Set<Character> REGEXP_CONTROL_CHARS = new HashSet<Character>();
 
     /**
@@ -37,7 +34,6 @@ public abstract class ComparisonExpression extends BinaryExpression implements
B
      */
     public ComparisonExpression(Expression left, Expression right) {
         super(left, right);
-        convertStringExpressions = CONVERT_STRING_EXPRESSIONS.get()!=null;
     }
 
     public static BooleanExpression createBetween(Expression value, Expression left, Expression
right) {
@@ -364,13 +360,7 @@ public abstract class ComparisonExpression extends BinaryExpression implements
B
         // try to convert up to allow the comparison.
         if (lc != rc) {
             try {
-                if (lc == Boolean.class) {
-                    if (convertStringExpressions && rc == String.class) {
-                        rv = Boolean.valueOf((String)rv);
-                    } else {
-                        return Boolean.FALSE;
-                    }
-                } else if (lc == Byte.class) {
+                if (lc == Byte.class) {
                     if (rc == Short.class) {
                         lv = Short.valueOf(((Number)lv).shortValue());
                     } else if (rc == Integer.class) {
@@ -381,8 +371,6 @@ public abstract class ComparisonExpression extends BinaryExpression implements
B
                         lv = new Float(((Number)lv).floatValue());
                     } else if (rc == Double.class) {
                         lv = new Double(((Number)lv).doubleValue());
-                    } else if (convertStringExpressions && rc == String.class) {
-                        rv = Byte.valueOf((String)rv);
                     } else {
                         return Boolean.FALSE;
                     }
@@ -395,8 +383,6 @@ public abstract class ComparisonExpression extends BinaryExpression implements
B
                         lv = new Float(((Number)lv).floatValue());
                     } else if (rc == Double.class) {
                         lv = new Double(((Number)lv).doubleValue());
-                    } else if (convertStringExpressions && rc == String.class) {
-                        rv = Short.valueOf((String)rv);
                     } else {
                         return Boolean.FALSE;
                     }
@@ -407,8 +393,6 @@ public abstract class ComparisonExpression extends BinaryExpression implements
B
                         lv = new Float(((Number)lv).floatValue());
                     } else if (rc == Double.class) {
                         lv = new Double(((Number)lv).doubleValue());
-                    } else if (convertStringExpressions && rc == String.class) {
-                        rv = Integer.valueOf((String)rv);
                     } else {
                         return Boolean.FALSE;
                     }
@@ -419,8 +403,6 @@ public abstract class ComparisonExpression extends BinaryExpression implements
B
                         lv = new Float(((Number)lv).floatValue());
                     } else if (rc == Double.class) {
                         lv = new Double(((Number)lv).doubleValue());
-                    } else if (convertStringExpressions && rc == String.class) {
-                        rv = Long.valueOf((String)rv);
                     } else {
                         return Boolean.FALSE;
                     }
@@ -431,8 +413,6 @@ public abstract class ComparisonExpression extends BinaryExpression implements
B
                         rv = new Float(((Number)rv).floatValue());
                     } else if (rc == Double.class) {
                         lv = new Double(((Number)lv).doubleValue());
-                    } else if (convertStringExpressions && rc == String.class) {
-                        rv = Float.valueOf((String)rv);
                     } else {
                         return Boolean.FALSE;
                     }
@@ -443,31 +423,9 @@ public abstract class ComparisonExpression extends BinaryExpression implements
B
                         rv = new Double(((Number)rv).doubleValue());
                     } else if (rc == Float.class) {
                         rv = new Double(((Number)rv).doubleValue());
-                    } else if (convertStringExpressions && rc == String.class) {
-                        rv = Double.valueOf((String)rv);
-                    } else {
-                        return Boolean.FALSE;
-                    }
-                } else if (convertStringExpressions && lc == String.class) {
-
-                    if (rc == Boolean.class) {
-                        lv = Boolean.valueOf((String)lv);
-                    } else if (rc == Byte.class) {
-                        lv = Byte.valueOf((String)lv);
-                    } else if (rc == Short.class) {
-                        lv = Short.valueOf((String)lv);
-                    } else if (rc == Integer.class) {
-                        lv = Integer.valueOf((String)lv);
-                    } else if (rc == Long.class) {
-                        lv = Long.valueOf((String)lv);
-                    } else if (rc == Float.class) {
-                        lv = Float.valueOf((String)lv);
-                    } else if (rc == Double.class) {
-                        lv = Double.valueOf((String)lv);
                     } else {
                         return Boolean.FALSE;
                     }
-
                 } else {
                     return Boolean.FALSE;
                 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message