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:de.xaniox.heavyspleef.core.game.Game.java

@Override
public void supply(Set<Variable> vars, Set<String> requested) {
    String gameStateName = gameState.name();
    gameStateName = Character.toUpperCase(gameStateName.charAt(0)) + gameStateName.substring(1);

    vars.add(new Variable("name", name));
    vars.add(new Variable("state", gameStateName));
    vars.add(new Variable("localized_state", gameState.getLocalizedName()));
    vars.add(new Variable("players", ingamePlayers.size()));
    vars.add(new Variable("dead", deadPlayers.size()));
    vars.add(new Variable("countdown", countdownTask != null ? countdownTask.getRemaining() : 0));
    vars.add(new Variable("is_countdown", countdownTask != null));

    for (String req : requested) {
        StringTokenizer tokenizer = new StringTokenizer(req, ":");

        String primaryReq = tokenizer.nextToken();

        boolean hasFlagRequest = primaryReq.equals(HAS_FLAG_PREFIX);
        boolean flagValueRequest = primaryReq.equals(FLAG_VALUE_PREFIX);

        if (hasFlagRequest || flagValueRequest) {
            if (!tokenizer.hasMoreTokens()) {
                throw new IllegalStateException("Requested variable '" + req
                        + "' must be followed by a flag name ('<request>:<flagpath>')");
            }//from w ww  .j  av a 2 s  .co  m

            String flagPath = tokenizer.nextToken();

            if (hasFlagRequest) {
                vars.add(new Variable(req, isFlagPresent(flagPath)));
            } else if (flagValueRequest) {
                AbstractFlag<?> flag = getFlag(flagPath);

                vars.add(new Variable(req, flag != null ? flag.getValue() : null));
            }
        }
    }
}

From source file:co.id.app.sys.util.StringUtils.java

/**
 * Return the getter method name for the given property name.
 *
 * @param property the property name/*from  ww w. j  av  a  2  s  .  co  m*/
 * @return the getter method name for the given property name.
 */
public static String toGetterName(String property) {
    HtmlStringBuffer buffer = new HtmlStringBuffer(property.length() + 3);

    buffer.append("get");
    buffer.append(Character.toUpperCase(property.charAt(0)));
    buffer.append(property.substring(1));

    return buffer.toString();
}

From source file:co.id.app.sys.util.StringUtils.java

/**
 * Return the is getter method name for the given property name.
 *
 * @param property the property name//www  .ja v  a 2  s  .c o m
 * @return the is getter method name for the given property name.
 */
public static String toIsGetterName(String property) {
    HtmlStringBuffer buffer = new HtmlStringBuffer(property.length() + 3);

    buffer.append("is");
    buffer.append(Character.toUpperCase(property.charAt(0)));
    buffer.append(property.substring(1));

    return buffer.toString();
}

From source file:keyboard.ecloga.com.eclogakeyboard.EclogaKeyboard.java

@Override
public void onKey(int primaryCode, int[] keyCodes) {
    final InputConnection ic = getCurrentInputConnection();

    playClick();//from   w  ww  .  ja  v a2s .c  om
    printChar = true;

    if (primaryCode != 126 && primaryCode != -5 && primaryCode != -1
            && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_1
            && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_2
            && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_3
            && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_4
            && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_5) {

        keyPressCounter++;

        if (keyPressCounter > 100 && keyPressCounter <= 1000 && keypresscounter1.equals("false")) {
            NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard",
                    System.currentTimeMillis());
            PendingIntent pending = PendingIntent.getActivity(this, 0, new Intent(this, Home.class), 0);

            notify.setLatestEventInfo(getApplicationContext(), "Warming up!", "Type more than 100 characters",
                    pending);
            notif.notify(0, notify);

            Preferences.setDefaults("keypresscounter1", "true", getApplicationContext());
        } else if (keyPressCounter > 10000 && keyPressCounter <= 10000 && keypresscounter2.equals("false")) {
            NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard",
                    System.currentTimeMillis());
            PendingIntent pending = PendingIntent.getActivity(this, 0, new Intent(this, Home.class), 0);

            notify.setLatestEventInfo(getApplicationContext(), "Keep it up!", "Type more than 1000 characters",
                    pending);
            notif.notify(0, notify);

            Preferences.setDefaults("keypresscounter2", "true", getApplicationContext());
        } else if (keyPressCounter > 10000 && keypresscounter3.equals("false")) {
            NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard",
                    System.currentTimeMillis());
            PendingIntent pending = PendingIntent.getActivity(this, 0, new Intent(this, Home.class), 0);

            notify.setLatestEventInfo(getApplicationContext(), "Typing master!",
                    "Type more than 10000 characters", pending);
            notif.notify(0, notify);

            Preferences.setDefaults("keypresscounter3", "true", getApplicationContext());
        }

        Preferences.setDefaults("keypresses", String.valueOf(keyPressCounter), getApplicationContext());
    }

    switch (primaryCode) {
    case 58:
        ic.commitText(":", 1);

        if (autoSpacing) {
            ic.commitText(" ", 1);
        }
        break;
    case 59:
        ic.commitText(";", 1);

        if (autoSpacing) {
            ic.commitText(" ", 1);
        }
        break;
    case 33:
        ic.commitText("!", 1);

        if (autoSpacing) {
            ic.commitText(" ", 1);
        }

        if (autoCapitalize) {
            caps = true;
            keyboard.setShifted(caps);
            kv.invalidateAllKeys();
            printChar = false;
        }
        break;
    case 63:
        ic.commitText("?", 1);

        if (autoSpacing) {
            ic.commitText(" ", 1);
        }

        if (autoCapitalize) {
            caps = true;
            keyboard.setShifted(caps);
            kv.invalidateAllKeys();
            printChar = false;
        }
        break;
    case -5:
        if (lang.equals("seclang")) {
            if (orient.equals("portrait")) {
                keyboard = prilang;
            } else if (orient.equals("landscape")) {
                keyboard = prilang_landscape;
            }
            kv.setKeyboard(keyboard);
            kv.invalidateAllKeys();
            lang = "prilang";
        } else if (lang.equals("prilang")) {
            if (orient.equals("portrait")) {
                keyboard = seclang;
            } else if (orient.equals("landscape")) {
                keyboard = seclang_landscape;
            }
            kv.setKeyboard(keyboard);
            kv.invalidateAllKeys();
            lang = "seclang";
        }
        break;
    case 32:
        ic.commitText(" ", 1);

        if (autoCapitalize) {
            if (String.valueOf(ic.getTextBeforeCursor(2, 0)).equals(". ")) {
                caps = true;
                keyboard.setShifted(caps);
                kv.invalidateAllKeys();
                printChar = false;
            }
        }
        break;
    case 126:
        ic.deleteSurroundingText(1, 0);

        if (autoCapitalize) {
            if (String.valueOf(ic.getTextBeforeCursor(1, 0)).equals(".")
                    || String.valueOf(ic.getTextBeforeCursor(2, 0)).equals(". ")
                    || String.valueOf(ic.getTextBeforeCursor(2, 0)).equals("")) {
                caps = true;
                keyboard.setShifted(caps);
                kv.invalidateAllKeys();
                printChar = false;
            }
        }
        break;
    case 44:
        ic.commitText(",", 1);

        if (autoSpacing) {
            ic.commitText(" ", 1);
        }
        break;
    case 46:
        ic.commitText(".", 1);

        if (autoSpacing) {
            ic.commitText(" ", 1);
        }

        if (autoCapitalize) {
            caps = true;
            keyboard.setShifted(caps);
            kv.invalidateAllKeys();
            printChar = false;
        }
        break;
    case -1:
        ic.performEditorAction(EditorInfo.IME_ACTION_GO);
        break;
    case EmojiKeyboardView.KEYCODE_EMOJI_1:
        keyboard = new Keyboard(this, R.xml.emoji_a1);
        kv.setKeyboard(keyboard);
        kv.invalidateAllKeys();
        emoji = 1;
        eScreen = 1;
        break;
    case EmojiKeyboardView.KEYCODE_EMOJI_2:
        keyboard = new Keyboard(this, R.xml.emoji_b1);
        kv.setKeyboard(keyboard);
        kv.invalidateAllKeys();
        emoji = 2;
        eScreen = 1;
        break;
    case EmojiKeyboardView.KEYCODE_EMOJI_3:
        keyboard = new Keyboard(this, R.xml.emoji_c1);
        kv.setKeyboard(keyboard);
        kv.invalidateAllKeys();
        emoji = 3;
        eScreen = 1;
        break;
    case EmojiKeyboardView.KEYCODE_EMOJI_4:
        keyboard = new Keyboard(this, R.xml.emoji_d1);
        kv.setKeyboard(keyboard);
        kv.invalidateAllKeys();
        emoji = 4;
        eScreen = 1;
        break;
    case EmojiKeyboardView.KEYCODE_EMOJI_5:
        keyboard = new Keyboard(this, R.xml.emoji_e1);
        kv.setKeyboard(keyboard);
        kv.invalidateAllKeys();
        emoji = 5;
        eScreen = 1;
        break;
    default:
        char code = (char) primaryCode;

        if (allCaps) {
            if (Character.isLetter(code) && capsLock) {
                code = Character.toLowerCase(code);
            } else if (Character.isLetter(code) && !capsLock) {
                code = Character.toUpperCase(code);
            }
        } else {
            if (Character.isLetter(code) && caps) {
                code = Character.toUpperCase(code);
            }
        }

        String character = String.valueOf(code);
        ic.commitText(character, 1);
    }

    if (printedDifferent) {
        ic.deleteSurroundingText(1, 0);
    }

    if (printedDot) {
        ic.deleteSurroundingText(1, 0);

        if (autoCapitalize) {
            caps = true;
            keyboard.setShifted(caps);
            kv.invalidateAllKeys();
            printChar = false;
        }
    }

    if (doubleUp == 2) {
        capsChange();
    } else {
        changeCaps();
    }
}

From source file:mil.army.usace.data.dataquery.rdbms.RdbmsDataQuery.java

public String dbToClassName(String dbName) throws ClassNotFoundException {
    String className = "";
    for (int i = 0; i < dbName.length(); i++) {
        if (i == 0)
            className += Character.toUpperCase(dbName.charAt(i));
        else {/*from   w ww  . j  a  v  a2  s  . c om*/
            char c = dbName.charAt(i);
            if (c == '_') {
                i++;
                className += Character.toUpperCase(dbName.charAt(i));
            } else {
                className += Character.toLowerCase(c);
            }
        }
    }
    return className;
}

From source file:co.id.app.sys.util.StringUtils.java

/**
 * Return a field label string from the given field name. For example:
 * <pre class="codeHtml">/*  w  w w.j  a v a  2  s  .  co m*/
 * <span class="blue">faxNumber</span> &nbsp; -&gt; &nbsp; <span class="red">Fax Number</span> </pre>
 *
 * @param name the field name
 * @return a field label string from the given field name
 */
public static String toLabel(String name) {
    if (name == null) {
        throw new IllegalArgumentException("Null name parameter");
    }

    HtmlStringBuffer buffer = new HtmlStringBuffer();

    for (int i = 0, size = name.length(); i < size; i++) {
        char aChar = name.charAt(i);

        if (i == 0) {
            buffer.append(Character.toUpperCase(aChar));

        } else {
            buffer.append(aChar);

            if (i < name.length() - 1) {
                char nextChar = name.charAt(i + 1);
                if (Character.isLowerCase(aChar)
                        && (Character.isUpperCase(nextChar) || Character.isDigit(nextChar))) {
                    buffer.append(" ");
                }
            }
        }
    }

    return buffer.toString();
}

From source file:com.googlecode.wicketwebbeans.model.BeanMetaData.java

/**
 * Creates a human readable label from a Java identifier.
 * /* w  w w . j a va 2 s  . com*/
 * @param identifier the Java identifier.
 * 
 * @return the label.
 */
private static String createLabel(String identifier) {
    // Check for a complex property.
    int idx = identifier.lastIndexOf('.');
    if (idx < 0) {
        idx = identifier.lastIndexOf('$'); // Java nested classes.
    }

    if (idx >= 0 && identifier.length() > 1) {
        identifier = identifier.substring(idx + 1);
    }

    if (identifier.length() == 0) {
        return "";
    }

    char[] chars = identifier.toCharArray();
    StringBuffer buf = new StringBuffer(chars.length + 10);

    // Capitalize the first letter.
    buf.append(Character.toUpperCase(chars[0]));
    boolean lastLower = false;
    for (int i = 1; i < chars.length; ++i) {
        if (!Character.isLowerCase(chars[i])) {
            // Lower to upper case transition -- add space before it
            if (lastLower) {
                buf.append(' ');
            }
        }

        buf.append(chars[i]);
        lastLower = Character.isLowerCase(chars[i]) || Character.isDigit(chars[i]);
    }

    return buf.toString();
}

From source file:mil.army.usace.data.dataquery.rdbms.RdbmsDataQuery.java

public String dbToFieldName(String dbName) {
    String fieldName = "";
    for (int i = 0; i < dbName.length(); i++) {
        char c = dbName.charAt(i);
        if (c == '_') {
            i++;/*w  ww .ja  v a  2s  .c  om*/
            fieldName += Character.toUpperCase(dbName.charAt(i));
        } else {
            fieldName += Character.toLowerCase(c);
        }
    }
    return fieldName;
}

From source file:net.bashtech.geobot.JSONUtil.java

public static String toTitleCase(String givenString) {
    String[] arr = givenString.split(" ");
    StringBuffer sb = new StringBuffer();

    for (int i = 0; i < arr.length; i++) {
        sb.append(Character.toUpperCase(arr[i].charAt(0))).append(arr[i].substring(1)).append(" ");
    }//from   ww  w.  j av a 2  s  .co  m
    return sb.toString().trim();
}

From source file:com.kodemore.utility.Kmu.java

/**
 * Convert the input string into kneeling camel case, while delimiting on
 * any spaces./*www  .  j  av  a2  s . c o m*/
 */
public static String toKneelingCamelCase(String s) {
    StringBuilder out = new StringBuilder();
    boolean newWord = false;

    int n = s.length();
    for (int i = 0; i < n; i++) {
        char c = s.charAt(i);
        if (c == ' ') {
            newWord = true;
            continue;
        }

        if (newWord)
            c = Character.toUpperCase(c);

        out.append(c);
        newWord = false;
    }

    return lowercaseFirstLetter(out.toString());
}