/** * @return The StringMatchers compiled from #getFilterLocalesStringMatcher() */ public synchronized StringMatcher[] getFilterLocalesStringMatchers() { if (cachedCompiledLocaleFilter != null) { return cachedCompiledLocaleFilter; } String pref = PREFS.getString(FILTER_LOCALES_STRING_MATCHERS); StringTokenizer tokenizer = new StringTokenizer(pref, ";, ", false); cachedCompiledLocaleFilter = new StringMatcher[tokenizer.countTokens()]; int ii = 0; while (tokenizer.hasMoreTokens()) { StringMatcher pattern = new StringMatcher(tokenizer.nextToken().trim(), true, false); cachedCompiledLocaleFilter[ii] = pattern; ii++; } return cachedCompiledLocaleFilter; }
/** * @param locale * @return true if the locale is selected by the local-filter defined in the rpeferences * @see MsgEditorPreferences#getFilterLocalesStringMatcher() */ public static boolean isDisplayed(Locale locale) { if (ROOT_LOCALE.equals(locale) || locale == null) { return true; } StringMatcher[] patterns = MsgEditorPreferences.getInstance().getFilterLocalesStringMatchers(); if (patterns == null || patterns.length == 0) { return true; } String locStr = locale.toString(); for (int i = 0; i < patterns.length; i++) { if (patterns[i].match(locStr)) { return true; } } return false; }
public void setFilter(String pattern, boolean ignoreCase, boolean ignoreWildCards) { fMatcher = new StringMatcher('*'+pattern + '*', ignoreCase, ignoreWildCards); }