Changeset 13277


Ignore:
Timestamp:
05/17/11 10:51:30 (10 years ago)
Author:
Mark Evenson
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/JavaObject.java

    r13276 r13277  
    332332    }
    333333
     334    public static LispObject JAVA_OBJECT_TO_STRING_LENGTH
     335        = LispInteger.getInstance(32);
     336
     337    public static final Symbol _JAVA_OBJECT_TO_STRING_LENGTH
     338        = exportSpecial("*JAVA-OBJECT-TO-STRING-LENGTH*",
     339                        PACKAGE_JAVA, JAVA_OBJECT_TO_STRING_LENGTH);
     340
     341    static {
     342        String doc = "Length to truncate toString() PRINT-OBJECT output for an otherwise "
     343                  +  "unspecialized JAVA-OBJECT.  Can be set to NIL to indicate no limit.";
     344        _JAVA_OBJECT_TO_STRING_LENGTH
     345            .setDocumentation(Symbol.VARIABLE, new SimpleString(doc));
     346    }
     347
    334348    @Override
    335349    public String writeToString()
     
    344358            sb.append(' ');
    345359            String ts = obj.toString();
    346             if(ts.length() > 32) { //random value, should be chosen sensibly
    347                 sb.append(ts.substring(0, 32) + "...");
     360            int length = -1;
     361            LispObject stringLength = _JAVA_OBJECT_TO_STRING_LENGTH.symbolValueNoThrow();
     362            if (stringLength instanceof Fixnum) {
     363                length = Fixnum.getValue(stringLength);
     364            }
     365            if (length < 0) {
     366                sb.append(ts);
     367            }else if (ts.length() > length) {
     368                // use '....' to not confuse user with PPRINT conventions
     369                sb.append(ts.substring(0, length)).append("....");
    348370            } else {
    349371                sb.append(ts);
Note: See TracChangeset for help on using the changeset viewer.