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(Locale locale) 

Source Link

Document

Converts all of the characters in this String to upper case using the rules of the given Locale .

Usage

From source file:Main.java

/**
 * Gets the md5 hashed and upper-cased device id.
 * /*from  w w w  . jav a  2 s.  co  m*/
 * @param context
 *            the application context.
 * @return The encoded device id.
 */
public static String getEncodedDeviceId(Context context) {
    String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);

    String hashedId;
    if ((androidId == null) || isEmulator()) {
        hashedId = md5("emulator");
    } else {
        hashedId = md5(androidId);
    }

    if (hashedId == null) {
        return null;
    }

    return hashedId.toUpperCase(Locale.US);
}

From source file:Main.java

private static String byteToHexStr(byte[] input) {
    if (input == null) {
        return "";
    }/*from w ww .  j  ava2  s  .com*/
    String output = "";
    String tmp = "";
    for (int n = 0; n < input.length; n++) {
        tmp = Integer.toHexString(input[n] & 0xFF);
        if (tmp.length() == 1) {
            output = output + "0" + tmp;
        } else {
            output = output + tmp;
        }
    }
    return output.toUpperCase(Locale.ENGLISH);
}

From source file:org.opendatakit.utilities.NameUtil.java

/**
 * Determines whether or not the given name is valid for a user-defined
 * entity in the database. Valid names are determined to not begin with a
 * single underscore, not to begin with a digit, and to contain only unicode
 * appropriate word characters./*w ww . j av  a 2s.c  o m*/
 *
 * @param name The string to be looked up in the list of definitely not allowed words
 * @return true if valid else false
 */
public static boolean isValidUserDefinedDatabaseName(String name) {
    boolean matchHit = letterFirstPattern.matcher(name).matches();
    // TODO: uppercase is bad...
    boolean reserveHit = Collections.binarySearch(reservedNamesSortedList, name.toUpperCase(Locale.US)) >= 0;
    return !reserveHit && matchHit;
}

From source file:Main.java

/**
 * Get the ip address for mesh usage(For mesh require the ip address hex uppercase without ".".
 * // ww w.j a  v  a 2  s .  c  o  m
 * @param hostname the ip address, e.g. 192.168.1.2
 * @return ip address by hex without ".", e.g. C0A80102
 */
public static String getIpAddressForMesh(String hostname) {
    StringBuilder sb = new StringBuilder();
    String[] segments = hostname.split("\\.");
    int segment;
    String segmentHexStr;
    for (int i = 0; i < segments.length; i++) {
        // get the integer
        segment = Integer.parseInt(segments[i]);
        // transform the integer to hex
        segmentHexStr = Integer.toHexString(segment);
        // transform the hex string to uppercase
        segmentHexStr = segmentHexStr.toUpperCase(Locale.US);
        // append segmentHexStr to the sb
        if (segmentHexStr.length() == 1) {
            sb.append("0");
            sb.append(segmentHexStr);
        } else if (segmentHexStr.length() == 2) {
            sb.append(segmentHexStr);
        } else {
            throw new RuntimeException();
        }
    }
    return sb.toString();
}

From source file:com.dgtlrepublic.anitomyj.KeywordManager.java

/** Returns a normalized string. */
public static String normalzie(String word) {
    if (StringUtils.isEmpty(word))
        return word;
    return word.toUpperCase(Locale.ENGLISH);
}

From source file:io.crate.metadata.PartitionName.java

/**
 * decodes an encoded ident into it's values
 *//*from ww  w  . j a  v  a  2  s  .c om*/
@Nullable
public static List<BytesRef> decodeIdent(@Nullable String ident) {
    if (ident == null) {
        return ImmutableList.of();
    }
    byte[] inputBytes = BASE32.decode(ident.toUpperCase(Locale.ROOT));
    try (StreamInput in = StreamInput.wrap(inputBytes)) {
        int size = in.readVInt();
        List<BytesRef> values = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            values.add(StringType.INSTANCE.streamer().readValueFrom(in));
        }
        return values;
    } catch (IOException e) {
        throw new IllegalArgumentException(String.format(Locale.ENGLISH, "Invalid partition ident: %s", ident),
                e);
    }
}