1 package org.apache.ojb.broker.util; 2 3 17 18 import java.io.Serializable ; 19 import java.net.InetAddress ; 20 import java.net.UnknownHostException ; 21 import java.rmi.server.UID ; 22 23 32 public class GUID implements Serializable 33 { 34 static final long serialVersionUID = -6163239155380515945L; 37 private static String localIPAddress; 38 39 42 private String guid; 43 44 47 static 48 { 49 try 50 { 51 localIPAddress = InetAddress.getLocalHost().getHostAddress(); 52 } 53 catch (UnknownHostException e) 54 { 55 localIPAddress = "localhost"; 56 } 57 } 58 59 62 public GUID() 63 { 64 UID uid = new UID (); 65 StringBuffer buf = new StringBuffer (); 66 buf.append(localIPAddress); 67 buf.append(":"); 68 buf.append(uid.toString()); 69 guid = buf.toString(); 70 } 71 72 78 public GUID(String theGuidString) 79 { 80 guid = theGuidString; 81 } 82 83 86 public String toString() 87 { 88 return guid; 89 } 90 93 public boolean equals(Object obj) 94 { 95 if (obj instanceof GUID) 96 { 97 if (guid.equals(((GUID) obj).guid)) 98 { 99 return true; 100 } 101 } 102 return false; 103 } 104 105 108 public int hashCode() 109 { 110 return guid.hashCode(); 111 } 112 113 } 114 | Popular Tags |