Here you can find the source of escape(Object value)
static public String escape(Object value)
//package com.java2s; //License from project: LGPL import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class Main { static public String escape(Object value) { if (value == null) { return "NULL"; }//from w w w . j a va 2 s. co m if (Number.class.isAssignableFrom(value.getClass())) { return value.toString(); } if (Boolean.class.isAssignableFrom(value.getClass())) { return (boolean) value ? "1" : "0"; } if (jdk.nashorn.api.scripting.ScriptObjectMirror.class.isAssignableFrom(value.getClass())) { value = jdk.nashorn.api.scripting.ScriptUtils.convert(value, Object[].class); } if (List.class.isAssignableFrom(value.getClass())) { value = ((List) value).toArray(); } if (value.getClass().isArray()) { String csv = Arrays.stream((Object[]) value).distinct().map(x -> escape(x)) .collect(Collectors.joining(",")); if (csv == null || csv.equals("")) { return "null"; } return csv; } // else return "'" + value.toString().replace("'", "''") + "'"; } }