1 28 29 30 package org.objectweb.ccm.runtime; 31 32 import org.objectweb.corba.runtime.*; 33 34 37 public class CookieImpl 38 extends org.omg.Components.Cookie 39 { 40 transient private int _channel_id; 41 transient private String _name; 42 43 public 45 CookieImpl() 46 { 47 cookieValue = null; 49 } 50 51 public 53 CookieImpl(byte[] val) 54 { 55 cookieValue = val; 57 } 58 59 public 61 CookieImpl(int chid) 62 { 63 _channel_id = chid; 65 _name = null; 66 67 double d = Math.random(); 69 String sval = Integer.toString(_channel_id)+":"+Double.toString(d); 70 cookieValue = sval.getBytes(); 71 } 72 73 public 75 CookieImpl(String n) 76 { 77 _channel_id = -1; 79 _name = n; 80 81 double d = Math.random(); 83 String sval = _name+":"+Double.toString(d); 84 cookieValue = sval.getBytes(); 85 } 86 87 91 final protected byte[] 92 getCookieValue() 93 { 94 return cookieValue; 95 } 96 97 final protected void 98 initialize() 99 { 100 String sval = new String (cookieValue); 101 int idx = sval.indexOf(':'); 102 _name = sval.substring(0, idx); 103 try { 104 _channel_id = Integer.parseInt(_name); 105 } catch (java.lang.NumberFormatException ex) { 106 } 108 } 109 110 114 final public int 115 getChannelId() 116 { 117 if (_channel_id==-1) { 118 initialize(); 119 } 120 121 return _channel_id; 122 } 123 124 final public String 125 getName() 126 { 127 if (_name==null) { 128 initialize(); 129 } 130 131 return _name; 132 } 133 134 138 final public boolean 139 equals(Object obj) 140 { 141 if (!(obj instanceof CookieImpl)) { 143 return false; 144 } 145 146 CookieImpl ck = (CookieImpl)obj; 148 if (java.util.Arrays.equals(cookieValue, ck.getCookieValue())) { 149 return true; 150 } else { 151 return false; 152 } 153 } 154 } 155 | Popular Tags |