directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r111893 - in incubator/directory/snickers/trunk: ber/src/java/org/apache/snickers/ber ber/src/java/org/apache/snickers/ber/digester ber/src/test/org/apache/snickers/ber codec/src/java/org/apache/snickers/codec/stateful
Date Tue, 14 Dec 2004 22:51:32 GMT
Author: akarasulu
Date: Tue Dec 14 14:51:29 2004
New Revision: 111893

URL: http://svn.apache.org/viewcvs?view=rev&rev=111893
Log:
Changes ...

 o took out superfluous System.out lines
 o added new VisitorMonitor for some lines for tracking what a visitor does

These changes close the following JIRA task:

http://nagoya.apache.org/jira/browse/DIRSNICKERS-97


Added:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/VisitorMonitor.java
Modified:
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/DeterminateLengthVisitor.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleEncodingVisitor.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleNodeVisitor.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java
   incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/TagTree.java
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java
   incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java
   incubator/directory/snickers/trunk/codec/src/java/org/apache/snickers/codec/stateful/EncoderMonitorAdapter.java

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/DeterminateLengthVisitor.java
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/DeterminateLengthVisitor.java?view=diff&rev=111893&p1=incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/DeterminateLengthVisitor.java&r1=111892&p2=incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/DeterminateLengthVisitor.java&r2=111893
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/DeterminateLengthVisitor.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/DeterminateLengthVisitor.java
Tue Dec 14 14:51:29 2004
@@ -30,6 +30,10 @@
  */
 public class DeterminateLengthVisitor implements TupleNodeVisitor
 {
+    /** the visitor monitor called when notible events occur */
+    private VisitorMonitor monitor = VisitorMonitor.NOOP;
+
+
     /**
      * Visits a tree of tuple nodes using a specific visitation order.
      *
@@ -69,7 +73,7 @@
         }
 
         node.getTuple().setValueLength( length );
-        System.out.println( node );
+        monitor.visited( this, node );
     }
 
 
@@ -108,5 +112,11 @@
     public ArrayList getOrder( TupleNode node, ArrayList children )
     {
         return children;
+    }
+
+
+    public void setMonitor( VisitorMonitor monitor )
+    {
+        this.monitor = monitor;
     }
 }

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleEncodingVisitor.java
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleEncodingVisitor.java?view=diff&rev=111893&p1=incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleEncodingVisitor.java&r1=111892&p2=incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleEncodingVisitor.java&r2=111893
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleEncodingVisitor.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleEncodingVisitor.java
Tue Dec 14 14:51:29 2004
@@ -44,6 +44,9 @@
     /** The List storing the ByteBuffers collected during a visitation */
     private ArrayList buffers = new ArrayList();
 
+    /** The visitor monitor used by this TupleNodeVisitor */
+    private VisitorMonitor visitorMonitor = VisitorMonitor.NOOP;
+
 
     // ------------------------------------------------------------------------
     // TupleNodeVisitor Implemenations
@@ -112,6 +115,7 @@
          * length of 0.
          *
          */
+        visitorMonitor.visited( this, node );
     }
 
 
@@ -162,5 +166,11 @@
         ByteBuffer[] array = ( ByteBuffer [] ) buffers.toArray( EMPTY_ARRAY );
         buffers.clear();
         super.encodeOccurred( array );
+    }
+
+
+    public void setMonitor( VisitorMonitor monitor )
+    {
+        visitorMonitor = monitor;
     }
 }

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleNodeVisitor.java
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleNodeVisitor.java?view=diff&rev=111893&p1=incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleNodeVisitor.java&r1=111892&p2=incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleNodeVisitor.java&r2=111893
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleNodeVisitor.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleNodeVisitor.java
Tue Dec 14 14:51:29 2004
@@ -38,8 +38,8 @@
  * </ul>
  *
  * @see TupleNode#accept(TupleNodeVisitor)
- * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
- *         Project</a> $Rev$
+ * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory Project</a>
+ * @version $Rev$
  */
 public interface TupleNodeVisitor
 {
@@ -75,4 +75,12 @@
      * @return the new reordered array of children
      */
     ArrayList getOrder( TupleNode node, ArrayList children ) ;
+
+    /**
+     * Sets the monitoring which recieves callbacks of notable events from
+     * this visitor.
+     *
+     * @param monitor the monitor instance for the visitor
+     */
+    void setMonitor( VisitorMonitor monitor );
 }

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java?view=diff&rev=111893&p1=incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java&r1=111892&p2=incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java&r2=111893
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java
Tue Dec 14 14:51:29 2004
@@ -324,7 +324,7 @@
     /** Exit the Application */
     private void exitForm(WindowEvent evt)
     {
-        System.out.println("Closing window: " + evt.getWindow().getName());
+        System.out.println( "Closed window: " + evt.getWindow().getName() );
 
         if ( doVmExit )
         {

Added: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/VisitorMonitor.java
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/VisitorMonitor.java?view=auto&rev=111893
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/VisitorMonitor.java
Tue Dec 14 14:51:29 2004
@@ -0,0 +1,39 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.snickers.ber;
+
+
+/**
+ * A callback interface used to monitor the activities of a tuple node visitor.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface VisitorMonitor
+{
+    /** The do nothing visitor monitor */
+    VisitorMonitor NOOP = new VisitorMonitor() {
+        public void visited( TupleNodeVisitor v, TupleNode n ) {} };
+
+    /**
+     * Notifies that a node has been visited.
+     *
+     * @param visitor the visitor visiting the node
+     * @param node the not that has already been visited
+     */
+    void visited( TupleNodeVisitor visitor, TupleNode node );
+}

Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/TagTree.java
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/TagTree.java?view=diff&rev=111893&p1=incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/TagTree.java&r1=111892&p2=incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/TagTree.java&r2=111893
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/TagTree.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/digester/TagTree.java
Tue Dec 14 14:51:29 2004
@@ -329,10 +329,6 @@
             {
                 node.addRule( rule ) ;
             }
-
-            System.out.println( rule + " already contained in node "
-                    + node + " found at path " + stack
-                    + " so we're not adding it again" ) ;
         }
 
         if ( ! node.isLeaf() )

Modified: incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java?view=diff&rev=111893&p1=incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java&r1=111892&p2=incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java&r2=111893
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/EncodeDecodeTests.java
Tue Dec 14 14:51:29 2004
@@ -54,8 +54,6 @@
         buf.get( snaccBytes );
 
         String snaccEncoded = new String( Hex.encodeHex( snaccBytes ) ) ;
-        System.out.println( "snacc encoded = [" + snaccEncoded + "][" 
-                + snaccBytes.length + "]" ) ;
 
         // @todo replace this with the Snickers encoder or use serialized
         // PDUs stubs for test cases rather than decoding live.
@@ -65,14 +63,11 @@
                 new ByteArrayInputStream( snaccBytes ) ) ;
         assertTrue( msg.getMessageId() == request.getMessageId() ) ;
         
-        System.out.println( "snacc decoded = " + msg ) ;
-        
-        root = ( DefaultMutableTupleNode ) 
+        root = ( DefaultMutableTupleNode )
             TupleTreeDecoder.treeDecode( ByteBuffer.wrap( snaccBytes ) ) ;
         
         if ( root == null )
         {
-            System.out.println( "nothing decoded" ) ;
             return ;
         }
         
@@ -105,22 +100,17 @@
         buf.get( snaccBytes );
 
         String snaccEncoded = new String( Hex.encodeHex( snaccBytes ) ) ;
-        System.out.println( "snacc encoded = [" + snaccEncoded + "]["
-                + snaccBytes.length + "]" ) ;
 
         MessageDecoder decoder = new MessageDecoder( env ) ;
         BindRequest msg = ( BindRequest ) decoder.decode( null,
                 new ByteArrayInputStream( snaccBytes ) ) ;
         assertTrue( msg.getMessageId() == request.getMessageId() ) ;
 
-        System.out.println( "snacc decoded = " + msg ) ;
-
         root = ( DefaultMutableTupleNode )
                 TupleTreeDecoder.treeDecode( ByteBuffer.wrap( snaccBytes ) ) ;
 
         if ( root == null )
         {
-            System.out.println( "nothing decoded" ) ;
             return ;
         }
 
@@ -132,6 +122,5 @@
 
         StringBuffer sb = new StringBuffer() ;
         root.printDepthFirst( sb, 0 ) ;
-        System.out.println( sb.toString() ) ;
     }
 }

Modified: incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java?view=diff&rev=111893&p1=incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java&r1=111892&p2=incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java&r2=111893
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java
(original)
+++ incubator/directory/snickers/trunk/ber/src/test/org/apache/snickers/ber/TupleTreeDecoderTest.java
Tue Dec 14 14:51:29 2004
@@ -113,11 +113,8 @@
         decoder.decode( ByteBuffer.wrap( out.toByteArray() ) ) ;
         watch.stop() ;
 
-        System.out.println( "time for decode = " + watch.getTime() ) ;
-
         StringBuffer buf = new StringBuffer() ;
         root.printDepthFirst( buf, 0 ) ;
-        System.out.println( "tuple tlv tree =\n" + buf.toString() ) ;
     }
     
     

Modified: incubator/directory/snickers/trunk/codec/src/java/org/apache/snickers/codec/stateful/EncoderMonitorAdapter.java
Url: http://svn.apache.org/viewcvs/incubator/directory/snickers/trunk/codec/src/java/org/apache/snickers/codec/stateful/EncoderMonitorAdapter.java?view=diff&rev=111893&p1=incubator/directory/snickers/trunk/codec/src/java/org/apache/snickers/codec/stateful/EncoderMonitorAdapter.java&r1=111892&p2=incubator/directory/snickers/trunk/codec/src/java/org/apache/snickers/codec/stateful/EncoderMonitorAdapter.java&r2=111893
==============================================================================
--- incubator/directory/snickers/trunk/codec/src/java/org/apache/snickers/codec/stateful/EncoderMonitorAdapter.java
(original)
+++ incubator/directory/snickers/trunk/codec/src/java/org/apache/snickers/codec/stateful/EncoderMonitorAdapter.java
Tue Dec 14 14:51:29 2004
@@ -25,6 +25,9 @@
  */
 public class EncoderMonitorAdapter implements EncoderMonitor
 {
+    /** Use this if you don't want to recreate this as just a NOOP monitor */
+    public EncoderMonitorAdapter INSTANCE = new EncoderMonitorAdapter();
+
     /**
      * Receive notification of a recoverable error.  This callback is used to
      * denote a failure to handle a unit of data to be encoded or decoded.  The

Mime
View raw message