ObjectIdImpl.java revision 608:7e06bf1dcb09
1139757Sscottl/* 239220Sgibbs * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. 339220Sgibbs * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 439220Sgibbs * 539220Sgibbs * This code is free software; you can redistribute it and/or modify it 639220Sgibbs * under the terms of the GNU General Public License version 2 only, as 739220Sgibbs * published by the Free Software Foundation. Oracle designates this 839220Sgibbs * particular file as subject to the "Classpath" exception as provided 939220Sgibbs * by Oracle in the LICENSE file that accompanied this code. 1039220Sgibbs * 1165942Sgibbs * This code is distributed in the hope that it will be useful, but WITHOUT 1265942Sgibbs * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1365942Sgibbs * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1465942Sgibbs * version 2 for more details (a copy is included in the LICENSE file that 1539220Sgibbs * accompanied this code). 1665942Sgibbs * 1795378Sgibbs * You should have received a copy of the GNU General Public License version 1865942Sgibbs * 2 along with this work; if not, write to the Free Software Foundation, 1965942Sgibbs * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2065942Sgibbs * 2165942Sgibbs * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2265942Sgibbs * or visit www.oracle.com if you need additional information or have any 2365942Sgibbs * questions. 2465942Sgibbs */ 2565942Sgibbs 2665942Sgibbspackage com.sun.corba.se.impl.ior; 2765942Sgibbs 2865942Sgibbsimport java.util.Arrays ; 2965942Sgibbsimport com.sun.corba.se.spi.ior.ObjectId ; 3065942Sgibbsimport org.omg.CORBA_2_3.portable.OutputStream ; 31123579Sgibbs 3239220Sgibbs/** 3339220Sgibbs * @author 3439220Sgibbs */ 3539220Sgibbspublic final class ObjectIdImpl implements ObjectId 3639220Sgibbs{ 3739220Sgibbs private byte[] id; 3839220Sgibbs 3939220Sgibbs public boolean equals( Object obj ) 4039220Sgibbs { 4139220Sgibbs if (!(obj instanceof ObjectIdImpl)) 4272640Sasmodai return false ; 4339220Sgibbs 4439220Sgibbs ObjectIdImpl other = (ObjectIdImpl)obj ; 4539220Sgibbs 4639220Sgibbs return Arrays.equals( this.id, other.id ) ; 4739220Sgibbs } 4839220Sgibbs 4939220Sgibbs public int hashCode() 5039220Sgibbs { 5139220Sgibbs int result = 17 ; 5239220Sgibbs for (int ctr=0; ctr<id.length; ctr++) 5339220Sgibbs result = 37*result + id[ctr] ; 5439220Sgibbs return result ; 5539220Sgibbs } 5639220Sgibbs 5739220Sgibbs public ObjectIdImpl( byte[] id ) 5839220Sgibbs { 5939220Sgibbs this.id = id ; 6039220Sgibbs } 6139220Sgibbs 6239220Sgibbs public byte[] getId() 6339220Sgibbs { 6439220Sgibbs return id ; 6539220Sgibbs } 6639220Sgibbs 6795378Sgibbs public void write( OutputStream os ) 6895378Sgibbs { 6995378Sgibbs os.write_long( id.length ) ; 7095378Sgibbs os.write_octet_array( id, 0, id.length ) ; 7195378Sgibbs } 72123579Sgibbs} 73123579Sgibbs