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:android.databinding.tool.LayoutXmlProcessor.java

/**
 * Generates a string identifier that can uniquely identify the given layout bundle.
 * This identifier can be used when we need to export data about this layout bundle.
 *///from w ww  . j a v a2 s  .  c o m
public String generateExportFileName(ResourceBundle.LayoutFileBundle layout) {
    StringBuilder name = new StringBuilder(layout.getFileName());
    name.append('-').append(layout.getDirectory());
    for (int i = name.length() - 1; i >= 0; i--) {
        char c = name.charAt(i);
        if (c == '-') {
            name.deleteCharAt(i);
            c = Character.toUpperCase(name.charAt(i));
            name.setCharAt(i, c);
        }
    }
    return name.toString();
}

From source file:adalid.commons.util.StrUtils.java

private static String firstDigit(String string) {
    char c = Character.toUpperCase(string.charAt(0));
    int i = digitBetweenZeroAndEight(c);
    return i + "";
}

From source file:com.raspi.chatapp.util.Notification.java

public void createNotification(String buddyId, String name, String message, String type) {
    SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);

    if (defaultSharedPreferences
            .getBoolean(context.getResources().getString(R.string.pref_key_new_message_notifications), true)) {
        int index = buddyId.indexOf("@");
        if (index != -1)
            buddyId = buddyId.substring(0, index);
        if (name == null)
            name = buddyId;/*from w w w . j  a v  a 2  s .  co m*/
        Log.d("DEBUG", "creating notification: " + buddyId + "|" + name + "|" + message);
        Intent resultIntent = new Intent(context, ChatActivity.class);
        resultIntent.setAction(NOTIFICATION_CLICK);
        String oldBuddyId = getOldBuddyId();
        Log.d("DEBUG",
                (oldBuddyId == null) ? ("oldBuddy is null (later " + buddyId) : ("oldBuddy: " + oldBuddyId));
        if (oldBuddyId == null || oldBuddyId.equals("")) {
            oldBuddyId = buddyId;
            setOldBuddyId(buddyId);
        }
        if (oldBuddyId.equals(buddyId)) {
            resultIntent.putExtra(Constants.BUDDY_ID, buddyId);
            resultIntent.putExtra(Constants.CHAT_NAME, name);
        }

        TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
        stackBuilder.addParentStack(ChatActivity.class);
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationManager nm = ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));
        NotificationCompat.Style style;

        String[] previousNotifications = readJSONArray(CURRENT_NOTIFICATIONS);
        String title;
        String[] currentNotifications = Arrays.copyOf(previousNotifications, previousNotifications.length + 1);
        currentNotifications[currentNotifications.length - 1] = name + ": " + message;
        if (previousNotifications.length == 0) {
            style = new NotificationCompat.BigTextStyle();
            NotificationCompat.BigTextStyle bigTextStyle = ((NotificationCompat.BigTextStyle) style);
            title = context.getResources().getString(R.string.new_message) + " "
                    + context.getResources().getString(R.string.from) + " " + name;
            bigTextStyle.bigText(currentNotifications[0]);
            bigTextStyle.setBigContentTitle(title);
        } else {
            style = new NotificationCompat.InboxStyle();
            NotificationCompat.InboxStyle inboxStyle = (NotificationCompat.InboxStyle) style;
            title = (previousNotifications.length + 1) + " "
                    + context.getResources().getString(R.string.new_messages);
            for (String s : currentNotifications)
                if (s != null && !"".equals(s))
                    inboxStyle.addLine(s);
            inboxStyle.setSummaryText(
                    (currentNotifications.length > 2) ? ("+" + (currentNotifications.length - 2) + " more")
                            : null);
            inboxStyle.setBigContentTitle(title);
        }
        writeJSONArray(currentNotifications, CURRENT_NOTIFICATIONS);

        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setContentTitle(title)
                .setContentText(currentNotifications[currentNotifications.length - 1])
                .setSmallIcon(MessageHistory.TYPE_TEXT.equals(type) ? R.drawable.ic_forum_white_48dp
                        : R.drawable.ic_photo_camera_white_48dp)
                .setLargeIcon(getLargeIcon(Character.toUpperCase(name.toCharArray()[0]))).setStyle(style)
                .setAutoCancel(true).setPriority(5).setContentIntent(resultPendingIntent);

        String str = context.getResources().getString(R.string.pref_key_privacy);
        mBuilder.setVisibility(context.getResources().getString(R.string.pref_value1_privacy).equals(str)
                ? NotificationCompat.VISIBILITY_SECRET
                : context.getResources().getString(R.string.pref_value2_privacy).equals(str)
                        ? NotificationCompat.VISIBILITY_PRIVATE
                        : NotificationCompat.VISIBILITY_PUBLIC);

        str = context.getResources().getString(R.string.pref_key_vibrate);
        if (defaultSharedPreferences.getBoolean(str, true))
            mBuilder.setVibrate(new long[] { 800, 500, 800, 500 });

        str = context.getResources().getString(R.string.pref_key_led);
        if (defaultSharedPreferences.getBoolean(str, true))
            mBuilder.setLights(Color.BLUE, 500, 500);

        str = defaultSharedPreferences.getString(context.getResources().getString(R.string.pref_key_ringtone),
                "");
        mBuilder.setSound("".equals(str) ? RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
                : Uri.parse(str));

        nm.notify(NOTIFICATION_ID, mBuilder.build());
        str = context.getResources().getString(R.string.pref_key_banner);
        if (!defaultSharedPreferences.getBoolean(str, true)) {
            try {
                Thread.sleep(1500);
            } catch (InterruptedException e) {
            }
            reset();
        }
    }
}

From source file:fr.inria.atlanmod.neoemf.graph.blueprints.datastore.BlueprintsPersistenceBackendFactory.java

@Override
public BlueprintsPersistenceBackend createPersistentBackend(File file, Map<?, ?> options)
        throws InvalidDataStoreException {
    BlueprintsPersistenceBackend graphDB = null;
    PropertiesConfiguration neoConfig = null;
    PropertiesConfiguration configuration = null;
    try {// w w  w  . j ava 2s .c  o m
        // Try to load previous configurations
        Path path = Paths.get(file.getAbsolutePath()).resolve(CONFIG_FILE);
        try {
            configuration = new PropertiesConfiguration(path.toFile());
        } catch (ConfigurationException e) {
            throw new InvalidDataStoreException(e);
        }
        // Initialize value if the config file has just been created
        if (!configuration.containsKey(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE)) {
            configuration.setProperty(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE,
                    BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE_DEFAULT);
        } else if (options.containsKey(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE)) {
            // The file already existed, check that the issued options
            // are not conflictive
            String savedGraphType = configuration
                    .getString(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE);
            String issuedGraphType = options.get(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE)
                    .toString();
            if (!savedGraphType.equals(issuedGraphType)) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, "Unable to create graph as type " + issuedGraphType
                        + ", expected graph type was " + savedGraphType + ")");
                throw new InvalidDataStoreException("Unable to create graph as type " + issuedGraphType
                        + ", expected graph type was " + savedGraphType + ")");
            }
        }

        // Copy the options to the configuration
        for (Entry<?, ?> e : options.entrySet()) {
            configuration.setProperty(e.getKey().toString(), e.getValue().toString());
        }

        // Check we have a valid graph type, it is needed to get the
        // graph name
        String graphType = configuration.getString(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE);
        if (graphType == null) {
            throw new InvalidDataStoreException("Graph type is undefined for " + file.getAbsolutePath());
        }

        String[] segments = graphType.split("\\.");
        if (segments.length >= 2) {
            String graphName = segments[segments.length - 2];
            String upperCaseGraphName = Character.toUpperCase(graphName.charAt(0)) + graphName.substring(1);
            String configClassQualifiedName = MessageFormat.format(
                    "fr.inria.atlanmod.neoemf.graph.blueprints.{0}.config.Blueprints{1}Config", graphName,
                    upperCaseGraphName);
            try {
                ClassLoader classLoader = BlueprintsPersistenceBackendFactory.class.getClassLoader();
                Class<?> configClass = classLoader.loadClass(configClassQualifiedName);
                Field configClassInstanceField = configClass.getField("eINSTANCE");
                AbstractBlueprintsConfig configClassInstance = (AbstractBlueprintsConfig) configClassInstanceField
                        .get(configClass);
                Method configMethod = configClass.getMethod("putDefaultConfiguration", Configuration.class,
                        File.class);
                configMethod.invoke(configClassInstance, configuration, file);
                Method setGlobalSettingsMethod = configClass.getMethod("setGlobalSettings");
                setGlobalSettingsMethod.invoke(configClassInstance);
            } catch (ClassNotFoundException e1) {
                NeoLogger.log(NeoLogger.SEVERITY_WARNING,
                        "Unable to find the configuration class " + configClassQualifiedName);
                e1.printStackTrace();
            } catch (NoSuchFieldException e2) {
                NeoLogger.log(NeoLogger.SEVERITY_WARNING,
                        MessageFormat.format(
                                "Unable to find the static field eINSTANCE in class Blueprints{0}Config",
                                upperCaseGraphName));
                e2.printStackTrace();
            } catch (NoSuchMethodException e3) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR,
                        MessageFormat.format(
                                "Unable to find configuration methods in class Blueprints{0}Config",
                                upperCaseGraphName));
                e3.printStackTrace();
            } catch (InvocationTargetException e4) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, MessageFormat.format(
                        "An error occured during the exection of a configuration method", upperCaseGraphName));
                e4.printStackTrace();
            } catch (IllegalAccessException e5) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, MessageFormat.format(
                        "An error occured during the exection of a configuration method", upperCaseGraphName));
                e5.printStackTrace();
            }
        } else {
            NeoLogger.log(NeoLogger.SEVERITY_WARNING, "Unable to compute graph type name from " + graphType);
        }

        Graph baseGraph = null;
        try {
            baseGraph = GraphFactory.open(configuration);
        } catch (RuntimeException e) {
            throw new InvalidDataStoreException(e);
        }
        if (baseGraph instanceof KeyIndexableGraph) {
            graphDB = new BlueprintsPersistenceBackend((KeyIndexableGraph) baseGraph);
        } else {
            NeoLogger.log(NeoLogger.SEVERITY_ERROR,
                    "Graph type " + file.getAbsolutePath() + " does not support Key Indices");
            throw new InvalidDataStoreException(
                    "Graph type " + file.getAbsolutePath() + " does not support Key Indices");
        }
        // Save the neoconfig file
        Path neoConfigPath = Paths.get(file.getAbsolutePath()).resolve(NEO_CONFIG_FILE);
        try {
            neoConfig = new PropertiesConfiguration(neoConfigPath.toFile());
        } catch (ConfigurationException e) {
            throw new InvalidDataStoreException(e);
        }
        if (!neoConfig.containsKey(BACKEND_PROPERTY)) {
            neoConfig.setProperty(BACKEND_PROPERTY, BLUEPRINTS_BACKEND);
        }
    } finally {
        if (configuration != null) {
            try {
                configuration.save();
            } catch (ConfigurationException e) {
                // Unable to save configuration, supposedly it's a minor error,
                // so we log it without rising an exception
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, e);
            }
        }
        if (neoConfig != null) {
            try {
                neoConfig.save();
            } catch (ConfigurationException e) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, e);
            }
        }
    }
    return graphDB;
}

From source file:net.sf.zekr.ui.ZekrGlobalKeyListener.java

private int extractSwtBitKeyCode(Event event) {
    int keyCode = 0;
    if ((event.stateMask & SWT.CTRL) == SWT.CTRL) {
        keyCode = SWT.CTRL;/*from ww  w.  j a  v  a 2s. c  o m*/
    }
    if ((event.stateMask & SWT.COMMAND) == SWT.COMMAND) {
        keyCode = SWT.COMMAND;
    }
    if ((event.stateMask & SWT.ALT) == SWT.ALT) {
        keyCode |= SWT.ALT;
    }
    if ((event.stateMask & SWT.SHIFT) == SWT.SHIFT) {
        keyCode |= SWT.SHIFT;
    }
    if ((event.keyCode & SWT.KEYCODE_BIT) == 0) {
        keyCode |= Character.toUpperCase(event.keyCode);
    } else {
        keyCode |= event.keyCode;
    }
    if (keyCode == 0) {
        keyCode = event.character;
    }
    return keyCode;
}

From source file:com.ing.connector.util.WStringUtil.java

/**
 *  checkForSpecialWords --> uppercases any appropriate
 *                           word phrases
 *///from   w w  w .j a  v a2 s.c  o m
private String checkForSpecialWords(String aString) {
    String lString = aString;
    int lLength = lString.length();

    //************************************************************
    //the following logic checks for word phrases 2 char in length
    //************************************************************
    if (lLength >= 2) {
        String[] lArrayFor2 = new String[(lLength - 1)];

        for (int i = 0; i < lLength - 1; i++) {
            lArrayFor2[i] = lString.substring(i, i + 2);

            if (lArrayFor2[i].equalsIgnoreCase("MD") || lArrayFor2[i].equalsIgnoreCase("II")
                    || lArrayFor2[i].equalsIgnoreCase("IV")) {
                char[] lChar2 = lString.toCharArray();

                lChar2[i] = Character.toUpperCase(lChar2[i]);
                lChar2[i + 1] = Character.toUpperCase(lChar2[i + 1]);

                lString = new String(lChar2);
            }
        }
    }

    //************************************************************
    //the following logic checks for word phrases 3 char in length
    //************************************************************
    if (lLength >= 3) {
        String[] lArrayFor3 = new String[(lLength - 2)];

        for (int i = 0; i < lLength - 2; i++) {
            lArrayFor3[i] = lString.substring(i, i + 3);

            if (lArrayFor3[i].equalsIgnoreCase("III") || lArrayFor3[i].equalsIgnoreCase("CPA")) {
                char[] lChar3 = lString.toCharArray();

                lChar3[i] = Character.toUpperCase(lChar3[i]);
                lChar3[i + 1] = Character.toUpperCase(lChar3[i + 1]);
                lChar3[i + 2] = Character.toUpperCase(lChar3[i + 2]);

                lString = new String(lChar3);
            }
        }
    }

    //************************************************************
    //the following logic checks for word phrases 4 char in length
    //************************************************************
    if (lLength >= 4) {
        String[] lArrayFor4 = new String[(lLength - 3)];

        for (int i = 0; i < lLength - 3; i++) {
            lArrayFor4[i] = lString.substring(i, i + 4);

            //*** make uppercase
            if (lArrayFor4[i].equalsIgnoreCase("FLMI") || lArrayFor4[i].equalsIgnoreCase("CLCU")) {
                char[] lChar4 = lString.toCharArray();

                lChar4[i] = Character.toUpperCase(lChar4[i]);
                lChar4[i + 1] = Character.toUpperCase(lChar4[i + 1]);
                lChar4[i + 2] = Character.toUpperCase(lChar4[i + 2]);
                lChar4[i + 3] = Character.toUpperCase(lChar4[i + 3]);

                lString = new String(lChar4);
            }

            //*** make lowercase
            if (lArrayFor4[i].equalsIgnoreCase(" OR ") || lArrayFor4[i].equalsIgnoreCase(" OF ")) {
                char[] lChar4 = lString.toCharArray();

                lChar4[i + 1] = Character.toLowerCase(lChar4[i + 1]);
                lChar4[i + 2] = Character.toLowerCase(lChar4[i + 2]);

                lString = new String(lChar4);
            }
        }
    }

    //************************************************************
    //the following logic checks for word phrases 5 char in length
    //************************************************************
    if (lLength >= 5) {
        String[] lArrayFor5 = new String[(lLength - 4)];

        for (int i = 0; i < lLength - 4; i++) {
            lArrayFor5[i] = lString.substring(i, i + 5);

            //*** make lowercase
            if (lArrayFor5[i].equalsIgnoreCase(" AND ")) {
                char[] lChar5 = lString.toCharArray();

                lChar5[i + 1] = Character.toLowerCase(lChar5[i + 1]);
                lChar5[i + 2] = Character.toLowerCase(lChar5[i + 2]);
                lChar5[i + 3] = Character.toLowerCase(lChar5[i + 3]);

                lString = new String(lChar5);
            }
        }
    }

    return lString;
}

From source file:StringExaminer.java

/**
*
*
* @param char1/*from   w  ww . j av  a 2s. com*/
* @param char2
*
* @return
*/
protected boolean charsAreEqual(char char1, char char2) {
    return (this.ignoreCase()) ? (Character.toUpperCase(char1) == Character.toUpperCase(char2))
            : (char1 == char2);
}

From source file:com.jskj.assets.server.dataGen.GenData.java

private void addIntegerSetterGetting(TopLevelClass topLevelClass, IntrospectedTable introspectedTable,
        String name) {//from   ww  w  .  j a v  a 2 s. c  o  m
    CommentGenerator commentGenerator = context.getCommentGenerator();
    Field field = new Field();
    field.setVisibility(JavaVisibility.PROTECTED);
    // field.setType(FullyQualifiedJavaType.getIntInstance());
    field.setType(PrimitiveTypeWrapper.getIntegerInstance());
    field.setName(name);
    // field.setInitializationString("-1");
    commentGenerator.addFieldComment(field, introspectedTable);
    topLevelClass.addField(field);
    char c = name.charAt(0);
    String camel = Character.toUpperCase(c) + name.substring(1);
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("set" + camel);
    method.addParameter(new Parameter(PrimitiveTypeWrapper.getIntegerInstance(), name));
    method.addBodyLine("this." + name + "=" + name + ";");
    commentGenerator.addGeneralMethodComment(method, introspectedTable);
    topLevelClass.addMethod(method);
    method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setReturnType(PrimitiveTypeWrapper.getIntegerInstance());
    method.setName("get" + camel);
    method.addBodyLine("return " + name + ";");
    commentGenerator.addGeneralMethodComment(method, introspectedTable);
    topLevelClass.addMethod(method);
}

From source file:StringUtils.java

static public String contractToCamelCase(String string) {
    StringBuffer bff = new StringBuffer(string.length());
    boolean previousWasSpace = false;
    for (int i = 0; i < string.length(); i++) {
        char currentChar = string.charAt(i);
        if (currentChar == ' ') {
            previousWasSpace = true;//  w w  w .j  a  v  a  2 s  . c om
        } else {
            if (previousWasSpace)
                bff.append(Character.toUpperCase(currentChar));
            else
                bff.append(currentChar);
            previousWasSpace = false;
        }
    }
    return bff.toString();
}

From source file:com.adguard.filter.proxy.ProtocolDetector.java

/**
 * Searches for a substring in a byte array (ignoring characters case)
 *
 * @param bytes            Byte array to search in
 * @param searchStartIndex Index in the byte array (to start searching from that index)
 * @param searchString     Search string
 * @return true if substring was found//from   w w  w . j av a  2s.c o m
 */
private static boolean findStringIgnoreCase(byte[] bytes, int searchStartIndex, String searchString) {
    if ((bytes.length - searchStartIndex) < searchString.length()) {
        return false;
    }

    for (int i = 0; i < searchString.length(); i++) {
        char c = searchString.charAt(i);
        byte b = bytes[i + searchStartIndex];
        if (b != c && b != Character.toUpperCase(c)) {
            return false;
        }
    }

    return true;
}