directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1379499 - in /directory: apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/ shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/
Date Fri, 31 Aug 2012 16:33:56 GMT
Author: elecharny
Date: Fri Aug 31 16:33:55 2012
New Revision: 1379499

URL: http://svn.apache.org/viewvc?rev=1379499&view=rev
Log:
Added some toString() methods to pretty print the cursors, for debugging purposes

Modified:
    directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/AndCursor.java
    directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/EqualityCursor.java
    directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/OrCursor.java
    directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/AbstractCursor.java
    directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/Cursor.java

Modified: directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/AndCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/AndCursor.java?rev=1379499&r1=1379498&r2=1379499&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/AndCursor.java
(original)
+++ directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/AndCursor.java
Fri Aug 31 16:33:55 2012
@@ -243,4 +243,60 @@ public class AndCursor<V> extends Abstra
 
         return true;
     }
+
+
+    /**
+     * Dumps the evaluators
+     */
+    private String dumpEvaluators( String tabs )
+    {
+        StringBuilder sb = new StringBuilder();
+
+        for ( Evaluator<? extends ExprNode> evaluator : evaluators )
+        {
+            sb.append( tabs + "  [" );
+            sb.append( evaluator );
+            sb.append( "]\n" );
+        }
+
+        return sb.toString();
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString( String tabs )
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( tabs ).append( "AndCursor (" );
+
+        if ( available() )
+        {
+            sb.append( "available) :\n" );
+        }
+        else
+        {
+            sb.append( "absent) :\n" );
+        }
+
+        if ( ( evaluators != null ) && ( evaluators.size() > 0 ) )
+        {
+            sb.append( dumpEvaluators( tabs ) );
+        }
+
+        sb.append( wrapped.toString( tabs + "  " ) );
+
+        return sb.toString();
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return toString( "" );
+    }
 }

Modified: directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/EqualityCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/EqualityCursor.java?rev=1379499&r1=1379498&r2=1379499&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/EqualityCursor.java
(original)
+++ directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/EqualityCursor.java
Fri Aug 31 16:33:55 2012
@@ -320,4 +320,51 @@ public class EqualityCursor<V> extends A
             uuidIdxCursor.close( cause );
         }
     }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString( String tabs )
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( tabs ).append( "EqualityCursor (" );
+
+        if ( available() )
+        {
+            sb.append( "available)" );
+        }
+        else
+        {
+            sb.append( "absent)" );
+        }
+
+        sb.append( " :\n" );
+
+        sb.append( tabs + "  " ).append( equalityEvaluator ).append( '\n' );
+
+        if ( userIdxCursor != null )
+        {
+            sb.append( tabs + "  <user>\n" );
+            sb.append( userIdxCursor.toString( tabs + "    " ) );
+        }
+
+        if ( uuidIdxCursor != null )
+        {
+            sb.append( tabs + "  <uuid>\n" );
+            sb.append( userIdxCursor.toString( tabs + "  " ) );
+        }
+
+        return sb.toString();
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return toString( "" );
+    }
 }

Modified: directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/OrCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/OrCursor.java?rev=1379499&r1=1379498&r2=1379499&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/OrCursor.java
(original)
+++ directory/apacheds/branches/apacheds-mvbt/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/cursor/OrCursor.java
Fri Aug 31 16:33:55 2012
@@ -278,4 +278,82 @@ public class OrCursor<V> extends Abstrac
             cursor.close( cause );
         }
     }
+
+
+    /**
+     * Dumps the evaluators
+     */
+    private String dumpEvaluators( String tabs )
+    {
+        StringBuilder sb = new StringBuilder();
+
+        for ( Evaluator<? extends ExprNode> evaluator : evaluators )
+        {
+            sb.append( tabs + "  [" );
+            sb.append( evaluator );
+            sb.append( "]\n" );
+        }
+
+        return sb.toString();
+    }
+
+
+    /**
+     * Dumps the cursors
+     */
+    private String dumpCursors( String tabs )
+    {
+        StringBuilder sb = new StringBuilder();
+
+        for ( Cursor<IndexEntry<V, String>> cursor : cursors )
+        {
+            sb.append( cursor.toString( tabs + "  " ) );
+            sb.append( "\n" );
+        }
+
+        return sb.toString();
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString( String tabs )
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( tabs ).append( "OrCursor (" );
+
+        if ( available() )
+        {
+            sb.append( "available)" );
+        }
+        else
+        {
+            sb.append( "absent)" );
+        }
+
+        sb.append( "#" ).append( cursorIndex ).append( " : \n" );
+
+        if ( ( evaluators != null ) && ( evaluators.size() > 0 ) )
+        {
+            sb.append( dumpEvaluators( tabs ) ).append( '\n' );
+        }
+
+        if ( ( cursors != null ) && ( cursors.size() > 0 ) )
+        {
+            sb.append( dumpCursors( tabs ) ).append( '\n' );
+        }
+
+        return sb.toString();
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return toString( "" );
+    }
 }
\ No newline at end of file

Modified: directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/AbstractCursor.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/AbstractCursor.java?rev=1379499&r1=1379498&r2=1379499&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/AbstractCursor.java
(original)
+++ directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/AbstractCursor.java
Fri Aug 31 16:33:55 2012
@@ -136,4 +136,13 @@ public abstract class AbstractCursor<E> 
         throw new UnsupportedOperationException( I18n.err( I18n.ERR_02014_UNSUPPORTED_OPERATION,
getClass().getName()
             .concat( "." ).concat( "isLast()" ) ) );
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString( String tabs )
+    {
+        return tabs;
+    }
 }

Modified: directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/Cursor.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/Cursor.java?rev=1379499&r1=1379498&r2=1379499&view=diff
==============================================================================
--- directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/Cursor.java
(original)
+++ directory/shared/branches/shared-mvbt/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/cursor/Cursor.java
Fri Aug 31 16:33:55 2012
@@ -243,4 +243,12 @@ public interface Cursor<E> extends Itera
      * @param monitor the monitor to use for detecting Cursor close events
      */
     void setClosureMonitor( ClosureMonitor monitor );
+
+
+    /**
+     * Pretty-print a cursor and its wrapped cursor.
+     * @param tabs The spaces to add at each level
+     * @return The cursor and all it's wrapped elements, recursively printed
+     */
+    String toString( String tabs );
 }



Mime
View raw message