List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:com.qmetry.qaf.automation.util.StringUtil.java
/** * Utility method to create variable or method name from string. * @param formStr//from w ww. jav a 2 s. c o m * @return */ public static String toCamelCaseIdentifier(String formStr) { StringBuffer res = new StringBuffer(); formStr = formStr.replaceAll("\\{(\\d)*(\\s)*\\}", ""); String[] strArr = formStr.split("\\W"); int i = 0; for (String str : strArr) { if (str.trim().length() > 0) { char[] stringArray = str.trim().toCharArray(); if (i == 0) stringArray[0] = Character.toLowerCase(stringArray[0]); else stringArray[0] = Character.toUpperCase(stringArray[0]); str = new String(stringArray); res.append(str); } i++; } return res.toString().trim(); }
From source file:org.jnap.core.persistence.factory.DaoFactory.java
/** * @param entityClass/* ww w . j a v a 2 s .co m*/ * @return */ private String buildDaoName(Class<? extends PersistentModel> entityClass) { String daoName = entityClass.getSimpleName() + "Dao"; daoName = Character.toLowerCase(daoName.charAt(0)) + daoName.substring(1); return daoName; }
From source file:com.sf.ddao.crud.param.CRUDBeanPropsParameter.java
public static String mapPropName2Field(PropertyDescriptor descriptor) { final String s = descriptor.getName(); StringBuilder sb = new StringBuilder(s.length()); for (char ch : s.toCharArray()) { if (Character.isUpperCase(ch)) { ch = Character.toLowerCase(ch); sb.append("_").append(ch); } else {//w w w . j a v a 2 s. co m sb.append(ch); } } return sb.toString(); }
From source file:corner.util.BeanUtils.java
/** * bean//from www .j a v a2 s. c om * * @param bean * bean. * @param pro * ??. * @return . */ public static Object getProperty(Object bean, String pro) { if (Character.isUpperCase(pro.charAt(0))) { pro = Character.toLowerCase(pro.charAt(0)) + pro.substring(1); } try { return org.apache.commons.beanutils.PropertyUtils.getProperty(bean, pro); } catch (Exception e) { return null; } }
From source file:com.salesmanager.core.util.StringUtil.java
/** * Can be used to decode URL //ww w . ja v a2 s. co m * @param s * @return */ public static String unescape(String s) { StringBuffer sbuf = new StringBuffer(); int l = s.length(); int ch = -1; int b, sumb = 0; for (int i = 0, more = -1; i < l; i++) { /* Get next byte b from URL segment s */ switch (ch = s.charAt(i)) { case '%': ch = s.charAt(++i); int hb = (Character.isDigit((char) ch) ? ch - '0' : 10 + Character.toLowerCase((char) ch) - 'a') & 0xF; ch = s.charAt(++i); int lb = (Character.isDigit((char) ch) ? ch - '0' : 10 + Character.toLowerCase((char) ch) - 'a') & 0xF; b = (hb << 4) | lb; break; case '+': b = ' '; break; default: b = ch; } /* Decode byte b as UTF-8, sumb collects incomplete chars */ if ((b & 0xc0) == 0x80) { // 10xxxxxx (continuation byte) sumb = (sumb << 6) | (b & 0x3f); // Add 6 bits to sumb if (--more == 0) sbuf.append((char) sumb); // Add char to sbuf } else if ((b & 0x80) == 0x00) { // 0xxxxxxx (yields 7 bits) sbuf.append((char) b); // Store in sbuf } else if ((b & 0xe0) == 0xc0) { // 110xxxxx (yields 5 bits) sumb = b & 0x1f; more = 1; // Expect 1 more byte } else if ((b & 0xf0) == 0xe0) { // 1110xxxx (yields 4 bits) sumb = b & 0x0f; more = 2; // Expect 2 more bytes } else if ((b & 0xf8) == 0xf0) { // 11110xxx (yields 3 bits) sumb = b & 0x07; more = 3; // Expect 3 more bytes } else if ((b & 0xfc) == 0xf8) { // 111110xx (yields 2 bits) sumb = b & 0x03; more = 4; // Expect 4 more bytes } else /*if ((b & 0xfe) == 0xfc)*/ { // 1111110x (yields 1 bit) sumb = b & 0x01; more = 5; // Expect 5 more bytes } /* We don't test if the UTF-8 encoding is well-formed */ } return sbuf.toString(); }
From source file:net.yacy.cora.document.encoding.UTF8.java
@Override public int compare(String o0, String o1) { final int l0 = o0.length(); final int l1 = o1.length(); final int ml = Math.min(l0, l1); char c0, c1;/*w ww .jav a2s. co m*/ for (int i = 0; i < ml; i++) { if (this.insensitive) { c0 = Character.toLowerCase(o0.charAt(i)); c1 = Character.toLowerCase(o1.charAt(i)); } else { c0 = o0.charAt(i); c1 = o1.charAt(i); } if (c0 == c1) continue; return c0 - c1; } return l0 - l1; }
From source file:org.echocat.jomon.runtime.StringUtils.java
/** * Convert a string to lower case. (Faster than String.toLowerCase) *//*from ww w . ja va2 s . c o m*/ public static void toLowerCase(char[] chars) { for (int a = 0; a < chars.length; a++) { chars[a] = Character.toLowerCase(chars[a]); } }
From source file:com.bfd.harpc.config.spring.HarpcBeanDefinitionParser.java
/** * {@link#parse}//from w ww . ja v a2 s. com * <p> * * @param element * @param parserContext * @param clazz * @return {@link BeanDefinition} */ private BeanDefinition parse(Element element, ParserContext parserContext, Class<?> clazz) { RootBeanDefinition beanDefinition = new RootBeanDefinition(); beanDefinition.setBeanClass(clazz); Method[] methods = clazz.getMethods(); String id = StringUtils.EMPTY; for (Method method : methods) { if (method.getName().length() > 3 && method.getName().startsWith("set") && method.getParameterTypes().length == 1) { String attribute = method.getName().substring(3); char ch = attribute.charAt(0); attribute = Character.toLowerCase(ch) + attribute.substring(1); String value = element.getAttribute(attribute); if (StringUtils.isNotEmpty(value)) { Type type = method.getParameterTypes()[0]; if (type == boolean.class) { beanDefinition.getPropertyValues().addPropertyValue(attribute, Boolean.valueOf(value)); } else { if ("ref".equals(attribute) && parserContext.getRegistry().containsBeanDefinition(value)) { beanDefinition.getPropertyValues().addPropertyValue(attribute, new RuntimeBeanReference(value)); } else { beanDefinition.getPropertyValues().addPropertyValue(attribute, value); if ("id".equals(attribute)) { id = value; } } } } } } parserContext.getRegistry().registerBeanDefinition(id, beanDefinition); return beanDefinition; }
From source file:com.qtplaf.library.util.StringUtils.java
/** * Separates with a blank the different tokens that can compose a normal class or method name, like for instance * doSomething into Do something./*from www. j av a2 s .com*/ * * @param str The string to separate. * @return The separated string. */ public static String separeTokens(String str) { StringBuilder b = new StringBuilder(); if (str != null) { for (int i = 0; i < str.length(); i++) { if (i == 0) { b.append(Character.toUpperCase(str.charAt(i))); } else { if (Character.isLowerCase(str.charAt(i - 1)) && Character.isUpperCase(str.charAt(i))) { b.append(' '); if ((i < str.length() - 1) && Character.isUpperCase(str.charAt(i + 1))) { b.append(str.charAt(i)); } else { b.append(Character.toLowerCase(str.charAt(i))); } } else { b.append(str.charAt(i)); } } } } return b.toString(); }