ExternalDataUtil { public static String toSafeColumnName(String columnName, Map<String, String> cache) { String cachedName = cache.get(columnName); if (cachedName == null) { String safeColumnName = toSafeColumnName(columnName); cache.put(columnName, safeColumnName); return safeColumnName; } else { return cachedName; } } private  ExternalDataUtil(); static String toSafeColumnName(String columnName, Map<String, String> cache); static String toSafeColumnName(String columnName); static List<String> findMatchingColumnsAfterSafeningNames(String[] columnNames); static XPathFuncExpr getSearchXPathExpression(String appearance); static ArrayList<SelectChoice> populateExternalChoices(FormEntryPrompt formEntryPrompt,
            XPathFuncExpr xpathfuncexpr); static LinkedHashMap<String, String> createMapWithDisplayingColumns(String valueColumn,
            String displayColumns); static List<String> createListOfColumns(String columnString); static boolean containsAnyData(String[] row); static String[] fillUpNullValues(String[] row, String[] headerRow); static String nullSafe(String value); static boolean isAnInteger(String value); static final String EXTERNAL_DATA_TABLE_NAME; static final String EXTERNAL_METADATA_TABLE_NAME; static final String SORT_COLUMN_NAME; static final String COLUMN_DATASET_FILENAME; static final String COLUMN_MD5_HASH; static final Pattern SEARCH_FUNCTION_REGEX; static final String JR_IMAGES_PREFIX; }
@Test public void testSafeColumnName() { Assert.assertEquals("c_", ExternalDataUtil.toSafeColumnName("")); Assert.assertEquals("c_simplename", ExternalDataUtil.toSafeColumnName("simplename")); Assert.assertEquals("c_camelcase", ExternalDataUtil.toSafeColumnName("CamelCase")); Assert.assertEquals("c_trailingwhitespace", ExternalDataUtil.toSafeColumnName("trailingwhitespace ")); Assert.assertEquals("c_leadingwhitespace", ExternalDataUtil.toSafeColumnName(" leadingwhitespace")); Assert.assertEquals("c_middle_whitespace", ExternalDataUtil.toSafeColumnName("middle whitespace")); Assert.assertEquals("c_0123456789", ExternalDataUtil.toSafeColumnName("0123456789")); Assert.assertEquals("c_a_b", ExternalDataUtil.toSafeColumnName("a*b")); Assert.assertEquals("c_new_line", ExternalDataUtil.toSafeColumnName("new\nline")); Assert.assertEquals("c_double_quote", ExternalDataUtil.toSafeColumnName("double\"quote")); }