1. /*
  2. * @(#)ORBVersionImpl.java 1.10 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.internal.core ;
  8. import org.omg.CORBA.portable.OutputStream ;
  9. public class ORBVersionImpl implements ORBVersion {
  10. private byte orbType ;
  11. private ORBVersionImpl( byte orbType )
  12. {
  13. this.orbType = orbType ;
  14. }
  15. public static final ORBVersion FOREIGN = new ORBVersionImpl(
  16. ORBVersion.FOREIGN ) ;
  17. public static final ORBVersion OLD = new ORBVersionImpl(
  18. ORBVersion.OLD ) ;
  19. public static final ORBVersion NEW = new ORBVersionImpl(
  20. ORBVersion.NEW ) ;
  21. public static final ORBVersion JDK1_3_1_01 = new ORBVersionImpl(
  22. ORBVersion.JDK1_3_1_01 ) ;
  23. public static final ORBVersion NEWER = new ORBVersionImpl(
  24. ORBVersion.NEWER ) ;
  25. public byte getORBType()
  26. {
  27. return orbType ;
  28. }
  29. public void write( OutputStream os )
  30. {
  31. os.write_octet( (byte)orbType ) ;
  32. }
  33. public String toString()
  34. {
  35. return "ORBVersionImpl[" + Byte.toString( orbType ) + "]" ;
  36. }
  37. public boolean equals( Object obj )
  38. {
  39. if (!(obj instanceof ORBVersion))
  40. return false ;
  41. ORBVersion version = (ORBVersion)obj ;
  42. return version.getORBType() == orbType ;
  43. }
  44. public boolean lessThan(ORBVersion version) {
  45. return orbType < version.getORBType();
  46. }
  47. public int compareTo(Object obj) {
  48. // The Comparable interface says that this
  49. // method throws a ClassCastException if the
  50. // given object's type prevents it from being
  51. // compared.
  52. return getORBType() - ((ORBVersion)obj).getORBType();
  53. }
  54. }