List of usage examples for java.lang String equalsIgnoreCase
public boolean equalsIgnoreCase(String anotherString)
From source file:Main.java
/** * This method creates a map of all of the childern of a node * @param root - Parent node//from w w w .j a v a2 s . c o m * @return HashMap key value map of the children of the parent node */ public static HashMap getMap(Node root) { HashMap map = new HashMap(); if (root != null) { NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); String nodeName = child.getNodeName(); if (!nodeName.equalsIgnoreCase("#comment") && !nodeName.equalsIgnoreCase("#text")) { if (child.getChildNodes().getLength() > 1) { map.put(nodeName, child); } else { Node textChild = child.getFirstChild(); if (textChild == null) { map.put(nodeName, null); } else { map.put(nodeName, child.getFirstChild().getNodeValue()); } } } } } return map; }
From source file:Main.java
public static boolean selectBooleanAttribute(Element parent, String attrName) { String result = selectStringAttribute(parent, attrName, "0"); if (result.equalsIgnoreCase("1") || result.equalsIgnoreCase("true")) { return true; }/*ww w . ja v a 2 s. c o m*/ return false; }
From source file:Main.java
/** * Returns true if the entity's Content-Type header is * <code>application/x-www-form-urlencoded</code>. *///from w w w . j av a 2 s .c o m public static boolean isEncoded(final HttpEntity entity) { Header h = entity.getContentType(); if (h != null) { HeaderElement[] elems = h.getElements(); if (elems.length > 0) { String contentType = elems[0].getName(); return contentType.equalsIgnoreCase(CONTENT_TYPE); } else { return false; } } else { return false; } }
From source file:Main.java
public static CharSequence highlightText(String search, String originalText) { if (search != null && !search.equalsIgnoreCase("")) { String normalizedText = Normalizer.normalize(originalText, Normalizer.Form.NFD) .replaceAll("\\p{InCombiningDiacriticalMarks}+", "").toLowerCase(); int start = normalizedText.indexOf(search); if (start < 0) { return originalText; } else {// w w w.ja v a 2 s . c om Spannable highlighted = new SpannableString(originalText); while (start >= 0) { int spanStart = Math.min(start, originalText.length()); int spanEnd = Math.min(start + search.length(), originalText.length()); highlighted.setSpan(new ForegroundColorSpan(Color.BLUE), spanStart, spanEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); start = normalizedText.indexOf(search, spanEnd); } return highlighted; } } return originalText; }
From source file:Main.java
/** * This method creates a collection of child nodes from a parent node * @param root the parent node// ww w . j av a2s. co m * @return Collection - childern nodes */ public static Collection getCollection(Node root) { Collection collection = new ArrayList(); if (root != null) { NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); String nodeName = child.getNodeName(); if (!nodeName.equalsIgnoreCase("#comment") && !nodeName.equalsIgnoreCase("#text")) { if (child.getChildNodes().getLength() > 1) { collection.add(child); } else { Node textChild = child.getFirstChild(); if (textChild == null) { // don't accept nulls } else { collection.add(child.getFirstChild().getNodeValue()); } } } } } return collection; }
From source file:Main.java
/** * This used when a double ends in 0 (IE 100.0) and you want 2 decimal places instead (IE 100.00) * @param value The double to convert/*from w w w. j av a 2s.c o m*/ * @param addDollarSign boolean, if null passed, nothing, if true passed, will add * a $ to the begining * @return A String, formatted correctly. Will look like this: 104.44 or $99.40 */ public static String convertDoubleToStringAddZeroNoRemove(double value, Boolean addDollarSign) { String str = Double.toString(value); String ending = str.substring((str.length() - 2), (str.length() - 1)); if (ending.equalsIgnoreCase(".")) { str = str + "0"; } if (addDollarSign != null) { if (addDollarSign) { str = "$" + str; } } return str; }
From source file:Main.java
public static boolean supportABI(String requestAbi) { String abi = get_CPU_ABI(); if (!TextUtils.isEmpty(abi) && abi.equalsIgnoreCase(requestAbi)) return true; String abi2 = get_CPU_ABI2(); return !TextUtils.isEmpty(abi2) && abi.equalsIgnoreCase(requestAbi); }
From source file:Main.java
public static boolean shouldShowDialog(String version, Context context) { String oldVersion = getSharedPreferences(context).getString(PREFERENCE_KEY, ""); return !oldVersion.equalsIgnoreCase(version); }
From source file:Main.java
public static String covertBorderStyle(String style) { if (style == null) return null; if (style.equalsIgnoreCase("Dot")) return "dotted"; if (style.equalsIgnoreCase("DashDot")) return "dashDot"; if (style.equalsIgnoreCase("Double")) return "double"; if (style.equalsIgnoreCase("Continuous")) return "thin"; return null;/*from w w w .j a v a2 s .co m*/ }
From source file:Main.java
public static final int indexOfIgnoreCase(String[] array, String str) { if (array != null) { for (int i = 0; i < array.length; ++i) { String s = array[i]; if (s != null) { if (s.equalsIgnoreCase(str)) { return i; }/*from www.j ava2 s .co m*/ } else if (str == null) { return i; } } } return -1; }