Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.UUID;

public class Main {
    public static UUID UUID(byte abyte0[]) {
        StringBuilder stringbuilder;
        switch (abyte0.length) {
        default:
            return null;

        case 2: // '\002'
            Object aobj4[] = new Object[2];
            aobj4[0] = Byte.valueOf(abyte0[0]);
            aobj4[1] = Byte.valueOf(abyte0[1]);
            return UUID16(String.format("%02x%02x", aobj4));

        case 16: // '\020'
            stringbuilder = new StringBuilder(128);
            break;
        }
        Object aobj[] = new Object[4];
        aobj[0] = Byte.valueOf(abyte0[0]);
        aobj[1] = Byte.valueOf(abyte0[1]);
        aobj[2] = Byte.valueOf(abyte0[2]);
        aobj[3] = Byte.valueOf(abyte0[3]);
        stringbuilder.append(String.format("%02x%02x%02x%02x", aobj));
        Object aobj1[] = new Object[4];
        aobj1[0] = Byte.valueOf(abyte0[4]);
        aobj1[1] = Byte.valueOf(abyte0[5]);
        aobj1[2] = Byte.valueOf(abyte0[6]);
        aobj1[3] = Byte.valueOf(abyte0[7]);
        stringbuilder.append(String.format("-%02x%02x-%02x%02x", aobj1));
        Object aobj2[] = new Object[4];
        aobj2[0] = Byte.valueOf(abyte0[8]);
        aobj2[1] = Byte.valueOf(abyte0[9]);
        aobj2[2] = Byte.valueOf(abyte0[10]);
        aobj2[3] = Byte.valueOf(abyte0[11]);
        stringbuilder.append(String.format("-%02x%02x-%02x%02x", aobj2));
        Object aobj3[] = new Object[4];
        aobj3[0] = Byte.valueOf(abyte0[12]);
        aobj3[1] = Byte.valueOf(abyte0[13]);
        aobj3[2] = Byte.valueOf(abyte0[14]);
        aobj3[3] = Byte.valueOf(abyte0[15]);
        stringbuilder.append(String.format("%02x%02x%02x%02x", aobj3));
        return UUID128(stringbuilder.toString());
    }

    public static UUID UUID16(String s) {
        return java.util.UUID.fromString(String.format("0000%4s-0000-1000-8000-00805f9b34fb", new Object[] { s }));
    }

    public static UUID UUID128(String s) {
        return java.util.UUID.fromString(s);
    }
}