Example usage for java.lang String toLowerCase

List of usage examples for java.lang String toLowerCase

Introduction

In this page you can find the example usage for java.lang String toLowerCase.

Prototype

public String toLowerCase() 

Source Link

Document

Converts all of the characters in this String to lower case using the rules of the default locale.

Usage

From source file:Main.java

/**
 * Find the specified occurrence of one string in another string.
 * /*from ww  w  .  j a  v  a  2s. co m*/
 * @param search
 *            The string to search.
 * @param searchFor
 *            What we are searching for.
 * @param index
 *            The occurrence to find.
 * @return The index of the specified string, or -1 if not found.
 */
public static int findOccurance(final String search, final String searchFor, final int index) {
    int count = index;
    final String lowerSearch = search.toLowerCase();
    int result = -1;

    do {
        result = lowerSearch.indexOf(searchFor, result + 1);
    } while (count-- > 0);

    return result;
}

From source file:Main.java

public static Map<String, String> toMap(Object javaBean) {
    Map<String, String> result = new HashMap<String, String>();
    Method[] methods = javaBean.getClass().getDeclaredMethods();

    for (Method method : methods) {
        try {/*from  ww  w .  j  a  v  a  2 s.c  o  m*/
            if (method.getName().startsWith("get")) {
                String field = method.getName();
                field = field.substring(field.indexOf("get") + 3);
                field = field.toLowerCase().charAt(0) + field.substring(1);

                Object value = method.invoke(javaBean, (Object[]) null);
                if (value != null) {
                    result.put(field, value.toString());
                }
            }
        } catch (Exception e) {
        }
    }

    return result;
}

From source file:Main.java

public static InputStream getStream(Context context, String url) throws IOException {
    String lowerUrl = url.toLowerCase();
    InputStream is;/*from   ww  w . ja  v a 2 s.c  o  m*/
    if (lowerUrl.startsWith(ASSETS_PREFIX)) {
        String assetPath = url.substring(ASSETS_PREFIX.length());
        is = getAssetsStream(context, assetPath);
    } else if (lowerUrl.startsWith(ASSETS_PREFIX2)) {
        String assetPath = url.substring(ASSETS_PREFIX2.length());
        is = getAssetsStream(context, assetPath);
    } else if (lowerUrl.startsWith(ASSETS_PREFIX3)) {
        String assetPath = url.substring(ASSETS_PREFIX3.length());
        is = getAssetsStream(context, assetPath);
    } else if (lowerUrl.startsWith(ASSETS_PREFIX4)) {
        String assetPath = url.substring(ASSETS_PREFIX4.length());
        is = getAssetsStream(context, assetPath);
    } else if (lowerUrl.startsWith(RAW_PREFIX)) {
        String rawName = url.substring(RAW_PREFIX.length());
        is = getRawStream(context, rawName);
    } else if (lowerUrl.startsWith(RAW_PREFIX2)) {
        String rawName = url.substring(RAW_PREFIX2.length());
        is = getRawStream(context, rawName);
    } else if (lowerUrl.startsWith(FILE_PREFIX)) {
        String filePath = url.substring(FILE_PREFIX.length());
        is = getFileStream(filePath);
    } else if (lowerUrl.startsWith(DRAWABLE_PREFIX)) {
        String drawableName = url.substring(DRAWABLE_PREFIX.length());
        is = getDrawableStream(context, drawableName);
    } else {
        throw new IllegalArgumentException(
                String.format("Unsupported url: %s \n" + "Supported: \n%sxxx\n%sxxx\n%sxxx", url, ASSETS_PREFIX,
                        RAW_PREFIX, FILE_PREFIX));
    }
    return is;
}

From source file:de.micromata.genome.gwiki.jetty.CmdLineInput.java

public static boolean ask(String message) {
    System.out.println(message);//w w w. j a  va2s .co m
    do {
        System.out.print("(Yes/No): ");
        String inp = StringUtils.trim(readLine());
        inp = inp.toLowerCase();
        if (inp.equals("y") == true || inp.equals("yes") == true) {
            return true;
        }
        if (inp.equals("n") == true || inp.equals("no") == true) {
            return false;
        }
    } while (true);
}

From source file:irille.pub.verify.RandomImageServlet.java

public static boolean support(HttpServletRequest req, String contentType) {
    String accept = getHeader(req, "accept");
    if (accept != null) {
        accept = accept.toLowerCase();
        return accept.indexOf(contentType.toLowerCase()) != -1;
    }/*from   www .  jav a 2s  .  co m*/
    return false;
}

From source file:Anagram.java

/**
 * Tests whether the passed-in strings are anagrams --
 * containing the exact same number of each letter.
 * Punctuation, case, and order don't matter.
 * //from w ww .  java 2s . c  om
 * @return true if the strings are anagrams; otherwise, false
 */
public static boolean areAnagrams(String string1, String string2) {

    String workingCopy1 = removeJunk(string1);
    String workingCopy2 = removeJunk(string2);

    workingCopy1 = workingCopy1.toLowerCase();
    workingCopy2 = workingCopy2.toLowerCase();

    workingCopy1 = sort(workingCopy1);
    workingCopy2 = sort(workingCopy2);

    return workingCopy1.equals(workingCopy2);
}

From source file:Main.java

/**
 * Draws data and returns items in array list.
 * /*from   w ww. ja  va 2  s.  com*/
 * @param list
 *            Draws data from premade list.
 * @param filter
 *            Filters data to lower case.
 * @return Returns items in the form of an array list.
 */
public static String[] filter(String[] list, String filter) {
    String[] items = new String[0];
    for (String item : list) {
        if (item.toLowerCase().contains(filter.toLowerCase())) {
            items = Arrays.copyOf(items, items.length + 1);
            items[items.length - 1] = item;
        }
    }
    return items;
}

From source file:br.com.manish.ahy.kernel.util.TextUtil.java

public static String tinyFirstLetter(String str) {
    String firstLetter = str.substring(0, 1);
    String ret = str.substring(1, str.length());
    ret = firstLetter.toLowerCase() + ret;
    return ret;//  ww  w. j  a v a 2  s .  com
}

From source file:com.technofovea.hl2parse.JxPathUtil.java

/**
 * This function performs a case-insensitive starts-with test.
 * @param s The string to examine//from w w w . j  av a  2 s . c  o m
 * @param prefix The prefix to try
 * @return True if the first string starts with the second, ignoring case.
 */
public static boolean startswith(String s, String prefix) {
    if (s == null || prefix == null) {
        return false;
    }
    return s.toLowerCase().startsWith(prefix.toLowerCase());
}

From source file:Main.java

public static String getLocalizedPokemonName(String name, Context context) {
    if (name == null || context == null) {
        return name;
    }//  ww w  .  j  a  va2  s.  co  m

    try {
        String sname = name.toLowerCase();
        int id = context.getResources().getIdentifier(sname, "string", context.getPackageName());
        return id != 0 ? context.getResources().getString(id) : name;
    } catch (Exception e) {
    }
    return name;
}