]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/internal/ole/win32/GUID.java
ee1a6b87155f4a043d9cef9ed5e5eb77f589fa45
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / internal / ole / win32 / GUID.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2010 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.internal.ole.win32;
15
16 public final class GUID {
17         public int Data1;
18         public short Data2;
19         public short Data3;
20         public byte[] Data4 = new byte[8];
21         public static final int sizeof = COM.GUID_sizeof ();
22
23         static final String zeros = "00000000"; //$NON-NLS-1$
24
25 static String toHex (int v, int length) {
26         String t = Integer.toHexString (v).toUpperCase ();
27         int tlen = t.length ();
28         if (tlen > length) {
29                 t = t.substring (tlen - length);
30         }
31         return zeros.substring (0, Math.max (0, length - tlen)) + t;
32 }
33
34 @Override
35 public String toString () {
36         return '{' + toHex (Data1, 8) + '-' +
37                 toHex (Data2, 4) + '-' +
38                 toHex (Data3, 4) + '-' +
39                 toHex (Data4[0], 2) + toHex (Data4[1], 2) + '-' +
40                 toHex (Data4[2], 2) + toHex (Data4[3], 2) + toHex (Data4[4], 2) + toHex (Data4[5], 2) + toHex (Data4[6], 2) + toHex (Data4[7], 2) + '}';
41 }
42
43 }