List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:mil.army.usace.data.dataquery.rdbms.RdbmsDataQuery.java
public String dbToFieldName(String dbName) { String fieldName = ""; for (int i = 0; i < dbName.length(); i++) { char c = dbName.charAt(i); if (c == '_') { i++;// ww w .ja v a 2s. co m fieldName += Character.toUpperCase(dbName.charAt(i)); } else { fieldName += Character.toLowerCase(c); } } return fieldName; }
From source file:org.apache.uima.ruta.resource.MultiTreeWordList.java
/** * Checks if a string is contained by the MultiTreeWordList. * //from w w w .j a v a 2 s . c o m * @param node * The MultiTextNode which is under consideration at the moment. * @param query * The query string. * @param result * The result which matched until now. * @param distance * The remaining edit distance. * @param index * The index of the query string at the moment. * @param ignoreCase * Indicates whether we search case sensitive or not. * @param fragment * Indicates whether we search for fragments of the query string or not. * @param edm * The edit distance cost map we are using. * @return A map with all strings with a specified edit distance to the string query as keys and * the files they belong to as values. */ private boolean editDistanceBool(MultiTextNode node, String query, String result, double distance, int index, boolean ignoreCase, boolean fragment, EditDistanceCostMap edm) { boolean deletion = false; boolean insertion = false; boolean substitution = false; boolean noop = false; // Recursion stop. if (fragment) { if (index == query.length()) { return true; } } if (node.isWordEnd()) { double remainingInsertCosts = 0.0; // Accumulating remaining insert costs if the query is longer than // the word in the trie. for (int i = index; i < query.length(); i++) { remainingInsertCosts += edm.getInsertCosts(query.charAt(i)); } if (remainingInsertCosts <= distance) { // if (query.length() - index <= distance) { return true; } } // Delete. if (distance - edm.getDeleteCosts(node.getValue()) >= 0 && result.length() > 0) { deletion = editDistanceBool(node, query, result, distance - edm.getDeleteCosts(node.getValue()), index + 1, ignoreCase, fragment, edm); if (deletion) { return true; } } // Recursion. for (MultiTextNode tempNode : node.getChildren().values()) { if (index < query.length()) { if (ignoreCase) { if (Character.toLowerCase(tempNode.getValue()) == Character.toLowerCase(query.charAt(index))) { noop = editDistanceBool(tempNode, query, result + tempNode.getValue(), distance, index + 1, ignoreCase, fragment, edm); } } else { if (tempNode.getValue() == query.charAt(index)) { noop = editDistanceBool(tempNode, query, result + tempNode.getValue(), distance, index + 1, ignoreCase, fragment, edm); } } if (noop) { return true; } } if (distance - edm.getReplaceCosts(node.getValue(), tempNode.getValue()) >= 0) { // Substitute. substitution = editDistanceBool(tempNode, query, result + tempNode.getValue(), distance - edm.getReplaceCosts(node.getValue(), tempNode.getValue()), index + 1, ignoreCase, fragment, edm); if (substitution) { return true; } } if (distance - edm.getInsertCosts(tempNode.getValue()) >= 0) { // Insert - use the same index twice. insertion = editDistanceBool(tempNode, query, result + tempNode.getValue(), distance - edm.getInsertCosts(tempNode.getValue()), index, ignoreCase, fragment, edm); if (insertion) { return true; } } } return false; }
From source file:co.id.app.sys.util.StringUtils.java
/** * Return a field name string from the given field label. * <p/>/* w w w . ja v a 2s. c o m*/ * A label of " OK do it!" is returned as "okDoIt". Any &nbsp; * characters will also be removed. * <p/> * A label of "customerSelect" is returned as "customerSelect". * * @param label the field label or caption * @return a field name string from the given field label */ public static String toName(String label) { if (label == null) { throw new IllegalArgumentException("Null label parameter"); } boolean doneFirstLetter = false; boolean lastCharBlank = false; boolean hasWhiteSpace = (label.indexOf(' ') != -1); HtmlStringBuffer buffer = new HtmlStringBuffer(label.length()); for (int i = 0, size = label.length(); i < size; i++) { char aChar = label.charAt(i); if (aChar != ' ') { if (Character.isJavaIdentifierPart(aChar)) { if (lastCharBlank) { if (doneFirstLetter) { buffer.append(Character.toUpperCase(aChar)); lastCharBlank = false; } else { buffer.append(Character.toLowerCase(aChar)); lastCharBlank = false; doneFirstLetter = true; } } else { if (doneFirstLetter) { if (hasWhiteSpace) { buffer.append(Character.toLowerCase(aChar)); } else { buffer.append(aChar); } } else { buffer.append(Character.toLowerCase(aChar)); doneFirstLetter = true; } } } } else { lastCharBlank = true; } } return buffer.toString(); }
From source file:me.Wundero.Ray.utils.TextUtils.java
private static char toLowerCase(char in) { return Character.toLowerCase(in); }
From source file:cn.remex.core.util.StringUtils.java
private static String changeFirstCharacterCase(final String str, final boolean capitalize) { if (str == null || str.length() == 0) { return str; }// w w w. jav a 2 s .c om StringBuffer buf = new StringBuffer(str.length()); if (capitalize) { buf.append(Character.toUpperCase(str.charAt(0))); } else { buf.append(Character.toLowerCase(str.charAt(0))); } buf.append(str.substring(1)); return buf.toString(); }
From source file:com.app.kmsystem.util.StringUtils.java
@SuppressWarnings({ "unchecked", "unused" }) private static Set getObjectPropertyNames(Object object) { if (object instanceof Map) { return ((Map) object).keySet(); }/*ww w . j a va 2s .c o m*/ HashSet hashSet = new HashSet(); Method[] methods = object.getClass().getMethods(); for (int i = 0; i < methods.length; i++) { String methodName = methods[i].getName(); if (methodName.startsWith("get") && methodName.length() > 3) { String propertyName = "" + Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4); hashSet.add(propertyName); } if (methodName.startsWith("is") && methodName.length() > 2) { String propertyName = "" + Character.toLowerCase(methodName.charAt(2)) + methodName.substring(3); hashSet.add(propertyName); } if (methodName.startsWith("set") && methodName.length() > 3) { String propertyName = "" + Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4); hashSet.add(propertyName); } } return hashSet; }
From source file:com.xybase.utils.StringUtils.java
@SuppressWarnings("unchecked") public static Set getObjectPropertyNames(Object object) { if (object instanceof Map) { return ((Map) object).keySet(); }// ww w . jav a 2 s .c o m HashSet hashSet = new HashSet(); Method[] methods = object.getClass().getMethods(); for (Method method : methods) { String methodName = method.getName(); if (methodName.startsWith("get") && methodName.length() > 3) { String propertyName = "" + Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4); hashSet.add(propertyName); } if (methodName.startsWith("is") && methodName.length() > 2) { String propertyName = "" + Character.toLowerCase(methodName.charAt(2)) + methodName.substring(3); hashSet.add(propertyName); } if (methodName.startsWith("set") && methodName.length() > 3) { String propertyName = "" + Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4); hashSet.add(propertyName); } } return hashSet; }
From source file:co.id.app.sys.util.StringUtils.java
@SuppressWarnings({ "unchecked", "unused", "rawtypes" }) private static Set getObjectPropertyNames(Object object) { if (object instanceof Map) { return ((Map) object).keySet(); }/*from w w w. j a v a 2 s . co m*/ HashSet hashSet = new HashSet(); Method[] methods = object.getClass().getMethods(); for (int i = 0; i < methods.length; i++) { String methodName = methods[i].getName(); if (methodName.startsWith("get") && methodName.length() > 3) { String propertyName = "" + Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4); hashSet.add(propertyName); } if (methodName.startsWith("is") && methodName.length() > 2) { String propertyName = "" + Character.toLowerCase(methodName.charAt(2)) + methodName.substring(3); hashSet.add(propertyName); } if (methodName.startsWith("set") && methodName.length() > 3) { String propertyName = "" + Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4); hashSet.add(propertyName); } } return hashSet; }
From source file:de.uni_koblenz.jgralab.utilities.rsa2tg.SchemaGraph2XMI.java
/** * Find a new rolename which lets the new {@link Schema} still be * consistent.//from ww w . j a v a 2s. c o m * * @param connectedVertexClass * {@link VertexClass} for which the new rolename should be * created * @return String the new rolename */ private String createNewUniqueRoleName(VertexClass connectedVertexClass) { String baseRolename = connectedVertexClass.get_qualifiedName().replaceAll(Pattern.quote("."), "_"); // ensure that the rolename starts with an lower case letter if (Character.isUpperCase(baseRolename.charAt(0))) { baseRolename = Character.toLowerCase(baseRolename.charAt(0)) + baseRolename.substring(1); } // find a unique rolename HashMap<String, Object> boundVars = new HashMap<>(); boundVars.put("start", connectedVertexClass); int counter = 0; Object result; do { counter++; GreqlQuery query = GreqlQuery.createQuery("using start:" + "exists ic:start<->{structure.SpecializesVertexClass}*<->{structure.EndsAt}<->{structure.ComesFrom,structure.GoesTo}^2@ic.roleName=\"" + baseRolename + (counter == 1 ? "" : counter) + "\""); GreqlEnvironment environment = new GreqlEnvironmentAdapter(boundVars); result = query.evaluate(connectedVertexClass.getGraph(), environment); } while (result instanceof Boolean ? (Boolean) result : false); return baseRolename + (counter == 1 ? "" : counter); }
From source file:com.xybase.utils.StringUtils.java
/** * Convert a string to a valid camel case string * * @param inputString the input string to convert to camel case * @param firstCharacterUppercase when true first word will be converted to upper case as well * @return camel case of the input//from ww w . j a v a 2 s.c om */ public static String getCamelCaseString(String inputString, boolean firstCharacterUppercase) { StringBuilder sb = new StringBuilder(); boolean nextUpperCase = false; for (int i = 0; i < inputString.length(); i++) { char c = inputString.charAt(i); switch (c) { case '_': case '-': case '@': case '$': case '#': case ' ': if (sb.length() > 0) { nextUpperCase = true; } break; default: if (nextUpperCase) { sb.append(Character.toUpperCase(c)); nextUpperCase = false; } else { sb.append(Character.toLowerCase(c)); } break; } } if (firstCharacterUppercase) { sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); } return sb.toString(); }