List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:org.carewebframework.ui.command.CommandUtil.java
/** * Given a key event, returns the symbolic representation of the typed key. * //from w w w .java 2 s .c o m * @param event The key press event. * @return The symbolic representation of the typed key. */ public static String getShortcut(KeyEvent event) { StringBuilder sb = new StringBuilder(); if (event.isAltKey()) { sb.append('@'); } if (event.isCtrlKey()) { sb.append('^'); } if (event.isShiftKey()) { sb.append('$'); } String specialKey = specialKeys.get(event.getKeyCode()); if (specialKey != null) { sb.append('#').append(specialKey); } else { sb.append(Character.toLowerCase(event.getKeyCode())); } return sb.toString(); }
From source file:dev.maisentito.suca.commands.Hangman.java
public boolean guess(char letter) { letter = Character.toLowerCase(letter); if (!isGuessed(letter)) { mGuessedChars.add(letter);// ww w . ja va 2s .c om if (mPresentChars.contains(letter)) { return true; } mTriesLeft--; return false; } return false; }
From source file:BeanUtil.java
/** * Retreives a property descriptor object for a given property. * <p>//from w w w. j av a2 s .c om * Uses the classes in <code>java.beans</code> to get back * a descriptor for a property. Read-only and write-only * properties will have a slower return time. * </p> * * @param propertyName The programmatic name of the property * @param beanClass The Class object for the target bean. * For example sun.beans.OurButton.class. * @return a PropertyDescriptor for a property that follows the * standard Java naming conventions. * @throws PropertyNotFoundException indicates that the property * could not be found on the bean class. */ private static final PropertyDescriptor getPropertyDescriptor(String propertyName, Class beanClass) { PropertyDescriptor resultPropertyDescriptor = null; char[] pNameArray = propertyName.toCharArray(); pNameArray[0] = Character.toLowerCase(pNameArray[0]); propertyName = new String(pNameArray); try { resultPropertyDescriptor = new PropertyDescriptor(propertyName, beanClass); } catch (IntrospectionException e1) { // Read-only and write-only properties will throw this // exception. The properties must be looked up using // brute force. // This will get the list of all properties and iterate // through looking for one that matches the property // name passed into the method. try { BeanInfo beanInfo = Introspector.getBeanInfo(beanClass); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); for (int i = 0; i < propertyDescriptors.length; i++) { if (propertyDescriptors[i].getName().equals(propertyName)) { // If the names match, this this describes the // property being searched for. Break out of // the iteration. resultPropertyDescriptor = propertyDescriptors[i]; break; } } } catch (IntrospectionException e2) { e2.printStackTrace(); } } // If no property descriptor was found, then this bean does not // have a property matching the name passed in. if (resultPropertyDescriptor == null) { System.out.println("resultPropertyDescriptor == null"); } return resultPropertyDescriptor; }
From source file:com.iflytek.spider.metadata.SpellCheckedMetadata.java
/** * Normalizes String.//from w w w . j a v a2 s.co m * * @param str * the string to normalize * @return normalized String */ private static String normalize(final String str) { char c; StringBuffer buf = new StringBuffer(); for (int i = 0; i < str.length(); i++) { c = str.charAt(i); if (Character.isLetter(c)) { buf.append(Character.toLowerCase(c)); } } return buf.toString(); }
From source file:org.ardverk.gibson.EventUtils.java
private static void keywords(String value, Set<String> dst) { int length = value.length(); StringBuilder sb = new StringBuilder(length); for (int i = 0; i < length; i++) { char ch = value.charAt(i); if (!Character.isLetterOrDigit(ch)) { if (sb.length() >= MIN_KEYWORD_LENGTH) { dst.add(sb.toString());//from ww w .j av a 2 s .c o m } sb.setLength(0); continue; } sb.append(Character.toLowerCase(ch)); } if (sb.length() >= MIN_KEYWORD_LENGTH) { dst.add(sb.toString()); } }
From source file:com.helpinput.core.MapConvertor.java
public static String methodNameGetFieldName(String methodName) { StringBuffer sb = new StringBuffer(); sb.append(Character.toLowerCase(methodName.charAt(3))); sb.append(methodName.substring(4));/* ww w .java2 s . com*/ return sb.toString(); }
From source file:Main.java
/** * Put common code to deepTrim(String) and deepTrimToLower here. * /*ww w . j a v a 2 s . co m*/ * @param str * the string to deep trim * @param toLowerCase * how to normalize for case: upper or lower * @return the deep trimmed string * @see StringTools#deepTrim( String ) * * TODO Replace the toCharArray() by substring manipulations */ public static final String deepTrim(String str, boolean toLowerCase) { if ((null == str) || (str.length() == 0)) { return ""; } char ch; char[] buf = str.toCharArray(); char[] newbuf = new char[buf.length]; boolean wsSeen = false; boolean isStart = true; int pos = 0; for (int i = 0; i < str.length(); i++) { ch = buf[i]; // filter out all uppercase characters if (toLowerCase) { if (Character.isUpperCase(ch)) { ch = Character.toLowerCase(ch); } } // Check to see if we should add space if (Character.isWhitespace(ch)) { // If the buffer has had characters added already check last // added character. Only append a spc if last character was // not whitespace. if (wsSeen) { continue; } else { wsSeen = true; if (isStart) { isStart = false; } else { newbuf[pos++] = ch; } } } else { // Add all non-whitespace wsSeen = false; isStart = false; newbuf[pos++] = ch; } } return (pos == 0 ? "" : new String(newbuf, 0, (wsSeen ? pos - 1 : pos))); }
From source file:info.novatec.testit.livingdoc.util.NameUtils.java
public static String humanize(String s) { StringBuilder literal = new StringBuilder(); char[] chars = s.toCharArray(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (Character.isUpperCase(c) && i > 0) { literal.append(' '); literal.append(Character.toLowerCase(c)); } else {//w w w . j a v a2 s.com literal.append(c); } } return literal.toString(); }
From source file:org.cruxframework.crux.core.rebind.formatter.Formatters.java
/** * // w ww . jav a 2s . c o m */ @SuppressWarnings("unchecked") protected static void initializeFormatters() { formatters = new HashMap<String, String>(); Set<String> formatterNames = ClassScanner.searchClassesByInterface(Formatter.class); if (formatterNames != null) { for (String formatter : formatterNames) { try { Class<? extends Formatter> formatterClass = (Class<? extends Formatter>) Class .forName(formatter); FormatterName annot = formatterClass.getAnnotation(FormatterName.class); if (annot != null) { if (formatters.containsKey(annot.value())) { throw new CruxGeneratorException("Duplicated formatter: [" + annot.value() + "]."); } formatters.put(annot.value(), formatterClass.getCanonicalName()); } else { String simpleName = formatterClass.getSimpleName(); if (simpleName.length() > 1) { simpleName = Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1); } else { simpleName = simpleName.toLowerCase(); } if (formatters.containsKey(simpleName)) { throw new CruxGeneratorException("Duplicated formatter: [" + simpleName + "]."); } formatters.put(simpleName, formatterClass.getCanonicalName()); } } catch (Throwable e) { logger.error("Error initializing formatters.", e); } } } }
From source file:com.yahoo.semsearch.fastlinking.utils.Normalize.java
License:asdf
/** * Removes non digit or letter characters from an input string * This method accumulates chracters in a string buffer for efficiency * * @param args string to normalize// w ww . j a v a 2s. co m * @return processed string */ public static String normalizeFast(String args) { final StringBuilder t = new StringBuilder(); final int length = args.length(); boolean inSpace = false; for (int i = 0; i < length; i++) { char charAt = args.charAt(i); if (Character.isLetterOrDigit(charAt)) { if (inSpace) t.append(' '); t.append(Character.toLowerCase(charAt)); inSpace = false; } else if (t.length() > 0) inSpace = true; } return t.toString(); }