Example usage for java.lang Character isUpperCase

List of usage examples for java.lang Character isUpperCase

Introduction

In this page you can find the example usage for java.lang Character isUpperCase.

Prototype

public static boolean isUpperCase(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) is an uppercase character.

Usage

From source file:org.kuali.ext.mm.utility.BeanDDCreator.java

public static String camelCaseToString(String className) {
    StringBuffer newName = new StringBuffer(className);
    // upper case the 1st letter
    newName.replace(0, 1, newName.substring(0, 1).toUpperCase());
    // loop through, inserting spaces when cap
    for (int i = 0; i < newName.length(); i++) {
        if (Character.isUpperCase(newName.charAt(i))) {
            newName.insert(i, ' ');
            i++;//from w  ww. j  av a  2 s. c  om
        }
    }

    return newName.toString().trim().replace("Uc", "UC");
}

From source file:CharUtils.java

/**
 * True if first letter in a string is uppercase.
 * /*from w w w .  j av a  2 s  .com*/
 * @param s
 *            String to check for initial uppercase letter.
 * 
 * @return true if first letter in string is uppercase.
 * 
 *         <p>
 *         Leading non-letters are ignored. If none of the characters in the
 *         string is a letters, false is returned.
 *         </p>
 */

public static boolean isFirstLetterCapital(String s) {
    boolean result = false;

    String ts = s.trim();

    for (int i = 0; i < ts.length(); i++) {
        if (Character.isLetter(ts.charAt(i))) {
            result = Character.isUpperCase(ts.charAt(i));
            break;
        }
    }

    return result;
}

From source file:ips1ap101.lib.base.util.StrUtils.java

public static String getHumplessCase(String string, String hump) {
    if (string == null) {
        return null;
    }//ww  w . j  a va 2  s .  c om
    if (hump == null) {
        return null;
    }
    if (isNotMixedCase(string)) {
        return string;
    }
    String x = string.trim();
    String y = "";
    boolean b = false;
    char c;
    for (int i = 0; i < x.length(); i++) {
        c = x.charAt(i);
        if (Character.isUpperCase(c)) {
            if (b) {
                y += hump;
            }
            y += Character.toLowerCase(c);
        } else {
            y += c;
        }
        b = true;
    }
    return y;
}

From source file:com.aiblockchain.api.StringUtils.java

/**
 * Gets a lower case predicate or variable name derived from the given simple class name.
 *
 * @param simpleClassName the given simple class name
 *
 * @return a lower case predicate or variable name derived from the given simple class name
 *///from  w w w  .ja  v a  2  s . com
public static String getLowerCasePredicateName(final String simpleClassName) {
    //Preconditions
    assert simpleClassName != null : "simpleClassName must not be null";
    assert !simpleClassName.isEmpty() : "simpleClassName must not be empty";

    // predicates begin with a lower case letter, but class names are capitalized and may also begin with a accronym
    if (simpleClassName.length() == 1) {
        // trivial case
        return simpleClassName.toLowerCase(Locale.ENGLISH);
    } else {
        final StringBuilder stringBuilder = new StringBuilder();

        int index = 0;
        final int simpleClassName_len = simpleClassName.length();
        while (true) {
            if (index >= simpleClassName_len) {
                // reached the end with all upper case characters
                break;
            }
            char ch = simpleClassName.charAt(index);
            stringBuilder.append(Character.toLowerCase(ch));

            if (index < simpleClassName_len - 2 && Character.isUpperCase(simpleClassName.charAt(index + 1))
                    && Character.isLowerCase(simpleClassName.charAt(index + 2))) {
                break;
            } else if (index < simpleClassName_len - 1
                    && Character.isLowerCase(simpleClassName.charAt(index + 1))) {
                break;
            }
            index++;
        }

        // copy any remaining characters unchanged
        for (int i = index + 1; i < simpleClassName_len; i++) {
            stringBuilder.append(simpleClassName.charAt(i));
        }
        return stringBuilder.toString();
    }
}

From source file:com.plusub.lib.annotate.JsonParserUtils.java

/**
 * ?set??//from  www  . j  a v a2s .co  m
 * <p>Title: getSetMethodName
 * <p>Description: 
 * @param field
 * @return
 */
private static String getSetMethodName(Field field) {
    Class clazz = field.getType();
    String name = field.getName();
    StringBuilder sb = new StringBuilder();
    //boolean ?set? 
    //private boolean ishead; setIshead
    //private boolean isHead; setHead
    //private boolean head; setHead
    if (clazz.equals(Boolean.class) || clazz.getName().equals("boolean")) {
        sb.append("set");
        if (name.startsWith("is")) {
            if (name.length() > 2) {
                //private boolean isHead; setHead
                if (Character.isUpperCase(name.charAt(2))) {
                    sb.append(name.substring(2));
                } else {//private boolean ishead; setIshead
                    sb.append(name.toUpperCase().charAt(0));
                    sb.append(name.substring(1));
                }
            } else {
                sb.append(name.toUpperCase().charAt(0));
                sb.append(name.substring(1));
            }
        } else {//private boolean head; setHead
            sb.append(name.toUpperCase().charAt(0));
            sb.append(name.substring(1));
        }
    } else {
        sb.append("set");
        sb.append(name.toUpperCase().charAt(0));
        sb.append(name.substring(1));
    }
    return sb.toString();
}

From source file:org.codehaus.groovy.grails.commons.GrailsClassUtils.java

/**
 * Returns the property name representation of the given name
 *
 * @param name The name to convert/* ww  w .  j a v a 2  s. c o  m*/
 * @return The property name representation
 * @deprecated Use {@link grails.util.GrailsNameUtils#getPropertyNameRepresentation(String)} instead.
 */
@Deprecated
public static String getPropertyNameRepresentation(String name) {
    // Strip any package from the name.
    int pos = name.lastIndexOf('.');
    if (pos != -1) {
        name = name.substring(pos + 1);
    }

    // Check whether the name begins with two upper case letters.
    if (name.length() > 1 && Character.isUpperCase(name.charAt(0)) && Character.isUpperCase(name.charAt(1))) {
        return name;
    }

    String propertyName = name.substring(0, 1).toLowerCase(Locale.ENGLISH) + name.substring(1);
    if (propertyName.indexOf(' ') > -1) {
        propertyName = propertyName.replaceAll("\\s", "");
    }
    return propertyName;
}

From source file:io.fabric8.ConnectorMojo.java

public static String camelCaseToDash(String value) {
    StringBuilder sb = new StringBuilder(value.length());
    boolean dash = false;

    for (char c : value.toCharArray()) {
        // skip dash in start
        if (sb.length() > 0 & Character.isUpperCase(c)) {
            dash = true;/*  w  w w  .  j  a va  2s.  co m*/
        }
        if (dash) {
            sb.append('-');
            sb.append(Character.toLowerCase(c));
        } else {
            // lower case first
            if (sb.length() == 0) {
                sb.append(Character.toLowerCase(c));
            } else {
                sb.append(c);
            }
        }
        dash = false;
    }
    return sb.toString();
}

From source file:com.px100systems.util.SpringELCtx.java

/**
 * Convert to camel-case/*from w w w  .j  a  v a  2s  .  c o m*/
 * @param name text
 * @return calmel-case text
 */
public static String printableCamelCase(String name) {
    if (name == null || name.trim().isEmpty())
        return "";

    StringBuilder result = new StringBuilder(name.substring(0, 1).toUpperCase());
    for (char a : name.substring(1).toCharArray()) {
        if (Character.isUpperCase(a))
            result.append(' ');
        result.append(a);
    }

    return result.toString();
}

From source file:eu.delving.sip.xml.SourceConverter.java

private String anonymizeString(String string) {
    if (moreNumbersThanLetters(string))
        return string;
    StringBuilder out = new StringBuilder(string.length());
    Random random = new Random(string.hashCode());
    for (char c : string.toCharArray()) {
        if (Character.isLowerCase(c)) {
            out.append((char) ('a' + (Math.abs(random.nextInt()) % 26)));
        } else if (Character.isUpperCase(c)) {
            out.append((char) ('A' + (Math.abs(random.nextInt()) % 26)));
        } else {// w w  w  . j a  v a2  s.  com
            out.append(c);
        }
    }
    return out.toString();
}

From source file:com.github.abel533.mapperhelper.EntityHelper.java

/**
 * ?//  w ww.j a v a  2  s . com
 */
public static String underlineToCamelhump(String str) {
    Matcher matcher = Pattern.compile("_[a-z]").matcher(str);
    StringBuilder builder = new StringBuilder(str);
    for (int i = 0; matcher.find(); i++) {
        builder.replace(matcher.start() - i, matcher.end() - i, matcher.group().substring(1).toUpperCase());
    }
    if (Character.isUpperCase(builder.charAt(0))) {
        builder.replace(0, 1, String.valueOf(Character.toLowerCase(builder.charAt(0))));
    }
    return builder.toString();
}