1. /*
  2. * @(#)ORBVersionFactory.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 com.sun.corba.se.internal.core.ORBVersion ;
  9. import com.sun.corba.se.internal.core.ORBVersionImpl ;
  10. import org.omg.CORBA.portable.InputStream ;
  11. import org.omg.CORBA.INTERNAL ;
  12. public class ORBVersionFactory {
  13. private ORBVersionFactory() {} ;
  14. public static ORBVersion getORBVersion()
  15. {
  16. return ORBVersionImpl.NEWER ;
  17. }
  18. public static ORBVersion create( InputStream is )
  19. {
  20. byte value = is.read_octet() ;
  21. return byteToVersion( value ) ;
  22. }
  23. private static ORBVersion byteToVersion( byte value )
  24. {
  25. /* Throwing an exception here would cause Merlin to be incompatible
  26. * with future versions of the ORB, to the point that Merlin could
  27. * not even unmarshal objrefs from a newer version that uses
  28. * extended versioning. Therefore, we will simply treat all
  29. * unknown versions as NEWER.
  30. if (value < 0)
  31. throw new INTERNAL() ;
  32. */
  33. switch (value) {
  34. case ORBVersion.FOREIGN : return ORBVersionImpl.FOREIGN ;
  35. case ORBVersion.OLD : return ORBVersionImpl.OLD ;
  36. case ORBVersion.NEW : return ORBVersionImpl.NEW ;
  37. case ORBVersion.JDK1_3_1_01: return ORBVersionImpl.JDK1_3_1_01 ;
  38. case ORBVersion.NEWER : return ORBVersionImpl.NEWER ;
  39. default : return ORBVersionImpl.NEWER ;
  40. }
  41. }
  42. }