[armedbear-cvs] r13277 - trunk/abcl/src/org/armedbear/lisp

mevenson at common-lisp.net mevenson at common-lisp.net
Sat Jun 4 20:25:02 UTC 2011


Author: mevenson
Date: Tue May 17 03:51:30 2011
New Revision: 13277

Log:
JAVA:*JAVA-OBJECT-TO-STRING-LENGTH* controls pretty print length.

The default of 32 characters is the length beyond which the toString()
output from which an otherwise unspecialized JAVA-OBJECT elides its
representation.

Changed the character sequence indicating elision from "..." to "...."
to avoid confusing the user that any of the pretty printer variables
are responsible for an elision.

Setting this variable to NIL disables truncation of any kind.

Modified:
   trunk/abcl/src/org/armedbear/lisp/JavaObject.java

Modified: trunk/abcl/src/org/armedbear/lisp/JavaObject.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/JavaObject.java	Tue May 17 03:51:08 2011	(r13276)
+++ trunk/abcl/src/org/armedbear/lisp/JavaObject.java	Tue May 17 03:51:30 2011	(r13277)
@@ -331,6 +331,20 @@
         return obj == null ? 0 : (obj.hashCode() & 0x7ffffff);
     }
 
+    public static LispObject JAVA_OBJECT_TO_STRING_LENGTH 
+        = LispInteger.getInstance(32);
+
+    public static final Symbol _JAVA_OBJECT_TO_STRING_LENGTH 
+        = exportSpecial("*JAVA-OBJECT-TO-STRING-LENGTH*", 
+                        PACKAGE_JAVA, JAVA_OBJECT_TO_STRING_LENGTH);
+
+    static {
+        String doc = "Length to truncate toString() PRINT-OBJECT output for an otherwise "
+                  +  "unspecialized JAVA-OBJECT.  Can be set to NIL to indicate no limit.";
+        _JAVA_OBJECT_TO_STRING_LENGTH
+            .setDocumentation(Symbol.VARIABLE, new SimpleString(doc));
+    }
+
     @Override
     public String writeToString()
     {
@@ -343,8 +357,16 @@
                 = new StringBuilder(c.isArray() ? "jarray" : c.getName());
             sb.append(' ');
             String ts = obj.toString();
-            if(ts.length() > 32) { //random value, should be chosen sensibly
-                sb.append(ts.substring(0, 32) + "...");
+            int length = -1;
+            LispObject stringLength = _JAVA_OBJECT_TO_STRING_LENGTH.symbolValueNoThrow();
+            if (stringLength instanceof Fixnum) {
+                length = Fixnum.getValue(stringLength);
+            }
+            if (length < 0) {
+                sb.append(ts);
+            }else if (ts.length() > length) { 
+                // use '....' to not confuse user with PPRINT conventions
+                sb.append(ts.substring(0, length)).append("...."); 
             } else {
                 sb.append(ts);
             }




More information about the armedbear-cvs mailing list