jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r987184 - /jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/JoinType.java
Date Thu, 19 Aug 2010 15:14:11 GMT
Author: jukka
Date: Thu Aug 19 15:14:11 2010
New Revision: 987184

URL: http://svn.apache.org/viewvc?rev=987184&view=rev
Log:
JCR-2721: Add toString() methods to QOM tree classes

Add a helper method for join types.

Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/JoinType.java

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/JoinType.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/JoinType.java?rev=987184&r1=987183&r2=987184&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/JoinType.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/JoinType.java
Thu Aug 19 15:14:11 2010
@@ -30,19 +30,22 @@ import javax.jcr.query.qom.Source;
  */
 public enum JoinType {
 
-    INNER(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER),
+    INNER(QueryObjectModelConstants.JCR_JOIN_TYPE_INNER, "INNER JOIN"),
 
-    LEFT(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER),
+    LEFT(QueryObjectModelConstants.JCR_JOIN_TYPE_LEFT_OUTER, "LEFT OUTER JOIN"),
 
-    RIGHT(QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER);
+    RIGHT(QueryObjectModelConstants.JCR_JOIN_TYPE_RIGHT_OUTER, "RIGHT OUTER JOIN");
 
     /**
      * JCR name of this join type.
      */
     private final String name;
 
-    private JoinType(String name) {
+    private final String sql;
+
+    private JoinType(String name, String sql) {
         this.name = name;
+        this.sql = sql;
     }
 
     /**
@@ -63,6 +66,20 @@ public enum JoinType {
     }
 
     /**
+     * Formats an SQL join with this join type and the given sources and
+     * join condition. The sources and condition are simply used as-is,
+     * without any quoting or escaping.
+     *
+     * @param left left source
+     * @param right right source
+     * @param condition join condition
+     * @return SQL join, <code>left join right</code>
+     */
+    public String formatSql(Object left, Object right, Object condition) {
+        return left + " " + sql + " " + right + " ON " + condition;
+    }
+
+    /**
      * Returns the JCR 2.0 name of this join type.
      *
      * @see QueryObjectModelConstants



Mime
View raw message