@Test public void getQuotedIdentifierTest () { Assert.assertEquals ("abc", SchemaUtils.getQuotedIdentifier ("abc", " ")); Assert.assertEquals ("abc", SchemaUtils.getQuotedIdentifier ("abc", null)); Assert.assertEquals ("abc", SchemaUtils.getQuotedIdentifier ("abc", "")); Assert.assertEquals ("\"abc\"", SchemaUtils.getQuotedIdentifier ("abc", "\"")); Assert.assertEquals ("\"a\"\"b\"", SchemaUtils.getQuotedIdentifier ("a\"b", "\"")); Assert.assertEquals ("\"\"\"ab\"\"\"", SchemaUtils.getQuotedIdentifier ("\"ab\"", "\"")); Assert.assertEquals ("\"\"\"\"", SchemaUtils.getQuotedIdentifier ("\"", "\"")); }
public static String getQuotedIdentifier (String name, String quote) { if (quote == null || quote.length () == 0 || " ".equals (quote)) return name; if (name.indexOf (quote) < 0 || quote.length () != 1) return quote + name + quote; char ch = quote.charAt (0); StringBuilder builder = new StringBuilder (); builder.append (ch); int start = 0; int len = name.length (); int index; while (start < len && (index = name.indexOf (ch, start)) >= 0) { builder.append (name.substring (start, index)); builder.append (ch).append (ch); start = index + 1; } if (start < len) { builder.append (name.substring (start)); } builder.append (ch); return builder.toString (); }
SchemaUtils { public static String getQuotedIdentifier (String name, String quote) { if (quote == null || quote.length () == 0 || " ".equals (quote)) return name; if (name.indexOf (quote) < 0 || quote.length () != 1) return quote + name + quote; char ch = quote.charAt (0); StringBuilder builder = new StringBuilder (); builder.append (ch); int start = 0; int len = name.length (); int index; while (start < len && (index = name.indexOf (ch, start)) >= 0) { builder.append (name.substring (start, index)); builder.append (ch).append (ch); start = index + 1; } if (start < len) { builder.append (name.substring (start)); } builder.append (ch); return builder.toString (); } }
SchemaUtils { public static String getQuotedIdentifier (String name, String quote) { if (quote == null || quote.length () == 0 || " ".equals (quote)) return name; if (name.indexOf (quote) < 0 || quote.length () != 1) return quote + name + quote; char ch = quote.charAt (0); StringBuilder builder = new StringBuilder (); builder.append (ch); int start = 0; int len = name.length (); int index; while (start < len && (index = name.indexOf (ch, start)) >= 0) { builder.append (name.substring (start, index)); builder.append (ch).append (ch); start = index + 1; } if (start < len) { builder.append (name.substring (start)); } builder.append (ch); return builder.toString (); }  }
SchemaUtils { public static String getQuotedIdentifier (String name, String quote) { if (quote == null || quote.length () == 0 || " ".equals (quote)) return name; if (name.indexOf (quote) < 0 || quote.length () != 1) return quote + name + quote; char ch = quote.charAt (0); StringBuilder builder = new StringBuilder (); builder.append (ch); int start = 0; int len = name.length (); int index; while (start < len && (index = name.indexOf (ch, start)) >= 0) { builder.append (name.substring (start, index)); builder.append (ch).append (ch); start = index + 1; } if (start < len) { builder.append (name.substring (start)); } builder.append (ch); return builder.toString (); }  static String getQuotedIdentifier(String name, String quote); static String getTableSchema(JaqyHelper helper, SchemaInfo schemaInfo, String tableName, boolean exact); static JaqyResultSet getSchemaResultSet(JaqyHelper helper, SchemaInfo schemaInfo, boolean exact, JaqyInterpreter interpreter); static TypeMap getTypeMap(JaqyConnection conn); }
SchemaUtils { public static String getQuotedIdentifier (String name, String quote) { if (quote == null || quote.length () == 0 || " ".equals (quote)) return name; if (name.indexOf (quote) < 0 || quote.length () != 1) return quote + name + quote; char ch = quote.charAt (0); StringBuilder builder = new StringBuilder (); builder.append (ch); int start = 0; int len = name.length (); int index; while (start < len && (index = name.indexOf (ch, start)) >= 0) { builder.append (name.substring (start, index)); builder.append (ch).append (ch); start = index + 1; } if (start < len) { builder.append (name.substring (start)); } builder.append (ch); return builder.toString (); }  static String getQuotedIdentifier(String name, String quote); static String getTableSchema(JaqyHelper helper, SchemaInfo schemaInfo, String tableName, boolean exact); static JaqyResultSet getSchemaResultSet(JaqyHelper helper, SchemaInfo schemaInfo, boolean exact, JaqyInterpreter interpreter); static TypeMap getTypeMap(JaqyConnection conn);  }