45
|
1 /* ***** BEGIN LICENSE BLOCK *****
|
|
2 * Version: MPL 1.1
|
|
3 *
|
|
4 * The contents of this file are subject to the Mozilla Public License Version
|
|
5 * 1.1 (the "License"); you may not use this file except in compliance with
|
|
6 * the License. You may obtain a copy of the License at
|
|
7 * http://www.mozilla.org/MPL/
|
|
8 *
|
|
9 * Software distributed under the License is distributed on an "AS IS" basis,
|
|
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
11 * for the specific language governing rights and limitations under the
|
|
12 * License.
|
|
13 *
|
|
14 * The Original Code is Mozilla Communicator client code, released March 31, 1998.
|
|
15 *
|
|
16 * The Initial Developer of the Original Code is
|
|
17 * Netscape Communications Corporation.
|
|
18 * Portions created by Netscape are Copyright (C) 1998-1999
|
|
19 * Netscape Communications Corporation. All Rights Reserved.
|
|
20 *
|
|
21 * Contributor(s):
|
|
22 *
|
|
23 * IBM
|
|
24 * - Binding to permit interfacing between Mozilla and DWT
|
|
25 * - Copyright (C) 2003, 2004 IBM Corp. All Rights Reserved.
|
|
26 *
|
|
27 * ***** END LICENSE BLOCK ***** */
|
|
28 module dwt.internal.mozilla.nsID;
|
|
29
|
|
30 import dwt.dwthelper.utils;
|
|
31
|
|
32 /** @jniclass flags=cpp */
|
|
33 public class nsID {
|
|
34
|
|
35 public int m0;
|
|
36 public short m1;
|
|
37 public short m2;
|
|
38 public byte[] m3 = new byte[8];
|
|
39 public static final int sizeof = 16;
|
|
40
|
|
41 public nsID() {
|
|
42 }
|
|
43
|
|
44 public nsID(String id) {
|
|
45 Parse(id);
|
|
46 }
|
|
47
|
|
48 public bool Equals(nsID other) {
|
|
49 int /*long*/ ptr = XPCOM.nsID_new ();
|
|
50 XPCOM.memmove (ptr, this, nsID.sizeof);
|
|
51 int /*long*/ otherPtr = XPCOM.nsID_new ();
|
|
52 XPCOM.memmove (otherPtr, other, nsID.sizeof);
|
|
53 bool result = XPCOM.nsID_Equals (ptr, otherPtr) !is 0;
|
|
54 XPCOM.nsID_delete (ptr);
|
|
55 XPCOM.nsID_delete (otherPtr);
|
|
56 return result;
|
|
57 }
|
|
58
|
|
59 public void Parse (String aIDStr) {
|
|
60 if (aIDStr is null) throw new Error ();
|
|
61 int i = 0;
|
|
62 for (; i < 8; i++) m0 = (m0 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16);
|
|
63 if (aIDStr.charAt (i++) !is '-') throw new Error ();
|
|
64 for (; i < 13; i++) m1 = (short)((m1 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
|
|
65 if (aIDStr.charAt (i++) !is '-') throw new Error ();
|
|
66 for (; i < 18; i++) m2 = (short)((m2 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
|
|
67 if (aIDStr.charAt (i++) !is '-') throw new Error ();
|
|
68 for (; i < 21; i++) m3[0] = (byte)((m3[0] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
|
|
69 for (; i < 23; i++) m3[1] = (byte)((m3[1] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
|
|
70 if (aIDStr.charAt (i++) !is '-') throw new Error ();
|
|
71 for (; i < 26; i++) m3[2] = (byte)((m3[2] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
|
|
72 for (; i < 28; i++) m3[3] = (byte)((m3[3] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
|
|
73 for (; i < 30; i++) m3[4] = (byte)((m3[4] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
|
|
74 for (; i < 32; i++) m3[5] = (byte)((m3[5] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
|
|
75 for (; i < 34; i++) m3[6] = (byte)((m3[6] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
|
|
76 for (; i < 36; i++) m3[7] = (byte)((m3[7] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
|
|
77 }
|
|
78
|
|
79 }
|