List of usage examples for org.apache.commons.lang3 StringUtils equalsIgnoreCase
public static boolean equalsIgnoreCase(final CharSequence str1, final CharSequence str2)
Compares two CharSequences, returning true if they represent equal sequences of characters, ignoring case.
null s are handled without exceptions.
From source file:com.seavus.wordcountermaven.WordCounter.java
/** * @param args the command line arguments * @throws java.io.FileNotFoundException *//*from www . j av a 2 s.c om*/ public static void main(String[] args) throws FileNotFoundException { InputStream fileStream = WordCounter.class.getClassLoader().getResourceAsStream("test.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(fileStream)); Map<String, Integer> wordMap = new HashMap<>(); String line; boolean tokenFound = false; try { while ((line = br.readLine()) != null) { String[] tokens = line.trim().split("\\s+"); //trims surrounding whitespaces and splits lines into tokens for (String token : tokens) { for (Map.Entry<String, Integer> entry : wordMap.entrySet()) { if (StringUtils.equalsIgnoreCase(token, entry.getKey())) { wordMap.put(entry.getKey(), (wordMap.get(entry.getKey()) + 1)); tokenFound = true; } } if (!token.equals("") && !tokenFound) { wordMap.put(token.toLowerCase(), 1); } tokenFound = false; } } br.close(); } catch (IOException ex) { Logger.getLogger(WordCounter.class.getName()).log(Level.SEVERE, null, ex); } System.out.println("string : " + "frequency\r\n" + "-------------------"); //prints out each unique word (i.e. case-insensitive string token) and its frequency to the console for (Map.Entry<String, Integer> entry : wordMap.entrySet()) { System.out.println(entry.getKey() + " : " + entry.getValue()); } }
From source file:com.mirth.connect.donkey.model.channel.DeployedState.java
public static DeployedState fromString(String value) { for (DeployedState state : values()) { if (StringUtils.equalsIgnoreCase(state.toString(), value)) { return state; }//from w w w .jav a2s. c o m } return null; }
From source file:com.nesscomputing.syslog4j.SyslogLevel.java
public static final SyslogLevel forName(final String name) { for (SyslogLevel level : values()) { if (StringUtils.equalsIgnoreCase(level.name(), name)) { return level; }/* w w w. jav a2s . c o m*/ } return null; }
From source file:com.omnigon.aem.common.utils.LocaleUtils.java
public static boolean isValidAndNonEnglish(Locale locale) { return locale != null && StringUtils.isNotBlank(locale.getLanguage()) && !StringUtils.equalsIgnoreCase(Locale.ENGLISH.getLanguage(), locale.getLanguage()); }
From source file:com.nesscomputing.syslog4j.SyslogFacility.java
public static final SyslogFacility forName(final String name) { for (SyslogFacility facility : values()) { if (StringUtils.equalsIgnoreCase(facility.name(), name)) { return facility; }// ww w .ja v a2s .c o m } return null; }
From source file:fr.scc.elo.model.elo.EloType.java
public static EloType fromName(String eloType) throws EloTypeNotFoundException { for (EloType elo : EloType.values()) { if (StringUtils.equalsIgnoreCase(eloType, elo.toString())) { return elo; }/* w ww . j a v a 2s. c om*/ } throw new EloTypeNotFoundException(); }
From source file:com.galenframework.util.DriverTestFactory.java
/** * Instantiate a new WebDriver instance, respects GalenConfig * /* www .j a va 2s.c om*/ * @see GalenConfig * @return a new instance of the desired WebDriver */ public static WebDriver getDriver() { WebDriver driver = null; if (StringUtils.equalsIgnoreCase(GalenConfig.getConfig().getDefaultBrowser(), "chrome")) { driver = new ChromeDriver(); } else { if (StringUtils.equalsIgnoreCase(GalenConfig.getConfig().getDefaultBrowser(), "safari")) { driver = new SafariDriver(); } else { if (StringUtils.equalsIgnoreCase(GalenConfig.getConfig().getDefaultBrowser(), "iexplore")) { driver = new InternetExplorerDriver(); } else { // default to firefox driver = new FirefoxDriver(); } } } return driver; }
From source file:com.inkubator.hrm.web.search.BankGroupSearchParameter.java
public String getCode() { if (StringUtils.equalsIgnoreCase(getKeyParam(), "code")) { code = getParameter();/*from www. j a va 2s . co m*/ } else { code = null; } return code; }
From source file:com.qcadoo.view.constants.Alignment.java
public static Alignment parseString(final String stringValue) { for (Alignment value : Alignment.values()) { if (StringUtils.equalsIgnoreCase(value.getStringValue(), stringValue)) { return value; }/* ww w . j av a 2 s .co m*/ } throw new IllegalArgumentException(String.format("Can't parse Alignment from string '%s'", stringValue)); }
From source file:com.inkubator.hrm.web.search.BatchJobExecutionSearchParameter.java
public String getJobName() { if (StringUtils.equalsIgnoreCase(getKeyParam(), "jobName")) { jobName = getParameter();/* w ww . j a v a 2 s.c o m*/ } else { jobName = null; } return jobName; }