@Test public void testSplitCanonicalTableName() throws Exception { String[] elements = TableUtil.splitCanonicalTableName("aaa.bbb.ccc"); assertEquals(3, elements.length); assertEquals("aaa", elements[0]); assertEquals("bbb", elements[1]); assertEquals("ccc", elements[2]); elements = TableUtil.splitCanonicalTableName("bbb.ccc"); assertEquals(3, elements.length); assertEquals(null, elements[0]); assertEquals("bbb", elements[1]); assertEquals("ccc", elements[2]); elements = TableUtil.splitCanonicalTableName("aaa..ccc"); assertEquals(3, elements.length); assertEquals("aaa", elements[0]); assertEquals(null, elements[1]); assertEquals("ccc", elements[2]); elements = TableUtil.splitCanonicalTableName("ccc"); assertEquals(3, elements.length); assertEquals(null, elements[0]); assertEquals(null, elements[1]); assertEquals("ccc", elements[2]); }
public static String[] splitCanonicalTableName(String canonicalTableName) { List<String> list = new ArrayList<String>(); int pos = 0; for (int i = 0; i < canonicalTableName.length(); i++) { char c = canonicalTableName.charAt(i); if (c == '.') { list.add(canonicalTableName.substring(pos, i)); pos = i + 1; } } list.add(canonicalTableName.substring(pos)); String[] elements = new String[3]; if (list.size() == 3) { for (int i = 0; i < 3; i++) { if (!StringUtil.isEmpty(list.get(i))) { elements[i] = list.get(i); } } } else if (list.size() == 2) { for (int i = 0; i < 2; i++) { if (!StringUtil.isEmpty(list.get(i))) { elements[i + 1] = list.get(i); } } } else if (list.size() == 1) { elements[2] = list.get(0); } else { throw new IllegalArgumentException(canonicalTableName); } return elements; }
TableUtil { public static String[] splitCanonicalTableName(String canonicalTableName) { List<String> list = new ArrayList<String>(); int pos = 0; for (int i = 0; i < canonicalTableName.length(); i++) { char c = canonicalTableName.charAt(i); if (c == '.') { list.add(canonicalTableName.substring(pos, i)); pos = i + 1; } } list.add(canonicalTableName.substring(pos)); String[] elements = new String[3]; if (list.size() == 3) { for (int i = 0; i < 3; i++) { if (!StringUtil.isEmpty(list.get(i))) { elements[i] = list.get(i); } } } else if (list.size() == 2) { for (int i = 0; i < 2; i++) { if (!StringUtil.isEmpty(list.get(i))) { elements[i + 1] = list.get(i); } } } else if (list.size() == 1) { elements[2] = list.get(0); } else { throw new IllegalArgumentException(canonicalTableName); } return elements; } }
TableUtil { public static String[] splitCanonicalTableName(String canonicalTableName) { List<String> list = new ArrayList<String>(); int pos = 0; for (int i = 0; i < canonicalTableName.length(); i++) { char c = canonicalTableName.charAt(i); if (c == '.') { list.add(canonicalTableName.substring(pos, i)); pos = i + 1; } } list.add(canonicalTableName.substring(pos)); String[] elements = new String[3]; if (list.size() == 3) { for (int i = 0; i < 3; i++) { if (!StringUtil.isEmpty(list.get(i))) { elements[i] = list.get(i); } } } else if (list.size() == 2) { for (int i = 0; i < 2; i++) { if (!StringUtil.isEmpty(list.get(i))) { elements[i + 1] = list.get(i); } } } else if (list.size() == 1) { elements[2] = list.get(0); } else { throw new IllegalArgumentException(canonicalTableName); } return elements; } protected  TableUtil(); }
TableUtil { public static String[] splitCanonicalTableName(String canonicalTableName) { List<String> list = new ArrayList<String>(); int pos = 0; for (int i = 0; i < canonicalTableName.length(); i++) { char c = canonicalTableName.charAt(i); if (c == '.') { list.add(canonicalTableName.substring(pos, i)); pos = i + 1; } } list.add(canonicalTableName.substring(pos)); String[] elements = new String[3]; if (list.size() == 3) { for (int i = 0; i < 3; i++) { if (!StringUtil.isEmpty(list.get(i))) { elements[i] = list.get(i); } } } else if (list.size() == 2) { for (int i = 0; i < 2; i++) { if (!StringUtil.isEmpty(list.get(i))) { elements[i + 1] = list.get(i); } } } else if (list.size() == 1) { elements[2] = list.get(0); } else { throw new IllegalArgumentException(canonicalTableName); } return elements; } protected  TableUtil(); static TableSet getTableSet(GenDialect dialect, DataSource dataSource); static String buildCanonicalTableName(GenDialect dialect,
            String catalogName, String schemaName, String tableName); static String buildFullTableName(String catalogName,
            String schemaName, String tableName); static String[] splitCanonicalTableName(String canonicalTableName); }
TableUtil { public static String[] splitCanonicalTableName(String canonicalTableName) { List<String> list = new ArrayList<String>(); int pos = 0; for (int i = 0; i < canonicalTableName.length(); i++) { char c = canonicalTableName.charAt(i); if (c == '.') { list.add(canonicalTableName.substring(pos, i)); pos = i + 1; } } list.add(canonicalTableName.substring(pos)); String[] elements = new String[3]; if (list.size() == 3) { for (int i = 0; i < 3; i++) { if (!StringUtil.isEmpty(list.get(i))) { elements[i] = list.get(i); } } } else if (list.size() == 2) { for (int i = 0; i < 2; i++) { if (!StringUtil.isEmpty(list.get(i))) { elements[i + 1] = list.get(i); } } } else if (list.size() == 1) { elements[2] = list.get(0); } else { throw new IllegalArgumentException(canonicalTableName); } return elements; } protected  TableUtil(); static TableSet getTableSet(GenDialect dialect, DataSource dataSource); static String buildCanonicalTableName(GenDialect dialect,
            String catalogName, String schemaName, String tableName); static String buildFullTableName(String catalogName,
            String schemaName, String tableName); static String[] splitCanonicalTableName(String canonicalTableName);  }