List of usage examples for java.lang Character isLowerCase
public static boolean isLowerCase(int codePoint)
From source file:com.boundary.plugin.sdk.PluginUtil.java
/** * Transform a camel case string into a upper case string with underscores * /*ww w . j av a2 s. c om*/ * @param s {@link String} to transform * @param d replacement character for white space * @return {@link String} */ public static String toUpperUnderscore(String s, Character d) { StringBuilder builder = new StringBuilder(); s = s.trim(); boolean first = true; for (int i = 0; i < s.length(); i++) { if (Character.isWhitespace(s.charAt(i))) { builder.append(d); } else { if (Character.isUpperCase(s.charAt(i))) { if (first == false) { if (i + 1 < s.length() && Character.isLowerCase(s.charAt(i + 1))) { builder.append(d); } } } builder.append(Character.toUpperCase(s.charAt(i))); } first = false; } StringBuilder r = new StringBuilder(); r.append('\\').append(d).append('\\').append(d); return builder.toString().replaceAll(r.toString(), d.toString()); }
From source file:eu.crisis_economics.configuration.NameDeclarationExpression.java
public static List<String> isExpressionOfType(String rawExpression, FromFileConfigurationContext context) { String expression = rawExpression.trim(); if (expression.length() == 0) return null; boolean beginsWithLowercase = Character.isLowerCase(expression.charAt(0)); if (!beginsWithLowercase) return null; boolean containsSyntaxTokens = expression.matches(".*[\\s-/=,\\$\\[\\]\\{\\(\\)\\}].*"); if (containsSyntaxTokens) return null; return Arrays.asList(expression); }
From source file:org.commoncrawl.util.RPCStructIntrospector.java
static String toCamelCase(String name) { char firstChar = name.charAt(0); if (Character.isLowerCase(firstChar)) { return "" + Character.toUpperCase(firstChar) + name.substring(1); }//from www . j av a 2s . c o m return name; }
From source file:org.gradle.api.internal.plugins.CleanRule.java
public void apply(String taskName) { if (!taskName.startsWith(PREFIX)) { return;/*from w w w .ja v a 2s .co m*/ } String targetTaskName = taskName.substring(PREFIX.length()); if (Character.isLowerCase(targetTaskName.charAt(0))) { return; } Task task = tasks.findByName(StringUtils.uncapitalize(targetTaskName)); if (task == null) { return; } Delete clean = tasks.create(taskName, Delete.class); clean.delete(task.getOutputs().getFiles()); }
From source file:net.certiv.antlr.project.util.Strings.java
public static boolean isAllUpperCase(String in) { for (int idx = 0; idx < in.length(); idx++) { if (Character.isLowerCase(in.charAt(idx))) { return false; }//from ww w.j a va 2s .c o m } return true; }
From source file:Main.java
/** * <p>Swaps the case of a String changing upper and title case to * lower case, and lower case to upper case.</p> * * <ul>/*from w w w . j a v a 2 s . com*/ * <li>Upper case character converts to Lower case</li> * <li>Title case character converts to Lower case</li> * <li>Lower case character converts to Upper case</li> * </ul> * * <p>For a word based algorithm, see {@link WordUtils#swapCase(String)}. * A <code>null</code> input String returns <code>null</code>.</p> * * <pre> * StringUtils.swapCase(null) = null * StringUtils.swapCase("") = "" * StringUtils.swapCase("The dog has a BONE") = "tHE DOG HAS A bone" * </pre> * * <p>NOTE: This method changed in Lang version 2.0. * It no longer performs a word based algorithm. * If you only use ASCII, you will notice no change. * That functionality is available in WordUtils.</p> * * @param str the String to swap case, may be null * @return the changed String, <code>null</code> if null String input */ public static String swapCase(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return str; } StringBuffer buffer = new StringBuffer(strLen); char ch = 0; for (int i = 0; i < strLen; i++) { ch = str.charAt(i); if (Character.isUpperCase(ch)) { ch = Character.toLowerCase(ch); } else if (Character.isTitleCase(ch)) { ch = Character.toLowerCase(ch); } else if (Character.isLowerCase(ch)) { ch = Character.toUpperCase(ch); } buffer.append(ch); } return buffer.toString(); }
From source file:edu.illinois.cs.cogcomp.wikifier.utils.freebase.cleanDL.java
private static boolean mentionFilter(String[] parts) { char charAt = parts[3].charAt(0); if (Character.isLowerCase(charAt)) return true; return false; }
From source file:org.gradle.language.base.internal.plugins.CleanRule.java
public void apply(String taskName) { if (!taskName.startsWith(CLEAN) || taskName.equals(CLEAN)) { return;// ww w . j av a2 s . c om } String targetTaskName = taskName.substring(CLEAN.length()); if (Character.isLowerCase(targetTaskName.charAt(0))) { return; } Task task = tasks.findByName(StringUtils.uncapitalize(targetTaskName)); if (task == null) { return; } Delete clean = tasks.create(taskName, Delete.class); clean.delete(task.getOutputs().getFiles()); }
From source file:com.netflix.astyanax.util.StringUtils.java
public static <T> String joinClassAttributeValues(final T object, String name, Class<T> clazz) { Field[] fields = clazz.getDeclaredFields(); StringBuilder sb = new StringBuilder(); sb.append(name).append("["); sb.append(org.apache.commons.lang.StringUtils.join(Collections2.transform( // Filter any field that does not start with lower case // (we expect constants to start with upper case) Collections2.filter(Arrays.asList(fields), new Predicate<Field>() { @Override//from w w w.j av a 2 s .c o m public boolean apply(Field field) { if ((field.getModifiers() & Modifier.STATIC) == Modifier.STATIC) return false; return Character.isLowerCase(field.getName().charAt(0)); } }), // Convert field to "name=value". value=*** on error new Function<Field, String>() { @Override public String apply(Field field) { Object value; try { value = field.get(object); } catch (Exception e) { value = "***"; } return field.getName() + "=" + value; } }), ",")); sb.append("]"); return sb.toString(); }
From source file:com.zuoxiaolong.niubi.job.persistent.hibernate.HibernateNamingStrategy.java
private static String addUnderscores(String name) { StringBuilder buf = new StringBuilder(name.replace('.', '_')); for (int i = 1; i < buf.length() - 1; i++) { if (Character.isLowerCase(buf.charAt(i - 1)) && Character.isUpperCase(buf.charAt(i)) && Character.isLowerCase(buf.charAt(i + 1))) { buf.insert(i++, '_'); }/* w w w . j a va2 s.co m*/ } return buf.toString().toLowerCase(Locale.ROOT); }