directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 30896 - incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber
Date Thu, 29 Jul 2004 05:01:46 GMT
Author: akarasulu
Date: Wed Jul 28 22:01:45 2004
New Revision: 30896

Modified:
   incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java
Log:
added some binary to data type conversion smarts in tooltips

Modified: incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java
==============================================================================
--- incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java
(original)
+++ incubator/directory/snickers/trunk/ber-codec/src/java/org/apache/snickers/ber/TupleTreeAnalyzer.java
Wed Jul 28 22:01:45 2004
@@ -22,6 +22,7 @@
 import org.apache.commons.codec.binary.Hex;
 import org.apache.commons.collections.IteratorUtils;
 import org.apache.snickers.ber.primitives.UniversalTag;
+import org.apache.snickers.ber.primitives.PrimitiveUtils;
 
 import javax.swing.JMenu ;
 import javax.swing.JTree ;
@@ -342,8 +343,50 @@
             ByteBuffer buf = ( ByteBuffer ) tuple.getLastValueChunk().rewind();
             byte[] bites = new byte[buf.remaining()];
             buf.get( bites );
-            jTextArea1.setText( new String( Hex.encodeHex( bites ) ) );
-            jTextArea1.setToolTipText( "String: " + new String( bites ) );
+
+            jTextArea1.setText( new String( Hex
+                    .encodeHex( bites ) ) );
+
+            if ( type == TypeClass.UNIVERSAL )
+            {
+                UniversalTag tag = UniversalTag
+                        .getUniversalTag( tuple.getRawTag() );
+
+                if ( tag == UniversalTag.ENUMERATED ||
+                        tag == UniversalTag.INTEGER )
+                {
+                    int ii = PrimitiveUtils.decodeInt( bites, 0, bites.length );
+                    jTextArea1.setToolTipText( "Numeric: "
+                            + Integer.toString( ii ) );
+                }
+                else if ( tag == UniversalTag.BOOLEAN )
+                {
+                    boolean bool = PrimitiveUtils.berDecodeBoolean( bites[0] );
+                    jTextArea1.setToolTipText( "Boolean: "
+                            + Boolean.toString( bool ) );
+                }
+                else
+                {
+                    jTextArea1.setToolTipText( "String: "
+                            + new String( bites ) );
+                }
+            }
+            else
+            {
+                if ( bites.length > 4 )
+                {
+                    jTextArea1.setToolTipText( "String: "
+                            + new String( bites ) );
+                    return;
+                }
+                
+                int ii = PrimitiveUtils.decodeInt( bites, 0, bites.length );
+                boolean bool = PrimitiveUtils.berDecodeBoolean( bites[0] );
+                String tip =  "Numeric: " + Integer.toString( ii ) + "\n";
+                tip += "Boolean: " + Boolean.toString( bool ) + "\n";
+                tip += "String: " + new String( bites ) ;
+                jTextArea1.setToolTipText( tip );
+            }
         }
         else
         {

Mime
View raw message