Example usage for java.lang Character toUpperCase

List of usage examples for java.lang Character toUpperCase

Introduction

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

Prototype

public static int toUpperCase(int codePoint) 

Source Link

Document

Converts the character (Unicode code point) argument to uppercase using case mapping information from the UnicodeData file.

Usage

From source file:com.fonoster.astive.server.AstiveServer.java

private static void printUsage(AdminCommand ac, Options options) {
    String command = ac.getCommand();
    // capitalize command
    command = Character.toUpperCase(command.charAt(0)) + command.substring(1);
    HelpFormatter helpFormatter = new HelpFormatter();
    helpFormatter.setWidth(80);//from w  w  w .  j av  a2 s  . c  om
    helpFormatter.printHelp(AppLocale.getI18n("command" + command + "Usage"), AppLocale.getI18n("cliHeader"),
            options, AppLocale.getI18n("cliFooter"));
}

From source file:com.nridge.core.base.std.StrUtl.java

/**
 * Uses a simple Caesar-cypher encryption to replace each English letter
 * with the one 13 places forward or back along the alphabet, so that
 * "The butler did it!" becomes "Gur ohgyre qvq vg!".   major advantage
 * of rot13 over rot(N) for other N is that it is self-inverse, so the
 * same code can be used for encoding and decoding.
 *
 * @param aString A plain text string to encode.
 * @return An encrypted <i>String</i> object.
 *//*from   w  w  w . ja  v  a2s .  c o m*/
public static String simple13Rotation(String aString) {
    char ch, chUp;
    int strLength;
    StringBuilder strBuilder;

    if (StringUtils.isEmpty(aString))
        return aString;
    else {
        strBuilder = new StringBuilder();

        strLength = aString.length();
        for (int i = 0; i < strLength; i++) {
            ch = aString.charAt(i);
            if (Character.isLetter(ch)) {
                chUp = Character.toUpperCase(ch);
                if ((chUp >= 'A') && (chUp <= 'M'))
                    ch += 13;
                else
                    ch -= 13;
            }
            strBuilder.append(ch);
        }

        return strBuilder.toString();
    }
}

From source file:de.espend.idea.shopware.util.ShopwareUtil.java

private static String ucfirst(String subject) {
    return Character.toUpperCase(subject.charAt(0)) + subject.substring(1);
}

From source file:jp.co.opentone.bsol.framework.test.util.AssertMapComparer.java

/**
 * ???????./*from ww  w .ja  va 2s.c o m*/
 * <p>
 * "project_id"????"projectId"???
 * @param keyName ????
 * @return ??
 */
private String toFieldName(String keyName) {
    String fieldName = null;
    if (null != keyName) {
        StringBuilder builder = new StringBuilder();
        boolean isPrevUnderScore = false;
        for (int i = 0; i < keyName.length(); i++) {
            char ch = keyName.charAt(i);
            if ('_' == ch) {
                isPrevUnderScore = true;
            } else {
                if (isPrevUnderScore) {
                    builder.append(Character.toUpperCase(ch));
                    isPrevUnderScore = false;
                } else {
                    builder.append(ch);
                }
            }
        }
        fieldName = builder.toString();
    }
    return fieldName;
}

From source file:com.jk.util.JKObjectUtil.java

/**
 * Fix property name./*from  w ww . j  ava2  s .  c o  m*/
 *
 * @param name
 *            the name
 * @return the string
 */
////////////////////////////////////////////////////////////////////////////////////////////
public static String fixPropertyName(String name) {
    // captialize every char after the underscore , and remove underscores
    final char[] charArray = name.toCharArray();
    for (int i = 0; i < charArray.length; i++) {
        if (charArray[i] == '_') {
            charArray[i + 1] = Character.toUpperCase(charArray[i + 1]);
        }
    }
    name = new String(charArray).replaceAll("_", "");
    return name;
}

From source file:com.joliciel.talismane.tokeniser.patterns.TokenPatternImpl.java

private void addPattern(String testPattern, int start, int end, List<Pattern> parsedPattern,
         boolean inException) {
     if (start == end)
         return;/*from ww  w . j av a  2 s .c om*/

     String regex = testPattern.substring(start, end);

     if (regex.equals("\\p")) {
         // all separators
         parsedPattern.add(this.separatorPattern);
     } else {
         if (parsedPattern.size() == 0
                 || (parsedPattern.size() == 1 && parsedPattern.get(0).pattern().equals("\\b"))) {
             // automatically add upper-case characters
             char c = testPattern.charAt(start);
             if (c == '(') {
                 String patternOpening = "(";
                 String patternToSplit = regex.substring(1, regex.indexOf(')'));
                 if (patternToSplit.startsWith("?!")) {
                     patternToSplit = patternToSplit.substring(2);
                     patternOpening += "?!";
                 }
                 String[] patternParts = patternToSplit.split("\\|");
                 String patternClosing = regex.substring(regex.indexOf(')'));
                 regex = patternOpening;
                 boolean firstPart = true;
                 for (String patternPart : patternParts) {
                     if (patternPart.length() > 0) {
                         if (!firstPart)
                             regex += "|";
                         char c2 = patternPart.charAt(0);
                         if (c2 != Character.toUpperCase(c2)) {
                             regex += "[" + this.getCharacters(c2) + "]" + patternPart.substring(1);
                         } else {
                             regex += patternPart;
                         }
                         firstPart = false;
                     }
                 }
                 regex += patternClosing;
             }
             if (c != Character.toUpperCase(c)) {
                 regex = "[" + this.getCharacters(c) + "]" + regex.substring(1);
             }
         }

         // We never add the first pattern to the indexesToTest
         // since the interval concerns the interval between a token and the one preceeding it.

         boolean isSeparatorClass = regex.equals("\\p") || regex.equals("\\s") || regex.equals("\\b");
         isSeparatorClassList.add(isSeparatorClass);
         if (isSeparatorClass && parsedPattern.size() == 0)
             startsWithSeparatorClass = true;

         if (!(parsedPattern.size() == 0 || (parsedPattern.size() == 1 && startsWithSeparatorClass)
                 || inException || isSeparatorClass)) {
             indexesToTest.add(parsedPattern.size());
         }

         parsedPattern.add(Pattern.compile(regex));
     }
 }

From source file:fi.ni.IFC_ClassModel.java

/**
 * Format set method./*from   ww  w  . j  a  v a  2 s  .co m*/
 * 
 * @param s
 *            the s
 * @return the string
 */
static public String formatSetMethod(String s) {
    if (s == null)
        return null;
    StringBuffer sb = new StringBuffer();
    sb.append("set");
    sb.append(Character.toUpperCase(s.charAt(0)));
    sb.append(s.substring(1));
    return sb.toString();
}

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  ww  .  ja  v  a2  s.  c  om
 */
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: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>//w  ww .  j a  va2s.  c o m
 *     <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:com.prowidesoftware.swift.model.SwiftBlock2Input.java

/**
 * Sets the block's attributes by parsing the string argument containing the blocks value.<br /> 
 * This value can be in different flavors because some fields are optional.<br />
 * Example of supported values:<br />
 * <pre>/*from  w w w  . j  av a2 s.co  m*/
 * "I100BANKDEFFXXXX"      (16) or "2:I100BANKDEFFXXXX"      (18)   // used for service/system messages
 * "I100BANKDEFFXXXXU"     (17) or "2:I100BANKDEFFXXXXU"     (19)
 * "I100BANKDEFFXXXXU3"    (18) or "2:I100BANKDEFFXXXXU3"    (20)
 * "I100BANKDEFFXXXXU3003" (21) or "2:I100BANKDEFFXXXXU3003" (23)
 * </pre><br />
 * 
 * @param value string containing the entire blocks value
 * @param lenient if true the value will be parsed with a best effort heuristic, if false it will throw a IllegalArgumentException if the value has an invalid total size
 */
public void setValue(final String value, boolean lenient) {
    if (lenient) {
        //leave all attributes as null (cleaning defaults)
        clean();
    } else {
        // check parameters
        Validate.notNull(value, "value must not be null");
    }

    if (value != null) {
        int slen = value.length();

        if (!lenient) {
            // check parameters
            Validate.notNull(value, "value must not be null");
            Validate.isTrue(slen >= 16 && slen <= 23,
                    "expected a string value of 17 up to 23 chars and obtained a " + slen + " chars string: '"
                            + value + "'");
        }

        // figure out the starting point and check the input value has proper optional
        int offset = 0;
        if (value.startsWith("2:")) { // accept 2:...
            offset = 2;
        }

        slen -= offset;
        if (!lenient) {
            if (slen != 16 && slen != 17 && slen != 18 && slen != 21) {
                throw new IllegalArgumentException(
                        "Value must match: I<mt><address>[<pri>[<monitoring>[<obsolescence>]]]");
            }
            if (Character.toUpperCase(value.charAt(offset)) != 'I') {
                throw new IllegalArgumentException(
                        "Value must match: I<mt><address>[<pri>[<monitoring>[<obsolescence>]]]");
            }
        }
        offset++; // skip the input mark

        // separate value fragments
        int len = 3;
        this.setMessageType(this.getValuePart(value, offset, len));
        offset += len;

        len = 12;
        this.setReceiverAddress(this.getValuePart(value, offset, len));
        offset += len;

        len = 1;
        this.setMessagePriority(this.getValuePart(value, offset, len));
        offset += len; // optional (system messages)

        len = 1;
        this.setDeliveryMonitoring(this.getValuePart(value, offset, len));
        offset += len; // optional

        if (lenient) {
            //get all remaining text
            this.setObsolescencePeriod(this.getValuePart(value, offset));
        } else {
            len = 3;
            this.setObsolescencePeriod(this.getValuePart(value, offset, len));
        }

    }
}