/** SQL {@code TRIM(... seek FROM s)} function. */ public static String trim(boolean left, boolean right, String seek, String s) { return trim(left, right, seek, s, true); }
/** SQL {@code LTRIM} function. */ public static String ltrim(String s) { return trim(true, false, " ", s); }
/** SQL {@code TRIM(... seek FROM s)} function. */ public static String trim(boolean left, boolean right, String seek, String s) { return trim(left, right, seek, s, true); }
/** SQL {@code RTRIM} function applied to string. */ public static String rtrim(String s) { return trim(false, true, " ", s); }
/** SQL {@code RTRIM} function applied to string. */ public static String rtrim(String s) { return trim(false, true, " ", s); }
/** SQL {@code LTRIM} function. */ public static String ltrim(String s) { return trim(true, false, " ", s); }
/** CAST(VARCHAR AS BOOLEAN). */ public static boolean toBoolean(String s) { s = trim(true, true, " ", s); if (s.equalsIgnoreCase("TRUE")) { return true; } else if (s.equalsIgnoreCase("FALSE")) { return false; } else { throw new RuntimeException("Invalid character for cast"); } }
static String trimSpacesBoth(String s) { return trim(true, true, " ", s); }
static String trimSpacesBoth(String s) { return trim(true, true, " ", s); }
/** CAST(VARCHAR AS BOOLEAN). */ public static boolean toBoolean(String s) { s = trim(true, true, " ", s); if (s.equalsIgnoreCase("TRUE")) { return true; } else if (s.equalsIgnoreCase("FALSE")) { return false; } else { throw RESOURCE.invalidCharacterForCast(s).ex(); } }