List of usage examples for java.lang String toLowerCase
public String toLowerCase()
From source file:Main.java
public static void operate(String status) { // Check for null if (status == null) { System.out.println("status cannot be null."); return;// w ww .j av a 2 s . c om } status = status.toLowerCase(); switch (status) { case "on": System.out.println("Turn on"); break; case "off": System.out.println("Turn off"); break; default: System.out.println("Unknown command"); break; } }
From source file:Main.java
/** * Decapitalize a name.//from www. j a va 2s. co m * @param name * @return a decapitalized name */ public static String decapitalizeName(String name) { if (name.length() == 0) { return name; } else { String lowerName = name.toLowerCase(); int i; for (i = 0; i < name.length(); i++) { if (name.charAt(i) == lowerName.charAt(i)) { break; } } if (i > 1 && i < name.length()) { --i; } return name.substring(0, i).toLowerCase() + name.substring(i); } }
From source file:cuchaz.m3l.util.OperatingSystem.java
public static OperatingSystem get(String name) { // these names are from Minecraft's json files name = name.toLowerCase(); if (name.equals("windows") || name.equals("win")) { return Windows; } else if (name.equals("osx") || name.equals("mac")) { return Osx; } else if (name.equals("linux")) { return Linux; } else {/*from w ww .j a v a 2 s . co m*/ return null; } }
From source file:Main.java
/** * Returns a {@code Class} object that identifies the * declared class as a return type for the method represented by the given * {@code String name} parameter inside the invoked {@code Class<?> clazz} parameter. * * @param clazz the {@code Class} object whose declared methods to be * checked for the wanted method name. * @param name the method name as {@code String} to be * compared with {@link Method#getName()} * @return the {@code Class} object representing the return type of the given method name. * * @see {@link Class#getDeclaredMethods()} * @see {@link Method#getReturnType()}/*from w w w. j a v a 2 s.c o m*/ */ public static Class<?> getMethodReturnType(Class<?> clazz, String name) { if (clazz == null || name == null || name.isEmpty()) { return null; } name = name.toLowerCase(); Class<?> returnType = null; for (Method method : clazz.getDeclaredMethods()) { if (method.getName().equals(name)) { returnType = method.getReturnType(); break; } } return returnType; }
From source file:Main.java
/** * Returns a more practical audio resource name. E.g. if * http://stream.com/stream.pls is given, the PLS-file is parsed and the * first audio file is returned. It supports PLS, M3U, AXS and XSPF" * //w w w . j a va2 s .c o m * @param inputResource * The input resource, a file, URL, PLS-file or M3U-file. * * @return A more practical audio resource name. */ public static String sanitizeResource(String inputResource) { if (inputResource.toLowerCase().endsWith("pls")) { inputResource = parsePLS(inputResource); } else if (inputResource.toLowerCase().endsWith("m3u")) { inputResource = parseM3U(inputResource); } else if (inputResource.toLowerCase().endsWith("asx")) { inputResource = parseASX(inputResource); } else if (inputResource.toLowerCase().endsWith("xspf")) { inputResource = parseXSPF(inputResource); } return inputResource; }
From source file:Main.java
/** * Parses a time period into a long./*from w ww . ja v a 2 s.c om*/ * * Translates possible [msec|sec|min|h] suffixes * * For example: * "1" -> 1 (msec) * "1msec -> 1 (msec) * "1sec" -> 1000 (msecs) * "1min" -> 60000 (msecs) * "1h" -> 3600000 (msecs) * * Accepts negative periods, e.g. "-1" * * @param period the stringfied time period * @return the parsed time period as long * @throws NumberFormatException */ public static long parseTimePeriod(String period) { try { String s = period.toLowerCase(); long factor; // look for suffix if (s.endsWith("msec")) { s = s.substring(0, s.lastIndexOf("msec")); factor = MSEC; } else if (s.endsWith("sec")) { s = s.substring(0, s.lastIndexOf("sec")); factor = SECS; } else if (s.endsWith("min")) { s = s.substring(0, s.lastIndexOf("min")); factor = MINS; } else if (s.endsWith("h")) { s = s.substring(0, s.lastIndexOf("h")); factor = HOUR; } else { factor = 1; } return Long.parseLong(s) * factor; } catch (RuntimeException e) { // thrown in addition when period is 'null' throw new NumberFormatException("For input time period: '" + period + "'"); } }
From source file:io.cloudslang.content.utilities.services.PdfParseService.java
public static String getOccurrences(final String pdfContent, final String text, boolean ignoreCase) { if (ignoreCase) return valueOf(countMatches(pdfContent.toLowerCase(), text.toLowerCase())); return valueOf(countMatches(pdfContent, text)); }
From source file:Main.java
public static boolean startsWith(String s, String prefix, boolean ignoreCase) { if (s != null && prefix != null) { if (ignoreCase) { return s.toLowerCase().startsWith(prefix.toLowerCase()); } else {/*w w w .j av a2s .c o m*/ return s.startsWith(prefix); } } return s == null && prefix == null; }
From source file:Main.java
public static boolean hasValue(Map<?, ?> map, String key, String val) { if (map == null) { return false; }/*from w ww . jav a2 s . c o m*/ Collection<?> col = (Collection<?>) map.get(key); if (col == null) { return false; } Iterator<?> itr = col.iterator(); while (itr.hasNext()) { String str = (String) itr.next(); if (str.equalsIgnoreCase(val)) { return true; } if (str.toLowerCase().startsWith(val)) { return true; } } return false; }
From source file:com.sp.keyword_generator.Keyword.java
public static String stripAccents(String s) { s = StringUtils.replaceEachRepeatedly(s.toLowerCase(), InputReplace, OutputReplace); s = StringEscapeUtils.escapeSql(s);/*from w ww. j a v a2 s.com*/ s = Normalizer.normalize(s.toLowerCase(), Normalizer.Form.NFD); return s; }