1 28 package org.eclipse.swt.internal.mozilla; 29 30 public class nsID { 31 32 public int m0; 33 public short m1; 34 public short m2; 35 public byte[] m3 = new byte[8]; 36 public static final int sizeof = 16; 37 38 public nsID() { 39 } 40 41 public nsID(String id) { 42 Parse(id); 43 } 44 45 public boolean Equals(nsID other) { 46 int ptr = XPCOM.nsID_new(); 47 XPCOM.memmove(ptr, this, nsID.sizeof); 48 int otherPtr = XPCOM.nsID_new(); 49 XPCOM.memmove(otherPtr, other, nsID.sizeof); 50 boolean result = XPCOM.nsID_Equals(ptr, otherPtr); 51 XPCOM.nsID_delete(ptr); 52 XPCOM.nsID_delete(otherPtr); 53 return result; 54 } 55 56 public void Parse (String aIDStr) { 57 if(aIDStr == null) throw new Error (); 58 int i = 0; 59 for (; i < 8; i++) m0 = (m0 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16); 60 if (aIDStr.charAt (i++) != '-') throw new Error (); 61 for (; i < 13; i++) m1 = (short)((m1 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16)); 62 if (aIDStr.charAt (i++) != '-') throw new Error (); 63 for (; i < 18; i++) m2 = (short)((m2 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16)); 64 if (aIDStr.charAt (i++) != '-') throw new Error (); 65 for (; i < 21; i++) m3[0] = (byte)((m3[0] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16)); 66 for (; i < 23; i++) m3[1] = (byte)((m3[1] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16)); 67 if (aIDStr.charAt (i++) != '-') throw new Error (); 68 for (; i < 26; i++) m3[2] = (byte)((m3[2] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16)); 69 for (; i < 28; i++) m3[3] = (byte)((m3[3] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16)); 70 for (; i < 30; i++) m3[4] = (byte)((m3[4] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16)); 71 for (; i < 32; i++) m3[5] = (byte)((m3[5] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16)); 72 for (; i < 34; i++) m3[6] = (byte)((m3[6] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16)); 73 for (; i < 36; i++) m3[7] = (byte)((m3[7] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16)); 74 } 75 76 } | Popular Tags |