Example usage for java.util UUID fromString

List of usage examples for java.util UUID fromString

Introduction

In this page you can find the example usage for java.util UUID fromString.

Prototype

public static UUID fromString(String name) 

Source Link

Document

Creates a UUID from the string standard representation as described in the #toString method.

Usage

From source file:Main.java

/**
 * Obtains a UUID from Short style value.
 *
 * @param uuidShortValue the Short style UUID value.
 * @return an UUID instance.// w  w  w .j  a va2 s.  com
 */
@NonNull
public static UUID fromShortValue(final int uuidShortValue) {
    return UUID.fromString(
            "0000" + String.format("%04X", uuidShortValue & 0xffff) + "-0000-1000-8000-00805F9B34FB");
}

From source file:Main.java

public static String UUID(String key) {
    return UUID.fromString(key).toString();
}

From source file:Main.java

public static BluetoothSocket createBluetoothSocket(BluetoothDevice device) throws IOException {
    UUID uuid = UUID.fromString(SERIAL_SERVICE_UUID);
    BluetoothSocket socket = null;//from   ww w .  j  a v  a2  s  . co m
    if (Build.VERSION.SDK_INT >= 10) {
        try {
            final Method m = device.getClass().getMethod("createInsecureRfcommSocketToServiceRecord",
                    new Class[] { UUID.class });
            System.out.println("Performing invoke");
            socket = (BluetoothSocket) m.invoke(device, uuid);
            System.out.println("Invoke done");
            System.out.println(socket);
        } catch (Exception e) {
            Log.e("error", "Could not create Insecure RFComm Connection", e);
        }
    } else {
        //TODO, support older versions with secure connection
    }
    return socket;
}

From source file:Main.java

public static UUID parseUUID(String uuidValue) {
    try {//w ww  .  j ava  2 s. c  om
        return UUID.fromString(uuidValue);
    } catch (IllegalArgumentException x) {
        StringBuilder buf = new StringBuilder(36);
        buf.append(uuidValue);

        while (buf.length() < 32) {
            buf.insert(0, '0');
        }

        buf.insert(8, '-');
        buf.insert(13, '-');
        buf.insert(18, '-');
        buf.insert(23, '-');

        return UUID.fromString(buf.toString());
    }
}

From source file:Main.java

/**
 * Parses a UUID string with the format defined by toString().
 *
 * @param uuidString the UUID string to parse.
 * @return an UUID instance./*from w ww .j ava 2  s.c  om*/
 * @throws java.lang.NullPointerException if uuid is null.
 * @throws java.lang.IllegalArgumentException if uuid is not formatted correctly.
 */
@NonNull
public static UUID fromString(@NonNull final String uuidString) {
    try {
        return UUID.fromString(uuidString);
    } catch (IllegalArgumentException e) {
        // may be a short style
        return UUID.fromString("0000" + uuidString + "-0000-1000-8000-00805F9B34FB");
    }
}

From source file:com.hengyi.japp.tools.UuidUtils.java

public static String encodeBase64Uuid(String uuidString) {
    UUID uuid = UUID.fromString(uuidString);
    return base64Uuid(uuid);
}

From source file:Main.java

public static UUID stringToUuid(String uuidStr) {
    if (uuidStr.length() == 4) {
        uuidStr = BASE_UUID_START + uuidStr + BASE_UUID_END;
    }/*from  www  .jav a  2  s .co  m*/
    return UUID.fromString(uuidStr);
}

From source file:com.destroystokyo.debuggery.api.DebuggeryPlayer.java

/**
 * Get a player object from the string provided.
 * The provided string can be either a UUID or a player's name
 *
 * @param string UUID or nickname to check
 * @return a player object if it can be found or null if it can't
 * @throws IllegalArgumentException if string is null
 *//*from   w ww  .  j a  v a2  s.  c  o m*/
public static Player getPlayerFromString(String string) throws IllegalArgumentException {
    Validate.notNull(string, "String cannot be null!");
    Player player;
    try {
        UUID playerUUID = UUID.fromString(string);
        player = Bukkit.getServer().getPlayer(playerUUID);
    } catch (IllegalArgumentException e) {
        player = Bukkit.getServer().getPlayer(string);
    }
    return player;
}

From source file:com.proofpoint.event.client.TestingUtils.java

public static List<FixedDummyEventClass> getEvents() {
    return ImmutableList.of(
            new FixedDummyEventClass("localhost", new DateTime("2011-09-09T01:35:28.333Z"),
                    UUID.fromString("8e248a16-da86-11e0-9e77-9fc96e21a396"), 5678, "foo"),
            new FixedDummyEventClass("localhost", new DateTime("2011-09-09T01:43:18.123Z"),
                    UUID.fromString("94ac328a-da86-11e0-afe9-d30a5b7c4f68"), 1, "bar"),
            new FixedDummyEventClass("localhost", new DateTime("2011-09-09T01:45:55.555Z"),
                    UUID.fromString("a30671a6-da86-11e0-bc43-971987242263"), 1234, "hello"));
}

From source file:com.vangent.hieos.services.xds.bridge.utils.UUIDUtils.java

/**
 * Method description/* ww w. j av a  2  s  .c  om*/
 *
 *
 * @param uuidstr
 *
 * @return
 */
public static boolean isUUID(String uuidstr) {

    boolean result = false;

    try {

        UUID.fromString(uuidstr);

        result = true;

    } catch (IllegalArgumentException e) {

        // don't care
    }

    return result;
}