List of usage examples for java.lang Character toUpperCase
public static int toUpperCase(int codePoint)
From source file:Main.java
public static String createXmlName(String str) { StringBuffer result = new StringBuffer(); boolean skipped = false; boolean numbersOnly = true; for (int c = 0; c < str.length(); c++) { char ch = str.charAt(c); if (Character.isLetter(ch) || ch == '_' || ch == '-' || ch == '.') { if (skipped) result.append(Character.toUpperCase(ch)); else/*from w ww. ja v a 2 s .c o m*/ result.append(ch); numbersOnly = false; skipped = false; } else if (Character.isDigit(ch)) { result.append(ch); skipped = false; } else { skipped = true; } } str = result.toString(); if (numbersOnly && str.length() > 0) str = "_" + str; return str; }
From source file:Main.java
public final static String asUpperCaseFirstChar(final String target) { if ((target == null) || (target.length() == 0)) { return target; }//from w ww. ja va 2 s . c o m return Character.toUpperCase(target.charAt(0)) + (target.length() > 1 ? target.substring(1) : ""); }
From source file:StringUtil.java
/** * Capitalizes the first character of the given string. * @param s the String to capitalize//w w w .ja v a2 s.c om * @return the capitalized result */ public static String capitalize(String s) { if (s.length() == 0) return s; char c = Character.toUpperCase(s.charAt(0)); return c + s.substring(1, s.length()); }
From source file:Main.java
/** * Translates a XML file name to a Java file name according * to Android naming convention./*from ww w .j a v a 2 s .c o m*/ * * Doesn't append .java extension * * @return Java file name associated with XML file name */ public static String getJavaFileNameFromXmlFileName(String xmlFileName) { if (xmlFileName.endsWith(".xml")) { // cut off ".xm" xmlFileName = xmlFileName.substring(0, xmlFileName.length() - 4); } char[] charsXml = xmlFileName.toCharArray(); StringBuilder stringBuilder = new StringBuilder(); // make the first char upper case stringBuilder.append(Character.toUpperCase(charsXml[0])); // start looking for '_' at the second char for (int i = 1; i < charsXml.length; i++) { char currentChar = charsXml[i]; if (currentChar == '_') { // skip '_' and add the next char as upper case char toAppend = Character.toUpperCase(charsXml[++i]); stringBuilder.append(toAppend); } else { stringBuilder.append(currentChar); } } return stringBuilder.toString(); }
From source file:Main.java
public static String toConstantFormat(String str) { int n = str.length(); List<Character> list = new ArrayList<Character>(); char c;//from w w w . j a va2s. c o m for (int i = 0; i < n; i++) { c = str.charAt(i); if (i != 0 && Character.isUpperCase(c)) { list.add('_'); } list.add(Character.toUpperCase(c)); } StringBuffer buffer = new StringBuffer(); for (Character character : list) { buffer.append(character); } return buffer.toString(); }
From source file:Main.java
public static synchronized Method getSetter(final Class targetClass, final String propertyName) { String setterName = "set" + Character.toUpperCase(propertyName.charAt(0)); if (setterName.length() > 1) setterName += propertyName.substring(1); final Method[] methods = targetClass.getMethods(); for (Method m : methods) { if (m.getName().equals(setterName) && m.getParameterTypes().length == 1) return m; }//from ww w. j ava 2 s.c o m return null; }
From source file:com.optimalbi.Services.AmazonService.java
static String stringCap(String text) { int maxChars = 99; char[] chars = text.toCharArray(); if (chars.length > 0) { chars[0] = Character.toUpperCase(chars[0]); } else/*from ww w . java2 s . c o m*/ return ""; String shortString = String.valueOf(chars); if (shortString.length() > maxChars) { shortString = shortString.substring(0, maxChars - 3); shortString = shortString + "..."; } return shortString; }
From source file:MyKeyListener.java
public void keyTyped(KeyEvent evt) { JTextComponent c = (JTextComponent) evt.getSource(); char ch = evt.getKeyChar(); if (Character.isLowerCase(ch) == false) { return;//w ww. j ava 2 s .com } try { c.getDocument().insertString(c.getCaretPosition(), "" + Character.toUpperCase(ch), null); evt.consume(); } catch (BadLocationException e) { } }
From source file:org.springframework.social.google.api.impl.ApiEnumSerializer.java
public static String enumToString(Enum<?> value) { if (value == null) { return null; }/*from ww w.j a v a2s. c o m*/ String underscored = value.name(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < underscored.length(); i++) { char c = underscored.charAt(i); if (c == '_') { sb.append(Character.toUpperCase(underscored.charAt(++i))); } else { sb.append(Character.toLowerCase(c)); } } return sb.toString(); }
From source file:Main.java
private static String capitalizedName(final String property) { if (null == property || property.length() < 1) return property; final char[] chars = property.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); return new String(chars); }