KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > orb > ORBVersionImpl


1 /*
2  * @(#)ORBVersionImpl.java 1.13 04/03/01
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.orb ;
9
10 import org.omg.CORBA.portable.OutputStream JavaDoc ;
11
12 import com.sun.corba.se.spi.orb.ORBVersion ;
13
14 public class ORBVersionImpl implements ORBVersion {
15     private byte orbType ;
16
17     public ORBVersionImpl( byte orbType )
18     {
19     this.orbType = orbType ;
20     }
21
22     public static final ORBVersion FOREIGN = new ORBVersionImpl(
23     ORBVersion.FOREIGN ) ;
24
25     public static final ORBVersion OLD = new ORBVersionImpl(
26     ORBVersion.OLD ) ;
27
28     public static final ORBVersion NEW = new ORBVersionImpl(
29     ORBVersion.NEW ) ;
30
31     public static final ORBVersion JDK1_3_1_01 = new ORBVersionImpl(
32         ORBVersion.JDK1_3_1_01 ) ;
33
34     public static final ORBVersion NEWER = new ORBVersionImpl(
35     ORBVersion.NEWER ) ;
36
37     public static final ORBVersion PEORB = new ORBVersionImpl(
38     ORBVersion.PEORB ) ;
39
40     public byte getORBType()
41     {
42     return orbType ;
43     }
44
45     public void write( OutputStream JavaDoc os )
46     {
47     os.write_octet( (byte)orbType ) ;
48     }
49
50     public String JavaDoc toString()
51     {
52     return "ORBVersionImpl[" + Byte.toString( orbType ) + "]" ;
53     }
54
55     public boolean equals( Object JavaDoc obj )
56     {
57     if (!(obj instanceof ORBVersion))
58         return false ;
59
60     ORBVersion version = (ORBVersion)obj ;
61     return version.getORBType() == orbType ;
62     }
63
64     public int hashCode()
65     {
66     return orbType ;
67     }
68
69     public boolean lessThan(ORBVersion version) {
70         return orbType < version.getORBType();
71     }
72
73     public int compareTo(Object JavaDoc obj) {
74         // The Comparable interface says that this
75
// method throws a ClassCastException if the
76
// given object's type prevents it from being
77
// compared.
78
return getORBType() - ((ORBVersion)obj).getORBType();
79     }
80 }
81
Popular Tags