KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > ior > ObjectIdImpl


1 /*
2  * @(#)ObjectIdImpl.java 1.13 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.impl.ior;
9
10 import java.util.Arrays JavaDoc ;
11 import com.sun.corba.se.spi.ior.ObjectId ;
12 import org.omg.CORBA_2_3.portable.OutputStream JavaDoc ;
13
14 /**
15  * @author
16  */

17 public final class ObjectIdImpl implements ObjectId
18 {
19     private byte[] id;
20     
21     public boolean equals( Object JavaDoc obj )
22     {
23     if (!(obj instanceof ObjectIdImpl))
24         return false ;
25
26     ObjectIdImpl other = (ObjectIdImpl)obj ;
27
28     return Arrays.equals( this.id, other.id ) ;
29     }
30
31     public int hashCode()
32     {
33     int result = 17 ;
34     for (int ctr=0; ctr<id.length; ctr++)
35         result = 37*result + id[ctr] ;
36     return result ;
37     }
38
39     public ObjectIdImpl( byte[] id )
40     {
41     this.id = id ;
42     }
43
44     public byte[] getId()
45     {
46     return id ;
47     }
48
49     public void write( OutputStream JavaDoc os )
50     {
51     os.write_long( id.length ) ;
52     os.write_octet_array( id, 0, id.length ) ;
53     }
54 }
55
Popular Tags