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:net.sourceforge.pmd.lang.java.rule.codestyle.LinguisticNamingRule.java

private static boolean containsWord(String name, String word) {
    int index = name.indexOf(word);
    if (index >= 0 && name.length() > index + word.length()) {
        return Character.isUpperCase(name.charAt(index + word.length()));
    }/*from ww  w .  j av  a2 s. co  m*/
    return false;
}

From source file:com.smart.utils.ReflectionUtils.java

/**
 * ?pojoget//from  w ww.jav  a 2  s  .  co m
 * 
 * @param fieldName
 * @return
 */
public static String getGetMethodName(String fieldName) {
    StringBuffer result = new StringBuffer("get");
    String firstChar = fieldName.substring(0, 1);
    char firstCh = fieldName.charAt(0);
    // if(firstCh)
    if (Character.isUpperCase(firstCh)) {
        result.append(firstCh);
    } else {
        result.append(firstChar.toUpperCase());

    }
    result.append(fieldName.substring(1, fieldName.length()));
    return result.toString();
}

From source file:com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck.java

/**
 * Gets the disallowed abbreviation contained in given String.
 * @param str//  ww w .  j a  v  a  2s .com
 *        the given String.
 * @return the disallowed abbreviation contained in given String as a
 *         separate String.
 */
private String getDisallowedAbbreviation(String str) {
    int beginIndex = 0;
    boolean abbrStarted = false;
    String result = null;

    for (int index = 0; index < str.length(); index++) {
        final char symbol = str.charAt(index);

        if (Character.isUpperCase(symbol)) {
            if (!abbrStarted) {
                abbrStarted = true;
                beginIndex = index;
            }
        } else if (abbrStarted) {
            abbrStarted = false;

            final int endIndex = index - 1;
            // -1 as a first capital is usually beginning of next word
            result = getAbbreviationIfIllegal(str, beginIndex, endIndex);
            if (result != null) {
                break;
            }
            beginIndex = -1;
        }
    }
    // if abbreviation at the end of name and it is not single character (example: scaleX)
    if (abbrStarted && beginIndex != str.length() - 1) {
        final int endIndex = str.length();
        result = getAbbreviationIfIllegal(str, beginIndex, endIndex);
    }
    return result;
}

From source file:com.rabbitframework.commons.utils.StringUtils.java

public static String toSeparatorName(String property, String separator) {
    StringBuilder result = new StringBuilder();
    if (property != null && property.length() > 0) {
        result.append(property.substring(0, 1).toLowerCase());
        for (int i = 1; i < property.length(); i++) {
            char ch = property.charAt(i);
            if (Character.isUpperCase(ch)) {
                result.append(separator);
                result.append(Character.toLowerCase(ch));
            } else {
                result.append(ch);/*from  www  . j ava2 s.c o m*/
            }
        }
    }
    return result.toString();
}

From source file:com.miz.functions.MizLib.java

/**
 * Adds spaces between capital characters.
 * @param s (input String)//  w w  w .  j av  a 2 s.co  m
 * @return Input string with spaces between capital characters.
 */
public static String addSpaceByCapital(String s) {
    if (TextUtils.isEmpty(s))
        return "";

    StringBuilder result = new StringBuilder();
    char[] chars = s.toCharArray();
    for (int i = 0; i < chars.length; i++)
        if (chars.length > (i + 1))
            if (Character.isUpperCase(chars[i])
                    && (Character.isLowerCase(chars[i + 1]) && !Character.isSpaceChar(chars[i + 1])))
                result.append(" ").append(chars[i]);
            else
                result.append(chars[i]);
        else
            result.append(chars[i]);
    return result.toString().trim();
}

From source file:com.webcohesion.enunciate.modules.php_json_client.PHPJSONClientModule.java

protected boolean usesUnmappableElements() {
    boolean usesUnmappableElements = false;

    if (this.jacksonModule != null && this.jacksonModule.getJacksonContext() != null) {
        for (TypeDefinition complexType : this.jacksonModule.getJacksonContext().getTypeDefinitions()) {
            if (!Character.isUpperCase(complexType.getClientSimpleName().charAt(0))) {
                warn("%s: PHP requires your class name to be upper-case. Please rename the class or apply the @org.codehaus.enunciate.ClientName annotation to the class.",
                        positionOf(complexType));
                usesUnmappableElements = true;
            }// w w  w. j  a  v  a  2s .  c  o m
        }
    }

    if (this.jackson1Module != null && this.jackson1Module.getJacksonContext() != null) {
        for (com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition complexType : this.jackson1Module
                .getJacksonContext().getTypeDefinitions()) {
            if (!Character.isUpperCase(complexType.getClientSimpleName().charAt(0))) {
                warn("%s: PHP requires your class name to be upper-case. Please rename the class or apply the @org.codehaus.enunciate.ClientName annotation to the class.",
                        positionOf(complexType));
                usesUnmappableElements = true;
            }
        }
    }

    return usesUnmappableElements;
}

From source file:com.jigsforjava.string.StringUtils.java

/**
 * Converts a camel case string into a lower-case, delimiter-separated
 * string. For example, a call of toSeparatedString("ACamelCaseString, '_')
 * returns a_camel_case_string.//from w  ww .  j a v  a 2 s .c  o m
 * 
 * @param camelCaseString
 *            a String in camel case to delimit.
 * @param delimiter
 *            the character used to separate the string.
 * @return a String where capitals in the original are prefixed with the
 *         given delimiter.
 */
public static String toSeparatedString(String camelCaseString, char delimiter) {
    CharArrayWriter result = new CharArrayWriter();
    char[] chars = camelCaseString.toCharArray();

    for (int i = 0; i < chars.length; ++i) {
        if (chars[i] != delimiter && Character.isUpperCase(chars[i]) && i > 0) {
            if ((i < chars.length - 1) && (!Character.isUpperCase(chars[i + 1]) && chars[i + 1] != delimiter)
                    && chars[i - 1] != delimiter)
                result.write(delimiter);
            else if (!Character.isUpperCase(chars[i - 1]) && chars[i - 1] != delimiter)
                result.write(delimiter);
        }

        result.write(chars[i]);
    }

    return result.toString().toLowerCase();
}

From source file:org.kuali.rice.edl.impl.components.WorkflowDocumentState.java

public static void addActions(Document dom, Element documentState, List actions) {
    Element actionsPossible = EDLXmlUtils.getOrCreateChildElement(documentState, "actionsPossible", true);
    Iterator it = actions.iterator();
    while (it.hasNext()) {
        String action = it.next().toString();
        Element actionElement = dom.createElement(action);
        // if we use string.xsl we can avoid doing this here
        // (unless for some reason we decide we want different titles)
        if (!Character.isUpperCase(action.charAt(0))) {
            StringBuffer sb = new StringBuffer(action);
            sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
            action = sb.toString();// w  ww .  j a  v  a2 s. c  om
        }
        actionElement.setAttribute("title", action);
        actionsPossible.appendChild(actionElement);
    }

    Element annotatable = EDLXmlUtils.getOrCreateChildElement(documentState, "annotatable", true);
    annotatable.appendChild(dom.createTextNode(String.valueOf(isAnnotatable(actions))));
}

From source file:de.hybris.platform.test.CaseInsensitiveStringMapTest.java

private List<String> shuffleCase(final List<String> keys) {
    final List<String> shuffled = new ArrayList<String>(keys.size());
    for (final String key : keys) {
        final char[] chars = key.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            final char character = chars[i];
            if (Character.isUpperCase(character)) {
                chars[i] = Character.toLowerCase(character);
            } else if (Character.isLowerCase(character)) {
                chars[i] = Character.toUpperCase(character);
            }// ww  w . j a va2  s  . com
            shuffled.add(new String(chars));
        }
    }
    return shuffled;
}

From source file:com.gargoylesoftware.htmlunit.runners.TestCaseCorrector.java

private static void addMethodWithExpectation(final List<String> lines, int i, final String browserString,
        final String methodName, final ComparisonFailure comparisonFailure, final String defaultExpectations) {
    String parent = methodName;/*  w w w  . jav  a  2  s.  co  m*/
    final String child = parent.substring(parent.lastIndexOf('_') + 1);
    final int index = parent.indexOf('_', 1);
    if (index != -1) {
        parent = parent.substring(1, index);
    } else {
        parent = parent.substring(1);
    }

    if (!lines.get(i).isEmpty()) {
        i++;
    }
    lines.add(i++, "");
    lines.add(i++, "    /**");
    lines.add(i++, "     * @throws Exception if the test fails");
    lines.add(i++, "     */");
    lines.add(i++, "    @Test");
    lines.add(i++, "    @Alerts(DEFAULT = \"" + defaultExpectations + "\",");
    lines.add(i++, "            " + browserString + " = " + getActualString(comparisonFailure) + ")");
    if (index != -1) {
        lines.add(i++, "    public void _" + parent + "_" + child + "() throws Exception {");
        lines.add(i++, "        test(\"" + parent + "\", \"" + child + "\");");
    } else {
        String method = parent;
        for (final String prefix : HostExtractor.PREFIXES_) {
            if (method.startsWith(prefix)) {
                method = prefix.toLowerCase(Locale.ROOT) + method.substring(prefix.length());
                break;
            }
        }
        if (Character.isUpperCase(method.charAt(0))) {
            method = Character.toLowerCase(method.charAt(0)) + method.substring(1);
        }
        lines.add(i++, "    public void " + method + "() throws Exception {");
        lines.add(i++, "        test(\"" + parent + "\");");
    }
    lines.add(i++, "    }");
    lines.add(i++, "}");
    while (lines.size() > i) {
        lines.remove(i);
    }
}