empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1333998 - in /empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare: DBCompareAndOrExpr.java DBCompareExpr.java DBParenthesisExpr.java
Date Fri, 04 May 2012 14:42:00 GMT
Author: doebele
Date: Fri May  4 14:41:59 2012
New Revision: 1333998

URL: http://svn.apache.org/viewvc?rev=1333998&view=rev
Log:
EMPIREDB-142
custom parenthesis around and / or

Added:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
  (with props)
Modified:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareExpr.java

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java?rev=1333998&r1=1333997&r2=1333998&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java
Fri May  4 14:41:59 2012
@@ -152,5 +152,16 @@ public class DBCompareAndOrExpr extends 
     	}
     	return false;
     }
+	
+	/**
+	 * wraps the current expression with parenthesis. 
+	 * 
+	 * @return the new DBCompareColExpr object
+	 */
+	public DBCompareExpr parenthesis()
+	{
+		// create parenthesis Expression
+		return new DBParenthesisExpr(this);
+	}
     
 }
\ No newline at end of file

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareExpr.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareExpr.java?rev=1333998&r1=1333997&r2=1333998&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareExpr.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareExpr.java
Fri May  4 14:41:59 2012
@@ -37,7 +37,7 @@ public abstract class DBCompareExpr exte
 	 * @param expr the right part of the AND expression
 	 * @return the and compare expression
 	 */
-	public DBCompareExpr and(DBCompareExpr expr)
+	public DBCompareAndOrExpr and(DBCompareExpr expr)
 	{
 		// " AND "
 		return new DBCompareAndOrExpr(this, expr, false);
@@ -48,7 +48,7 @@ public abstract class DBCompareExpr exte
 	 * @param expr the right part of the OR expression
 	 * @return the or compare expression
 	 */
-	public DBCompareExpr or(DBCompareExpr expr)
+	public DBCompareAndOrExpr or(DBCompareExpr expr)
 	{
 		// " OR "
 		return new DBCompareAndOrExpr(this, expr, true);

Added: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java?rev=1333998&view=auto
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
(added)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
Fri May  4 14:41:59 2012
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.expr.compare;
+
+import java.util.Set;
+
+import org.apache.empire.db.DBColumn;
+import org.apache.empire.db.DBDatabase;
+
+/**
+ * This class wraps an existing compare expression with parenthesis.
+ * <P>
+ */
+public class DBParenthesisExpr extends DBCompareExpr
+{
+    private static final long serialVersionUID = 1L;
+    private final DBCompareExpr wrap;
+    
+    public DBParenthesisExpr(DBCompareExpr wrap)
+    {
+        this.wrap = wrap;
+    }
+
+    @Override
+    public DBDatabase getDatabase()
+    {
+        return wrap.getDatabase();
+    }
+    
+    @Override
+    public boolean isMutuallyExclusive(DBCompareExpr other)
+    {
+        return wrap.isMutuallyExclusive(other);
+    }
+
+    @Override
+    public void addReferencedColumns(Set<DBColumn> list)
+    {
+        wrap.addReferencedColumns(list);
+    }
+
+    @Override
+    public void addSQL(StringBuilder buf, long context)
+    {
+        buf.append("(");
+        wrap.addSQL(buf, context|CTX_NOPARENTHESES);
+        buf.append(")");
+    }
+}

Propchange: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message