Example usage for java.lang String toUpperCase

List of usage examples for java.lang String toUpperCase

Introduction

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

Prototype

public String toUpperCase() 

Source Link

Document

Converts all of the characters in this String to upper case using the rules of the default locale.

Usage

From source file:Main.java

public static String getDeviceName() {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;
    if (model.startsWith(manufacturer)) {
        return model.toUpperCase();
    } else {/*from   w w  w. j  a va2  s .  c o m*/
        return manufacturer + " " + model;
    }
}

From source file:Main.java

public static Object addInUpperCase(Object c, String s) {
    if (c.getClass().isAssignableFrom(List.class)) {
        ((List) c).add(s.toUpperCase());
    } else if (c.getClass().isAssignableFrom(ArrayList.class)) {
        ((ArrayList) c).add(s.toUpperCase());
    }/*from w ww.j a  v a  2s. c o  m*/
    return c;
}

From source file:Main.java

public static byte[] ConvertStringToHexBytesArray(String StringToConvert) {
    StringToConvert = StringToConvert.toUpperCase();
    StringToConvert = StringToConvert.replaceAll(" ", "");
    char[] CharArray = StringToConvert.toCharArray();
    char[] Char = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
    int result = 0;
    byte[] ConvertedString = new byte[StringToConvert.length() / 2];
    int iStringLen = (StringToConvert.length());

    for (int i = 0; i < iStringLen; i++) {
        for (int j = 0; j <= 15; j++) {
            if (CharArray[i] == Char[j]) {
                if (i % 2 == 1) {
                    result = result + j;
                    j = 15;/*from   w ww  .j a  va  2s  . c om*/
                }

                else if (i % 2 == 0) {
                    result = result + j * 16;
                    j = 15;
                }

            }
        }
        if (i % 2 == 1) {
            ConvertedString[i / 2] = (byte) result;
            result = 0;
        }
    }

    return ConvertedString;
}

From source file:Main.java

/**
 * Convert a string containing hexadecimal characters to a byte-array.
 *
 * @param s a hex string/*from w ww .  j av a 2 s.c o m*/
 * @return a byte array with the corresponding value
 */
public static byte[] fromHexString(String s) {
    char[] rawChars = s.toUpperCase().toCharArray();

    int hexChars = 0;
    for (int i = 0; i < rawChars.length; i++) {
        if ((rawChars[i] >= '0' && rawChars[i] <= '9') || (rawChars[i] >= 'A' && rawChars[i] <= 'F')) {
            hexChars++;
        }
    }

    byte[] byteString = new byte[(hexChars + 1) >> 1];

    int pos = hexChars & 1;

    for (int i = 0; i < rawChars.length; i++) {
        if (rawChars[i] >= '0' && rawChars[i] <= '9') {
            byteString[pos >> 1] <<= 4;
            byteString[pos >> 1] |= rawChars[i] - '0';
        } else if (rawChars[i] >= 'A' && rawChars[i] <= 'F') {
            byteString[pos >> 1] <<= 4;
            byteString[pos >> 1] |= rawChars[i] - 'A' + 10;
        } else {
            continue;
        }
        pos++;
    }

    return byteString;
}

From source file:monasca.common.model.alarm.AlarmSeverity.java

@JsonCreator
public static AlarmSeverity fromJson(@JsonProperty("severity") String text) {
    return AlarmSeverity.valueOf(text.toUpperCase());
}

From source file:Main.java

public static String upcaseFileName(String s) {
    if (System.getProperty("file.separator").equals("\\")) {
        return s.toUpperCase();
    } else {// w  w w  . ja  v a2  s.  com
        return s;
    }
}

From source file:Main.java

public static String capitalize(String string) {
    if (isNullOrEmpty(string))
        return string;
    return string.toUpperCase().substring(0, 1) + string.toLowerCase().substring(1);
}

From source file:Main.java

/**
 * <p>/* w  ww. j  a v a  2 s . co  m*/
 * Convert a String to upper case, <code>null</code> String returns <code>null</code>.
 * </p>
 *
 * @param str the String to uppercase
 * @return the upper cased String
 */
public static String upperCase(String str) {
    if (str == null) {
        return null;
    }
    return str.toUpperCase();
}

From source file:Main.java

public static String castHexKeyboard(String sInput) {
    String sOutput = "";

    sInput = sInput.toUpperCase();
    char[] cInput = sInput.toCharArray();

    for (int i = 0; i < sInput.length(); i++) {
        if (cInput[i] != '0' && cInput[i] != '1' && cInput[i] != '2' && cInput[i] != '3' && cInput[i] != '4'
                && cInput[i] != '5' && cInput[i] != '6' && cInput[i] != '7' && cInput[i] != '8'
                && cInput[i] != '9' && cInput[i] != 'A' && cInput[i] != 'B' && cInput[i] != 'C'
                && cInput[i] != 'D' && cInput[i] != 'E') {
            cInput[i] = 'F';
        }/*  w  w  w  .j a v a  2 s . co m*/
        sOutput += cInput[i];
    }

    return sOutput;
}

From source file:Main.java

public static String convertColorToHexString(java.awt.Color c) {
    String str = Integer.toHexString(c.getRGB() & 0xFFFFFF);
    return ("#" + "000000".substring(str.length()) + str.toUpperCase());
}