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