} else if (value instanceof String) { String string = (String) value; while (string != null) { int delimPosition = string.indexOf(DELIM); if (delimPosition == -1) { sb.append(string); string = null; } else { sb.append(string.substring(0, delimPosition + 3)) .append(ENCODED_DELIM); string = string.substring(delimPosition + 3); } }
    public static String render(InterMineObject obj) {        try {            StringBuffer sb = new StringBuffer();            sb.append(DELIM);            boolean needComma = false;            Iterator classIter = DynamicUtil.decomposeClass(obj.getClass()).iterator();            while (classIter.hasNext()) {                if (needComma) {                    sb.append(" ");                }                needComma = true;                Class clazz = (Class) classIter.next();                sb.append(clazz.getName());            }                        Map infos = TypeUtil.getFieldInfos(obj.getClass());            Iterator fieldIter = infos.keySet().iterator();            while (fieldIter.hasNext()) {                // If reference, value is id of referred-to object                // If field, value is field value                // If collection, no element output                // Element is not output if the value is null                String fieldName = (String) fieldIter.next();                Object value = TypeUtil.getFieldProxy(obj, fieldName);                if ((value != null) && (!Collection.class.isAssignableFrom(value.getClass()))) {                    // It is not null or a collection.                    if (value instanceof InterMineObject) {                        // Dereference ID of reference, and use that instead.                        Integer id = ((InterMineObject) value).getId();                        sb.append(DELIM)                            .append("r")                            .append(fieldName)                            .append(DELIM)                            .append(id.toString());                    } else {                        sb.append(DELIM)                            .append("a")                            .append(fieldName)                            .append(DELIM);                        if (value instanceof Date) {                            sb.append(Long.toString(((Date) value).getTime()));                        } else {                            sb.append(value.toString());                        }                    }                }            }            if (((sb.length() > 1000000) && ((1.3 * sb.length()) < sb.capacity()))                    || ((2 * sb.length()) < sb.capacity())) {                // Yes, this looks silly, but it prevents the String holding a reference to a char                // array that is up to twice the size of the String. We throw away the larger char                // array immediately anyway.                LOG.info("Converting StringBuffer (size = " + (sb.length() / 512)                        + " kB, capacity = " + (sb.capacity() / 512) + " kb) to String");                return new String(sb.toString());            }            return sb.toString();        } catch (IllegalAccessException e) {            IllegalArgumentException e2 = new IllegalArgumentException();            e2.initCause(e);            throw e2;        }    }