List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:com.zulip.android.util.CustomHtmlToSpannedConverter.java
private void handleStartTag(String tag, Attributes attributes) { if (tag.equalsIgnoreCase("br")) { // We don't need to handle this. TagSoup will ensure that there's a // </br> for each <br> // so we can safely emite the linebreaks when we handle the close // tag./* w w w . j av a 2 s. co m*/ } else if (tag.equalsIgnoreCase("p")) { handleP(mSpannableStringBuilder); } else if (tag.equalsIgnoreCase("div")) { handleP(mSpannableStringBuilder); } else if (tag.equalsIgnoreCase("strong")) { start(mSpannableStringBuilder, new Bold()); } else if (tag.equalsIgnoreCase("b")) { start(mSpannableStringBuilder, new Bold()); } else if (tag.equalsIgnoreCase("em")) { start(mSpannableStringBuilder, new Italic()); } else if (tag.equalsIgnoreCase("cite")) { start(mSpannableStringBuilder, new Italic()); } else if (tag.equalsIgnoreCase("dfn")) { start(mSpannableStringBuilder, new Italic()); } else if (tag.equalsIgnoreCase("i")) { start(mSpannableStringBuilder, new Italic()); } else if (tag.equalsIgnoreCase("big")) { start(mSpannableStringBuilder, new Big()); } else if (tag.equalsIgnoreCase("small")) { start(mSpannableStringBuilder, new Small()); } else if (tag.equalsIgnoreCase("font")) { startFont(mSpannableStringBuilder, attributes); } else if (tag.equalsIgnoreCase("blockquote")) { handleP(mSpannableStringBuilder); start(mSpannableStringBuilder, new Blockquote()); } else if (tag.equalsIgnoreCase("tt")) { start(mSpannableStringBuilder, new Monospace()); } else if (tag.equalsIgnoreCase("a")) { startA(mSpannableStringBuilder, attributes, mBaseUri); } else if (tag.equalsIgnoreCase("span") && "user-mention".equals(attributes.getValue("class"))) { startSpan(mSpannableStringBuilder, attributes); } else if (tag.equalsIgnoreCase("u")) { start(mSpannableStringBuilder, new Underline()); } else if (tag.equalsIgnoreCase("sup")) { start(mSpannableStringBuilder, new Super()); } else if (tag.equalsIgnoreCase("sub")) { start(mSpannableStringBuilder, new Sub()); } else if (tag.equalsIgnoreCase("code")) { start(mSpannableStringBuilder, new InlineCode()); } else if (tag.equalsIgnoreCase("pre")) { start(mSpannableStringBuilder, new CodeBlock()); } else if (tag.length() == 2 && Character.toLowerCase(tag.charAt(0)) == 'h' && tag.charAt(1) >= '1' && tag.charAt(1) <= '6') { handleP(mSpannableStringBuilder); start(mSpannableStringBuilder, new Header(tag.charAt(1) - '1')); } else if (tag.equalsIgnoreCase("img")) { String cssClass = attributes.getValue("", "class"); if (cssClass != null && cssClass.equals("emoji")) { startImg(mSpannableStringBuilder, attributes, mEmojiGetter); } else { startImg(mSpannableStringBuilder, attributes, mImageGetter); } } else if (mTagHandler != null) { mTagHandler.handleTag(true, tag, mSpannableStringBuilder, mReader); } }
From source file:ca.sqlpower.persistance.CatNap.java
/** * Converts camelCaps strings into their equivalent strings having * underscores instead of camelCaps. For example, * <tt>richardStallmanCantReadThisBecauseHeIsDyslexic</tt> becomes * <tt>richard_stallman_cant_read_this_because_he_is_dyslexic</tt>. * * @param camel The string to convert. Must not be null. * @return The converted string./*from w w w . j a v a 2 s. c o m*/ */ public static String camelToUnderscore(String camel) { StringBuffer result = new StringBuffer(camel.length() * 2); for (char ch : camel.toCharArray()) { if (Character.isUpperCase(ch)) { result.append('_'); result.append(Character.toLowerCase(ch)); } else { result.append(ch); } } return result.toString(); }
From source file:UTFEncodingUtil.java
/** * Decodes the given string using the provided encoding. The encoding must be a valid * Java-encoding.//from w w w . ja va2 s . com * * @param s the string that should be encoded. * @param encoding the encoding to tranform the bytes into a string. * @return the encoded string. * @throws UnsupportedEncodingException if the specified encoding is not recognized. */ public static String decode(final String s, final String encoding) throws UnsupportedEncodingException { if ("utf-8".equalsIgnoreCase(encoding)) { return decodeUTF(s); } // the resulting string will never be greater than the encoded string final byte[] result = new byte[s.length()]; final char[] chars = s.toCharArray(); int position = 0; for (int i = 0; i < chars.length; i++) { final char ch = chars[i]; final int b; switch (ch) { case '%': final char lch = s.charAt(++i); final int hb = (Character.isDigit(lch) ? lch - '0' : 10 + Character.toLowerCase(lch) - 'a') & 0xF; final char hch = s.charAt(++i); final int lb = (Character.isDigit(hch) ? hch - '0' : 10 + Character.toLowerCase(hch) - 'a') & 0xF; b = (hb << 4) | lb; break; case '+': b = ' '; break; default: b = ch; } result[position] = (byte) b; position += 1; } return new String(result, 0, position, encoding); }
From source file:CharArrayMap.java
private int getHashCode(CharSequence text) { int code;/*from ww w . j av a2 s. c o m*/ if (ignoreCase) { code = 0; int len = text.length(); for (int i = 0; i < len; i++) { code = code * 31 + Character.toLowerCase(text.charAt(i)); } } else { if (false && text instanceof String) { code = text.hashCode(); } else { code = 0; int len = text.length(); for (int i = 0; i < len; i++) { code = code * 31 + text.charAt(i); } } } return code; }
From source file:net.sf.jabref.bst.BibtexCaseChanger.java
private int convertNonControl(char[] c, int start, StringBuilder sb, FORMAT_MODE format) { int pos = start; switch (format) { case TITLE_LOWERS: case ALL_LOWERS: sb.append(Character.toLowerCase(c[pos])); pos++;// w w w .j av a 2s .co m break; case ALL_UPPERS: sb.append(Character.toUpperCase(c[pos])); pos++; break; default: LOGGER.info("convertNonControl - Unknown format: " + format); break; } return pos; }
From source file:org.codice.ddf.commands.catalog.ExportCommand.java
@Override protected Object executeWithSubject() throws Exception { Filter filter = getFilter();// ww w . j ava2 s. c om transformer = getServiceByFilter(MetacardTransformer.class, String.format("(%s=%s)", "id", DEFAULT_TRANSFORMER_ID)) .orElseThrow(() -> new IllegalArgumentException( "Could not get " + DEFAULT_TRANSFORMER_ID + " transformer")); revisionFilter = initRevisionFilter(); final File outputFile = initOutputFile(output); checkFile(outputFile); if (delete && !force) { final String input = session.readLine( "This action will remove all exported metacards and content from the catalog. Are you sure you wish to continue? (y/N):", null); if (input.length() == 0 || Character.toLowerCase(input.charAt(0)) != 'y') { console.println("ABORTED EXPORT."); return null; } } SecurityLogger.audit("Called catalog:export command with path : {}", output); try (FileOutputStream fileOutputStream = new FileOutputStream(outputFile); ZipOutputStream zipOutputStream = new ZipOutputStream(fileOutputStream)) { return doExport(outputFile, zipOutputStream, filter); } catch (FileNotFoundException e) { throw new FileNotFoundException( String.format("ZipOutputStream could not be created for the path %s", outputFile.getPath())); } }
From source file:android.support.v7.internal.view.menu.MenuItemImpl.java
@Override public MenuItem setAlphabeticShortcut(char alphaChar) { if (mShortcutAlphabeticChar == alphaChar) { return this; }/*from w w w . j a va 2 s.c om*/ mShortcutAlphabeticChar = Character.toLowerCase(alphaChar); mMenu.onItemsChanged(false); return this; }
From source file:com.janela.mobile.ui.repo.RepositoryListFragment.java
private void updateHeaders(final List<Repository> repos) { HeaderFooterListAdapter<?> rootAdapter = getListAdapter(); if (rootAdapter == null) return;/*from w w w . j ava2s . c o m*/ DefaultRepositoryListAdapter adapter = (DefaultRepositoryListAdapter) rootAdapter.getWrappedAdapter(); adapter.clearHeaders(); if (repos.isEmpty()) return; // Add recent header if at least one recent repository Repository first = repos.get(0); if (recentRepos.contains(first)) adapter.registerHeader(first, getString(R.string.recently_viewed)); // Advance past all recent repositories int index; Repository current = null; for (index = 0; index < repos.size(); index++) { Repository repository = repos.get(index); if (recentRepos.contains(repository.getId())) current = repository; else break; } if (index >= repos.size()) return; if (current != null) adapter.registerNoSeparator(current); // Register header for first character current = repos.get(index); char start = Character.toLowerCase(current.getName().charAt(0)); adapter.registerHeader(current, Character.toString(start).toUpperCase(US)); char previousHeader = start; for (index = index + 1; index < repos.size(); index++) { current = repos.get(index); char repoStart = Character.toLowerCase(current.getName().charAt(0)); if (repoStart <= start) continue; // Don't include separator for the last element of the previous // character if (previousHeader != repoStart) adapter.registerNoSeparator(repos.get(index - 1)); adapter.registerHeader(current, Character.toString(repoStart).toUpperCase(US)); previousHeader = repoStart; start = repoStart++; } // Don't include separator for last element adapter.registerNoSeparator(repos.get(repos.size() - 1)); }
From source file:org.apache.uima.ruta.resource.TreeWordList.java
private boolean recursiveContains(TextNode pointer, String text, int index, boolean ignoreCase, boolean fragment, char[] ignoreChars, int maxIgnoreChars, boolean ignoreWS) { if (pointer == null) { return false; }/* w w w . j av a 2 s. co m*/ if (index == text.length()) { return fragment || pointer.isWordEnd(); } char charAt = text.charAt(index); boolean charAtIgnored = false; if (ignoreChars != null) { for (char each : ignoreChars) { if (each == charAt) { charAtIgnored = true; maxIgnoreChars--; break; } } charAtIgnored &= index != 0; if (maxIgnoreChars < 0) { return false; } } int next = ++index; boolean result = false; if (ignoreCase) { TextNode childNodeL = pointer.getChildNode(Character.toLowerCase(charAt)); TextNode childNodeU = pointer.getChildNode(Character.toUpperCase(charAt)); TextNode wsNode = pointer.getChildNode(' '); if (ignoreWS && wsNode != null) { result |= recursiveContains(wsNode, text, --next, ignoreCase, fragment, ignoreChars, maxIgnoreChars, ignoreWS); } if (childNodeL == null && ignoreWS) { childNodeL = skipWS(pointer, charAt); } if (childNodeU == null && ignoreWS) { childNodeU = skipWS(pointer, charAt); } if (charAtIgnored && childNodeL == null && childNodeU == null) { result |= recursiveContains(pointer, text, next, ignoreCase, fragment, ignoreChars, maxIgnoreChars, ignoreWS); } else { result |= recursiveContains(childNodeL, text, next, ignoreCase, fragment, ignoreChars, maxIgnoreChars, ignoreWS) | recursiveContains(childNodeU, text, next, ignoreCase, fragment, ignoreChars, maxIgnoreChars, ignoreWS); } } else { TextNode wsNode = pointer.getChildNode(' '); if (ignoreWS && wsNode != null) { result |= recursiveContains(wsNode, text, --next, ignoreCase, fragment, ignoreChars, maxIgnoreChars, ignoreWS); } TextNode childNode = pointer.getChildNode(charAt); if (childNode == null && ignoreWS) { childNode = skipWS(pointer, charAt); } if (charAtIgnored && childNode == null) { result |= recursiveContains(pointer, text, next, ignoreCase, fragment, ignoreChars, maxIgnoreChars, ignoreWS); } else { result |= recursiveContains(childNode, text, next, ignoreCase, fragment, ignoreChars, maxIgnoreChars, ignoreWS); } } return result; }
From source file:com.github.mobile.ui.repo.RepositoryListFragment.java
private void updateHeaders(final List<Repository> repos) { HeaderFooterListAdapter<?> rootAdapter = getListAdapter(); if (rootAdapter == null) return;/*ww w .j a va2 s. c om*/ DefaultRepositoryListAdapter adapter = (DefaultRepositoryListAdapter) rootAdapter.getWrappedAdapter(); adapter.clearHeaders(); if (repos.isEmpty()) return; // Add recent header if at least one recent repository Repository first = repos.get(0); if (recentRepos.contains(first)) adapter.registerHeader(first, getString(string.recently_viewed)); // Advance past all recent repositories int index; Repository current = null; for (index = 0; index < repos.size(); index++) { Repository repository = repos.get(index); if (recentRepos.contains(repository.getId())) current = repository; else break; } if (index >= repos.size()) return; if (current != null) adapter.registerNoSeparator(current); // Register header for first character current = repos.get(index); char start = Character.toLowerCase(current.getName().charAt(0)); adapter.registerHeader(current, Character.toString(start).toUpperCase(US)); char previousHeader = start; for (index = index + 1; index < repos.size(); index++) { current = repos.get(index); char repoStart = Character.toLowerCase(current.getName().charAt(0)); if (repoStart <= start) continue; // Don't include separator for the last element of the previous // character if (previousHeader != repoStart) adapter.registerNoSeparator(repos.get(index - 1)); adapter.registerHeader(current, Character.toString(repoStart).toUpperCase(US)); previousHeader = repoStart; start = repoStart++; } // Don't include separator for last element adapter.registerNoSeparator(repos.get(repos.size() - 1)); }