Creates a FormattedString for the given object.
506632
public static FormattedString of( String format, Object object)
    {
    return
      object == null?
      new Null() :
      
      "binary".equals( format)?
      new Base64( (byte[]) object) :
      
      "byte".equals( format)?
      new Base64( (byte[]) object) :
      
      "date".equals( format)?
      new Date( (java.util.Date) object) :
      
      "date-time".equals( format)?
      new DateTime( (java.util.Date) object) :
      
      "uuid".equals( format)?
      new Uuid( (UUID) object) :
      
      new Native( object);
    }
411598
def _ToString(x):
    """"""
    # Some cross-language values for primitives.  This is tested in
    # jsontemplate_test.py.
    if x is None:
        return 'null'
    if isinstance(x, six.string_types):
        return x
    return pprint.pformat(x)
328134
String objectsToString(String key, Object objects) {
        java.io.StringWriter stringWriter = new java.io.StringWriter();
        stringWriter.write(key);
        stringWriter.write(":");

        if (objects == null) {
            stringWriter.write("\n");

        } else if (objects instanceof Object[]) {
            for (int i = 0; i < ((Object[]) objects).length; i++) {
                Object object = ((Object[]) objects)[i];
                if (object == null)
                    stringWriter.write("null\n");
                else {
                    stringWriter.write(((Object[]) objects)[i].toString());
                    stringWriter.write("\n");
                }
            }

        } else {
            stringWriter.write(objects.toString());
            stringWriter.write("\n");
        }

        return stringWriter.toString();
    }
943092
function format (obj, sub) {
    var x = utils.clone(obj);
    if (x) {
        if ('Binary' === x.constructor.name) {
            x = '[object Buffer]';
        } else if ('ObjectID' === x.constructor.name) {
            var representation = 'ObjectId("' + x.toHexString() + '")';
            x = { inspect: function() { return representation; } };
        } else if ('Date' === x.constructor.name) {
            var representation = 'new Date("' + x.toUTCString() + '")';
            x = { inspect: function() { return representation; } };
        } else if ('Object' === x.constructor.name) {
            var keys = Object.keys(x)
                , i = keys.length
                , key
            while (i--) {
                key = keys[i];
                if (x[key]) {
                    if ('Binary' === x[key].constructor.name) {
                        x[key] = '[object Buffer]';
                    } else if ('Object' === x[key].constructor.name) {
                        x[key] = format(x[key], true);
                    } else if ('ObjectID' === x[key].constructor.name) {
                        ;(function(x){
                            var representation = 'ObjectId("' + x[key].toHexString() + '")';
                            x[key] = { inspect: function() { return representation; } };
                        })(x)
                    } else if ('Date' === x[key].constructor.name) {
                        ;(function(x){
                            var representation = 'new Date("' + x[key].toUTCString() + '")';
                            x[key] = { inspect: function() { return representation; } };
                        })(x)
                    } else if (Array.isArray(x[key])) {
                        x[key] = x[key].map(function (o) {
                            return format(o, true)
                        });
                    }
                }
            }
        }
        if (sub) return x;
    }

    return require('util')
        .inspect(x, false, 10, true)
        .replace(/\n/g, '')
        .replace(/\s{2,}/g, ' ')
}
565481
@Override
	public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) {
		return toAppendTo.append(printer.format(obj));
	}
1128832
private static Writable getWritableFromObject(Object object) {

        Writable writable = null;

        if (object instanceof String) {

            writable = new Text(object.toString());

        } else if (object instanceof Long) {

            writable = new LongWritable((Long) object);

        } else {

            writable = new IntWritable((Integer) object);

        }
        // writable = writable!=null?writable:new Text("");
        return writable;
    }
1357322
function string(obj) {
  if ('function' === typeof obj) {
    return obj.toString();
  } else if (obj instanceof Date) {
    return 'new Date("' + obj + '")';
  } else if (Array.isArray(obj)) {
    return '[' + obj.map(string).join(', ') + ']';
  } else if ('[object Object]' === Object.prototype.toString.call(obj)) {
    return '{' + Object.keys(obj).map(function(key){
      return '"' + key + '":' + string(obj[key]);
    }).join(', ') + '}';
  } else {
    return JSON.stringify(obj);
  }
}
1344764
function format (obj) {
  if (!obj || typeof obj !== 'object') {
    throw new TypeError('argument obj is required')
  }

  var parameters = obj.parameters
  var type = obj.type

  if (!type || !TYPE_REGEXP.test(type)) {
    throw new TypeError('invalid type')
  }

  var string = type

  // append parameters
  if (parameters && typeof parameters === 'object') {
    var param
    var params = Object.keys(parameters).sort()

    for (var i = 0; i < params.length; i++) {
      param = params[i]

      if (!TOKEN_REGEXP.test(param)) {
        throw new TypeError('invalid parameter name')
      }

      string += '; ' + param + '=' + qstring(parameters[param])
    }
  }

  return string
}
524099
public static Object formatL(final String template, final Object... args) {
    return new Object() {
      @Override
      public String toString() {
        return format(template, args);
      }
    };
  }
239700
public static String display(Object object) {
        StringBuilder builder = new StringBuilder();
        displayRecursive(object, builder, new Stack<>(), false);
        return builder.toString();
    }
1366310
private String dataToString( Object data ) {
        if ( data == null ) return "<null>";
        return ( data instanceof Scriptable ) ? ScriptableUtils.toString((Scriptable) data)
                                              : Objects.toString(data);
    }
524464
@SuppressWarnings("unchecked")
    private static String converter(String fieldName, Object object) {
        StringBuilder builder = new StringBuilder();
        if (Checker.isNotEmpty(fieldName)) {
            builder.append("\"").append(fieldName).append("\":");
        }
        if (object instanceof Collection) {
            List list = (List) object;
            builder.append("[");
            list.forEach(obj -> builder.append(converter(ValueConsts.EMPTY_STRING, obj)));
            return builder.substring(0, builder.length() - 1) + "],";
        } else if (object instanceof Map) {
            Map map = (Map) object;
            builder.append("{");
            map.forEach((k, v) -> builder.append(converter(k.toString(), v)));
            return builder.substring(0, builder.length() - 1) + "},";
        } else if (Checker.isEmpty(fieldName)) {
            builder.append("\"").append(object).append("\",");
        } else {
            builder.append("\"").append(object).append("\",");
        }
        return builder.toString();
    }
445904
public static StringBuffer startToString(final Object object) {

        StringBuffer buffer = new StringBuffer("[");
        buffer.append(object.getClass().getName());
        buffer.append("@");
        buffer.append(Integer.toHexString(System.identityHashCode(object)));
        return buffer;

    }
716196
private String _serialize(Object object, Map<Object, String> done) throws ConverterException {

	type = "OBJECT";

	String rtn;
	deep++;
	// NULL
	if (object == null) {
	    rtn = goIn() + "";
	    deep--;
	    type = "NULL";
	    return rtn;
	}
	// String
	if (object instanceof String) {
	    rtn = goIn() + XMLUtil.escapeXMLString(object.toString());
	    deep--;
	    type = "STRING";
	    return rtn;
	}
	// Number
	if (object instanceof Number) {
	    rtn = goIn() + ((Number) object).doubleValue();
	    deep--;
	    type = "NUMBER";
	    return rtn;
	}
	// Boolean
	if (object instanceof Boolean) {
	    rtn = goIn() + ((Boolean) object).booleanValue();
	    deep--;
	    type = "BOOLEAN";
	    return rtn;
	}
	// DateTime
	if (object instanceof DateTime) {
	    rtn = _serializeDateTime((DateTime) object);
	    deep--;
	    type = "DATE";
	    return rtn;
	}
	// Date
	if (object instanceof Date) {
	    rtn = _serializeDate((Date) object);
	    deep--;
	    type = "DATE";
	    return rtn;
	}

	Object raw = LazyConverter.toRaw(object);
	String strId = done.get(raw);
	if (strId != null) {
	    rtn = goIn() + "<REF id=\"" + strId + "\"\\>";
	    deep--;
	    type = "NULL";
	    return rtn;
	}
	strId = Caster.toString(++this.id);
	done.put(raw, strId);
	try {
	    // Component
	    if (object instanceof Component) {
		rtn = _serializeComponent((Component) object, done);
		deep--;
		return rtn;
	    }
	    // Struct
	    if (object instanceof Struct) {
		rtn = _serializeStruct((Struct) object, done, strId);
		deep--;
		return rtn;
	    }
	    // Map
	    if (object instanceof Map) {
		rtn = _serializeMap((Map) object, done);
		deep--;
		return rtn;
	    }
	    // Array
	    if (object instanceof Array) {
		rtn = _serializeArray((Array) object, done, strId);
		deep--;
		return rtn;
	    }
	    // List
	    if (object instanceof List) {
		rtn = _serializeList((List) object, done, strId);
		deep--;
		return rtn;
	    }
	    // Query
	    if (object instanceof Query) {
		rtn = _serializeQuery((Query) object, done, strId);
		deep--;
		return rtn;
	    }
	}
	finally {
	    done.remove(raw);
	}
	// Others
	rtn = "<STRUCT ID=\"" + strId + "\" TYPE=\"" + Caster.toTypeName(object) + "\"></STRUCT>";
	deep--;
	return rtn;
    }
750210
static String toFormattedString(final String iban) {
        final StringBuilder ibanBuffer = new StringBuilder(iban);
        final int length = ibanBuffer.length();

        for (int i = 0; i < length / 4; i++) {
            ibanBuffer.insert((i + 1) * 4 + i, ' ');
        }

        return ibanBuffer.toString().trim();
    }
1371337
private String format(Object o) {
        return shellSession.format(o, Converter.INSPECT).toString();
    }
44809
public String objectToString(Object object) {
        DimIProxy action = new DimIProxy(this, IPROXY_OBJECT_TO_STRING);
        action.object = object;
        action.withContext();
        return action.stringResult;
    }