cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1457928 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser: ASTFalse.java ASTList.java ASTNamedParameter.java ASTNegate.java ASTNot.java ASTScalar.java ASTTrue.java
Date Mon, 18 Mar 2013 19:32:21 GMT
Author: aadamchik
Date: Mon Mar 18 19:32:21 2013
New Revision: 1457928

URL: http://svn.apache.org/r1457928
Log:
CAY-1803  Define toString() in path expressions

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTFalse.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTList.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNamedParameter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNegate.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNot.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTScalar.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTTrue.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTFalse.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTFalse.java?rev=1457928&r1=1457927&r2=1457928&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTFalse.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTFalse.java
Mon Mar 18 19:32:21 2013
@@ -18,17 +18,18 @@
  ****************************************************************/
 package org.apache.cayenne.exp.parser;
 
-import java.io.PrintWriter;
+import java.io.IOException;
 
 import org.apache.cayenne.exp.Expression;
 
 /**
  * Boolean false expression element
  * 
- * Notice that there is one ASTTrue and one ASTFalse instead of a ASTBoolean with a
- * Boolean value. The main reason for doing this is that a common ASTBoolean will have
- * operand count of 1 and that will default to a prepared statmenet like " where ? and
- * (...)", but we only need " where true and (...)".
+ * Notice that there is one ASTTrue and one ASTFalse instead of a ASTBoolean
+ * with a Boolean value. The main reason for doing this is that a common
+ * ASTBoolean will have operand count of 1 and that will default to a prepared
+ * statmenet like " where ? and (...)", but we only need " where true and
+ * (...)".
  * 
  * @see ASTTrue
  * @since 3.0
@@ -53,8 +54,7 @@ public class ASTFalse extends ConditionN
 
     @Override
     protected String getExpressionOperator(int index) {
-        throw new UnsupportedOperationException("No operator for '"
-                + ExpressionParserTreeConstants.jjtNodeName[id]
+        throw new UnsupportedOperationException("No operator for '" + ExpressionParserTreeConstants.jjtNodeName[id]
                 + "'");
     }
 
@@ -67,17 +67,20 @@ public class ASTFalse extends ConditionN
     public int getType() {
         return Expression.FALSE;
     }
-    
+
+    /**
+     * @since 3.2
+     */
     @Override
-    public void encodeAsString(PrintWriter pw) {
-        pw.print("false");
+    public void appendAsString(Appendable out) throws IOException {
+        out.append("false");
     }
-    
+
     /**
-     * @since 3.0
+     * @since 3.2
      */
     @Override
-    public void encodeAsEJBQL(PrintWriter pw, String rootId) {
-        encodeAsString(pw);
+    public void appendAsEJBQL(Appendable out, String rootId) throws IOException {
+        out.append("false");
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTList.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTList.java?rev=1457928&r1=1457927&r2=1457928&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTList.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTList.java
Mon Mar 18 19:32:21 2013
@@ -20,13 +20,11 @@
 package org.apache.cayenne.exp.parser;
 
 import java.io.IOException;
-import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.exp.Expression;
 
 /**
@@ -118,18 +116,6 @@ public class ASTList extends SimpleNode 
         out.append(')');
     }
 
-    /**
-     * @deprecated since 3.2 use {@link #appendAsString(Appendable)}
-     */
-    @Override
-    public void encodeAsString(PrintWriter pw) {
-        try {
-            appendAsString(pw);
-        } catch (IOException e) {
-            throw new CayenneRuntimeException("Unexpected IOException appending to PrintWriter",
e);
-        }
-    }
-
     @Override
     public void appendAsEJBQL(Appendable out, String rootId) throws IOException {
 
@@ -157,18 +143,6 @@ public class ASTList extends SimpleNode 
         }
     }
 
-    /**
-     * @since 3.0
-     */
-    @Override
-    public void encodeAsEJBQL(PrintWriter pw, String rootId) {
-        try {
-            appendAsEJBQL(pw, rootId);
-        } catch (IOException e) {
-            throw new CayenneRuntimeException("Unexpected IOException appending to PrintWriter",
e);
-        }
-    }
-
     @Override
     public int getOperandCount() {
         return 1;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNamedParameter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNamedParameter.java?rev=1457928&r1=1457927&r2=1457928&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNamedParameter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNamedParameter.java
Mon Mar 18 19:32:21 2013
@@ -19,7 +19,7 @@
 
 package org.apache.cayenne.exp.parser;
 
-import java.io.PrintWriter;
+import java.io.IOException;
 
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionException;
@@ -46,8 +46,7 @@ public class ASTNamedParameter extends A
 
     @Override
     protected Object evaluateNode(Object o) throws Exception {
-        throw new ExpressionException(
-            "Uninitialized parameter: " + value + ", call 'expWithParameters' first.");
+        throw new ExpressionException("Uninitialized parameter: " + value + ", call 'expWithParameters'
first.");
     }
 
     /**
@@ -73,21 +72,22 @@ public class ASTNamedParameter extends A
 
         super.setValue(new ExpressionParameter(name));
     }
-    
+
     /**
-     * @since 3.0
+     * @since 3.2
      */
     @Override
-    public void encodeAsEJBQL(PrintWriter pw, String rootId) {
-        if(value != null) {
+    public void appendAsEJBQL(Appendable out, String rootId) throws IOException {
+
+        if (value != null) {
             String valueString = value.toString();
-            if(valueString.length() > 1 && valueString.charAt(0) == '$') {
-                pw.print(':');
-                pw.print(valueString.substring(1));
+            if (valueString.length() > 1 && valueString.charAt(0) == '$') {
+                out.append(':');
+                out.append(valueString.substring(1));
                 return;
             }
         }
-        
-        super.encodeAsEJBQL(pw, rootId);
+
+        super.appendAsEJBQL(out, rootId);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNegate.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNegate.java?rev=1457928&r1=1457927&r2=1457928&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNegate.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNegate.java
Mon Mar 18 19:32:21 2013
@@ -19,7 +19,7 @@
 
 package org.apache.cayenne.exp.parser;
 
-import java.io.PrintWriter;
+import java.io.IOException;
 import java.math.BigDecimal;
 
 import org.apache.cayenne.exp.Expression;
@@ -65,57 +65,59 @@ public class ASTNegate extends SimpleNod
         return result != null ? result.negate() : null;
     }
 
+    /**
+     * @since 3.2
+     */
     @Override
-    public void encodeAsString(PrintWriter pw) {
+    public void appendAsString(Appendable out) throws IOException {
+
         if ((children != null) && (children.length > 0)) {
-            pw.print("-");
+            out.append("-");
 
             SimpleNode child = (SimpleNode) children[0];
 
             // don't call super - we have our own parenthesis policy
-            boolean useParen = parent != null
-                    && !((child instanceof ASTScalar) || (child instanceof ASTPath));
+            boolean useParen = parent != null && !((child instanceof ASTScalar) ||
(child instanceof ASTPath));
             if (useParen) {
-                pw.print("(");
+                out.append("(");
             }
 
-            child.encodeAsString(pw);
+            child.appendAsString(out);
 
             if (useParen) {
-                pw.print(')');
+                out.append(')');
             }
         }
     }
 
     /**
-     * @since 3.0
+     * @since 3.2
      */
     @Override
-    public void encodeAsEJBQL(PrintWriter pw, String rootId) {
+    public void appendAsEJBQL(Appendable out, String rootId) throws IOException {
+
         if ((children != null) && (children.length > 0)) {
-            pw.print("-");
+            out.append("-");
 
             SimpleNode child = (SimpleNode) children[0];
 
             // don't call super - we have our own parenthesis policy
-            boolean useParen = parent != null
-                    && !((child instanceof ASTScalar) || (child instanceof ASTPath));
+            boolean useParen = parent != null && !((child instanceof ASTScalar) ||
(child instanceof ASTPath));
             if (useParen) {
-                pw.print("(");
+                out.append("(");
             }
 
-            child.encodeAsEJBQL(pw, rootId);
+            child.appendAsEJBQL(out, rootId);
 
             if (useParen) {
-                pw.print(')');
+                out.append(')');
             }
         }
     }
 
     @Override
     protected String getExpressionOperator(int index) {
-        throw new UnsupportedOperationException("No operator for '"
-                + ExpressionParserTreeConstants.jjtNodeName[id]
+        throw new UnsupportedOperationException("No operator for '" + ExpressionParserTreeConstants.jjtNodeName[id]
                 + "'");
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNot.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNot.java?rev=1457928&r1=1457927&r2=1457928&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNot.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTNot.java
Mon Mar 18 19:32:21 2013
@@ -19,7 +19,7 @@
 
 package org.apache.cayenne.exp.parser;
 
-import java.io.PrintWriter;
+import java.io.IOException;
 
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.util.ConversionUtil;
@@ -52,9 +52,7 @@ public class ASTNot extends AggregateCon
             return Boolean.FALSE;
         }
 
-        return ConversionUtil.toBoolean(evaluateChild(0, o))
-                ? Boolean.FALSE
-                : Boolean.TRUE;
+        return ConversionUtil.toBoolean(evaluateChild(0, o)) ? Boolean.FALSE : Boolean.TRUE;
     }
 
     /**
@@ -70,24 +68,26 @@ public class ASTNot extends AggregateCon
         return Expression.NOT;
     }
 
+    /**
+     * @since 3.2
+     */
     @Override
-    public void encodeAsString(PrintWriter pw) {
-        pw.print("not ");
-        super.encodeAsString(pw);
+    public void appendAsString(Appendable out) throws IOException {
+        out.append("not ");
+        super.appendAsString(out);
     }
 
     /**
-     * @since 3.0
+     * @since 3.2
      */
     @Override
-    public void encodeAsEJBQL(PrintWriter pw, String rootId) {
-        encodeAsString(pw);
+    public void appendAsEJBQL(Appendable out, String rootId) throws IOException {
+        appendAsString(out);
     }
 
     @Override
     protected String getExpressionOperator(int index) {
-        throw new UnsupportedOperationException("No operator for '"
-                + ExpressionParserTreeConstants.jjtNodeName[id]
+        throw new UnsupportedOperationException("No operator for '" + ExpressionParserTreeConstants.jjtNodeName[id]
                 + "'");
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTScalar.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTScalar.java?rev=1457928&r1=1457927&r2=1457928&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTScalar.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTScalar.java
Mon Mar 18 19:32:21 2013
@@ -20,9 +20,7 @@
 package org.apache.cayenne.exp.parser;
 
 import java.io.IOException;
-import java.io.PrintWriter;
 
-import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.Persistent;
 import org.apache.cayenne.exp.Expression;
@@ -68,19 +66,6 @@ public class ASTScalar extends SimpleNod
     }
 
     /**
-     * @deprecated since 3.2 use {@link #appendAsString(Appendable)}
-     */
-    @Override
-    @Deprecated
-    public void encodeAsString(PrintWriter pw) {
-        try {
-            appendAsString(pw);
-        } catch (IOException e) {
-            throw new CayenneRuntimeException("UNexpected IOException appending to PrintWriter",
e);
-        }
-    }
-
-    /**
      * @since 3.2
      */
     @Override
@@ -89,20 +74,6 @@ public class ASTScalar extends SimpleNod
     }
 
     /**
-     * @deprecated since 3.2 use {@link #appendAsEJBQL(Appendable, String)}.
-     * @since 3.0
-     */
-    @Deprecated
-    @Override
-    public void encodeAsEJBQL(PrintWriter pw, String rootId) {
-        try {
-            appendAsEJBQL(pw, rootId);
-        } catch (IOException e) {
-            throw new CayenneRuntimeException("Unexpected IOException appending to PrintWriter",
e);
-        }
-    }
-
-    /**
      * @since 3.2
      */
     @Override

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTTrue.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTTrue.java?rev=1457928&r1=1457927&r2=1457928&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTTrue.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/ASTTrue.java
Mon Mar 18 19:32:21 2013
@@ -18,15 +18,16 @@
  ****************************************************************/
 package org.apache.cayenne.exp.parser;
 
-import java.io.PrintWriter;
+import java.io.IOException;
 
 import org.apache.cayenne.exp.Expression;
 
 /**
- * Boolean true expression element Notice that there is one ASTTrue and one ASTFalse
- * instead of a ASTBoolean with a Boolean value. The main reason for doing this is that a
- * common ASTBoolean will have operand count of 1 and that will default to a prepared
- * statmenet like " where ? and (...)", but we only need " where true and (...)".
+ * Boolean true expression element Notice that there is one ASTTrue and one
+ * ASTFalse instead of a ASTBoolean with a Boolean value. The main reason for
+ * doing this is that a common ASTBoolean will have operand count of 1 and that
+ * will default to a prepared statmenet like " where ? and (...)", but we only
+ * need " where true and (...)".
  * 
  * @see ASTFalse
  * @since 3.0
@@ -51,8 +52,7 @@ public class ASTTrue extends ConditionNo
 
     @Override
     protected String getExpressionOperator(int index) {
-        throw new UnsupportedOperationException("No operator for '"
-                + ExpressionParserTreeConstants.jjtNodeName[id]
+        throw new UnsupportedOperationException("No operator for '" + ExpressionParserTreeConstants.jjtNodeName[id]
                 + "'");
     }
 
@@ -66,16 +66,19 @@ public class ASTTrue extends ConditionNo
         return Expression.TRUE;
     }
 
+    /**
+     * @since 3.2
+     */
     @Override
-    public void encodeAsString(PrintWriter pw) {
-        pw.print("true");
+    public void appendAsString(Appendable out) throws IOException {
+        out.append("true");
     }
 
     /**
-     * @since 3.0
+     * @since 3.2
      */
     @Override
-    public void encodeAsEJBQL(PrintWriter pw, String rootId) {
-        pw.print("true");
+    public void appendAsEJBQL(Appendable out, String rootId) throws IOException {
+        out.append("true");
     }
 }



Mime
View raw message