Example usage for java.lang Character isLowerCase

List of usage examples for java.lang Character isLowerCase

Introduction

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

Prototype

public static boolean isLowerCase(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) is a lowercase character.

Usage

From source file:org.wso2.carbon.governance.list.ui.internal.GovernanceListUIServiceComponent.java

private String convertName(String[] nameParts) {
    String convertedName = null;//from  ww  w .  j a v a  2 s.  co  m
    //  making widget name camel case

    for (String namePart : nameParts) {
        int i;
        for (i = 0; i < namePart.length(); i++) {
            char c = namePart.charAt(i);
            if (!Character.isLetter(c) || Character.isLowerCase(c)) {
                break;
            }
        }
        if (namePart.equals(nameParts[0])) {
            namePart = namePart.substring(0, i).toLowerCase() + namePart.substring(i);
        }
        if (convertedName == null) {
            convertedName = namePart;
        } else {
            convertedName += namePart;
        }
    }
    return convertedName;
}

From source file:org.jboss.errai.codegen.util.CDIAnnotationUtils.java

public static String formatDefaultElName(final String rawName) {
    if (rawName.isEmpty() || Character.isLowerCase(rawName.charAt(0))
            || (rawName.length() > 1 && Character.isUpperCase(rawName.charAt(1)))) {
        return rawName;
    } else {//from ww  w .  ja va2 s.co m
        final StringBuilder builder = new StringBuilder(rawName);
        builder.setCharAt(0, Character.toLowerCase(builder.charAt(0)));

        return builder.toString();
    }
}

From source file:org.opensextant.util.TextUtils.java

/**
 * detects if string alpha chars are purely lower case.
 * //from w w w  .  j a  v a 2  s  .  c om
 * @param text
 *            text
 * @param textcase
 *            1 lower, 2 upper
 * @return if case matches given textcase param
 */
public static boolean checkCase(String text, int textcase) {
    if (text == null) {
        return false;
    }
    int caseCount = 0;

    for (char c : text.toCharArray()) {
        if (!Character.isLetter(c)) {
            continue;
        }
        if (textcase == 1) {
            if (Character.isUpperCase(c)) {
                // Checking for lower case; Fail if upper case is found.
                return false;
            } else if (Character.isLowerCase(c)) {
                ++caseCount;
            }
        } else if (textcase == 2) {
            if (Character.isLowerCase(c)) {
                // Checking for upper case; Fail if lower case is found.
                return false;
            } else if (Character.isUpperCase(c)) {
                ++caseCount;
            }
        }
    }
    // IF at least one letter found in the case, return true.
    // It is possible that mixed-language text that has no case-sense 
    // is mixed up with ASCII or Romance language text. 
    //   test     LOWER   UPPER
    //   A b  ==>  no      no
    //   A  ==>  no      yes
    //   a  ==>  yes      no
    return caseCount > 0;
}

From source file:org.codehaus.griffon.commons.GriffonClassUtils.java

/**
 * Converts a property name into its natural language equivalent eg ('firstName' becomes 'First Name')
 * @param name The property name to convert
 * @return The converted property name/*from   w  w w.j  a  v  a 2 s  . co  m*/
 */
public static String getNaturalName(String name) {
    List words = new ArrayList();
    int i = 0;
    char[] chars = name.toCharArray();
    for (int j = 0; j < chars.length; j++) {
        char c = chars[j];
        String w;
        if (i >= words.size()) {
            w = "";
            words.add(i, w);
        } else {
            w = (String) words.get(i);
        }

        if (Character.isLowerCase(c) || Character.isDigit(c)) {
            if (Character.isLowerCase(c) && w.length() == 0)
                c = Character.toUpperCase(c);
            else if (w.length() > 1 && Character.isUpperCase(w.charAt(w.length() - 1))) {
                w = "";
                words.add(++i, w);
            }

            words.set(i, w + c);
        } else if (Character.isUpperCase(c)) {
            if ((i == 0 && w.length() == 0) || Character.isUpperCase(w.charAt(w.length() - 1))) {
                words.set(i, w + c);
            } else {
                words.add(++i, String.valueOf(c));
            }
        }

    }

    StringBuffer buf = new StringBuffer();

    for (Iterator j = words.iterator(); j.hasNext();) {
        String word = (String) j.next();
        buf.append(word);
        if (j.hasNext())
            buf.append(' ');
    }
    return buf.toString();
}

From source file:org.languagetool.rules.uk.TokenAgreementRule.java

private static boolean isCapitalized(String token) {
    return token.length() > 1 && Character.isUpperCase(token.charAt(0))
            && Character.isLowerCase(token.charAt(1));
}

From source file:org.eclipse.virgo.ide.bundlor.jdt.core.ArtifactAnalyserTypeVisitor.java

private String recordFullyQualifiedName(String fqn) {
    if (!"void".equals(fqn)) {
        if (this.typePackage == null) {
            this.referencedTypes.add(fqn);
            return fqn;
        } else if (fqn != null && !this.typePackage.equals(getPackageName(fqn))) {
            // This is required to get FQCNs of the form
            // org.springframework.util.ReflectionUtils.MethodCallback correctly detected
            StringTokenizer segments = new StringTokenizer(fqn, ".");
            if (segments.countTokens() > 1) {
                List<String> newSegments = new ArrayList<String>();
                while (segments.hasMoreTokens()) {
                    String segment = segments.nextToken();
                    newSegments.add(segment);
                    if (!Character.isLowerCase(segment.charAt(0))) {
                        break;
                    }//from w  w  w.  j a v a 2 s .  co m
                }
                fqn = StringUtils.join(newSegments, ".");
            }

            this.partialManifest.recordReferencedType(fqn);
            return fqn;
        }
    }
    return "";
}

From source file:com.lines.activitys.SettingsActivity.java

/**
 * Method for checking if the current word is entirely capitals.
 * /*  w  w w  . j av  a 2  s. c  o m*/
 * @param word
 *            - check to see if this String is entirely uppercase
 * @return allCaps - true or false based on the result of the method
 */
private boolean isAllUpperCase(String word) {
    boolean allCaps = true;
    for (char c : word.toCharArray()) {
        if (Character.isLowerCase(c)) {
            allCaps = false;
            break;
        }
    }
    return allCaps;
}

From source file:com.nridge.core.base.field.Field.java

/**
 * Returns a title that has been derived from the name of the
 * field.  This method will handle the conversion as follows:
 *
 * <ul>/* ww  w  . ja v  a 2 s  .  c  om*/
 *     <li>id becomes Id</li>
 *     <li>employee_name becomes Employee Name</li>
 *     <li>federatedName becomes Federated Name</li>
 * </ul>
 *
 * The logic will ignore any other conventions and simply pass
 * the original character forward.
 *
 * @param aFieldName Name of the field to convert.
 *
 * @return Title for the field name.
 */
public static String nameToTitle(String aFieldName) {
    if (StringUtils.isNotEmpty(aFieldName)) {
        char curChar;
        boolean isLastSpace = true;
        boolean isLastLower = false;

        StringBuilder stringBuilder = new StringBuilder();
        int strLength = aFieldName.length();
        for (int i = 0; i < strLength; i++) {
            curChar = aFieldName.charAt(i);

            if ((curChar == StrUtl.CHAR_UNDERLINE) || (curChar == StrUtl.CHAR_DOT)) {
                curChar = StrUtl.CHAR_SPACE;
                stringBuilder.append(curChar);
            } else if (isLastSpace)
                stringBuilder.append(Character.toUpperCase(curChar));
            else if ((Character.isUpperCase(curChar)) && (isLastLower)) {
                stringBuilder.append(StrUtl.CHAR_SPACE);
                stringBuilder.append(curChar);
            } else
                stringBuilder.append(curChar);

            isLastSpace = (curChar == StrUtl.CHAR_SPACE);
            isLastLower = Character.isLowerCase(curChar);
        }

        return stringBuilder.toString();
    } else
        return aFieldName;
}

From source file:org.apache.ddlutils.task.DumpMetadataTask.java

/**
 * Derives the property name from the given method name.
 * // ww w  . ja va  2  s .c o  m
 * @param methodName The method name
 * @return The property name
 */
private String getPropertyName(String methodName) {
    if (methodName.startsWith("get")) {
        if (Character.isLowerCase(methodName.charAt(4))) {
            return Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4);
        } else {
            return methodName.substring(3);
        }
    } else if (methodName.startsWith("is")) {
        if (Character.isLowerCase(methodName.charAt(3))) {
            return Character.toLowerCase(methodName.charAt(2)) + methodName.substring(3);
        } else {
            return methodName.substring(2);
        }
    } else {
        return methodName;
    }
}