1. /*
  2. * @(#)RepIdDelegator_1_3_1.java 1.3 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.orbutil;
  8. import org.omg.CORBA.ORB;
  9. import java.io.Serializable;
  10. import java.util.Hashtable;
  11. import java.net.MalformedURLException;
  12. import com.sun.corba.se.internal.io.TypeMismatchException;
  13. import com.sun.corba.se.internal.util.RepositoryId;
  14. /**
  15. * Delegates to the RepositoryId_1_3_1 implementation in
  16. * com.sun.corba.se.internal.orbutil. This is necessary to
  17. * overcome the fact that many of RepositoryId's methods
  18. * are static.
  19. */
  20. public final class RepIdDelegator_1_3_1
  21. implements RepositoryIdStrings,
  22. RepositoryIdUtility,
  23. RepositoryIdInterface
  24. {
  25. // RepositoryIdFactory methods
  26. public String createForAnyType(Class type) {
  27. return RepositoryId_1_3_1.createForAnyType(type);
  28. }
  29. public String createForJavaType(Serializable ser)
  30. throws TypeMismatchException
  31. {
  32. return RepositoryId_1_3_1.createForJavaType(ser);
  33. }
  34. public String createForJavaType(Class clz)
  35. throws TypeMismatchException
  36. {
  37. return RepositoryId_1_3_1.createForJavaType(clz);
  38. }
  39. public String createSequenceRepID(java.lang.Object ser) {
  40. return RepositoryId_1_3_1.createSequenceRepID(ser);
  41. }
  42. public String createSequenceRepID(Class clazz) {
  43. return RepositoryId_1_3_1.createSequenceRepID(clazz);
  44. }
  45. public RepositoryIdInterface getFromString(String repIdString) {
  46. return new RepIdDelegator_1_3_1(RepositoryId_1_3_1.cache.getId(repIdString));
  47. }
  48. // RepositoryIdUtility methods
  49. public boolean isChunkedEncoding(int valueTag) {
  50. return RepositoryId.isChunkedEncoding(valueTag);
  51. }
  52. public boolean isCodeBasePresent(int valueTag) {
  53. return RepositoryId.isCodeBasePresent(valueTag);
  54. }
  55. public String getClassDescValueRepId() {
  56. return RepositoryId_1_3_1.kClassDescValueRepID;
  57. }
  58. public String getWStringValueRepId() {
  59. return RepositoryId_1_3_1.kWStringValueRepID;
  60. }
  61. public int getTypeInfo(int valueTag) {
  62. return RepositoryId.getTypeInfo(valueTag);
  63. }
  64. public int getStandardRMIChunkedNoRepStrId() {
  65. return RepositoryId.kPreComputed_StandardRMIChunked_NoRep;
  66. }
  67. public int getCodeBaseRMIChunkedNoRepStrId() {
  68. return RepositoryId.kPreComputed_CodeBaseRMIChunked_NoRep;
  69. }
  70. public int getStandardRMIChunkedId() {
  71. return RepositoryId.kPreComputed_StandardRMIChunked;
  72. }
  73. public int getCodeBaseRMIChunkedId() {
  74. return RepositoryId.kPreComputed_CodeBaseRMIChunked;
  75. }
  76. public int getStandardRMIUnchunkedId() {
  77. return RepositoryId.kPreComputed_StandardRMIUnchunked;
  78. }
  79. public int getCodeBaseRMIUnchunkedId() {
  80. return RepositoryId.kPreComputed_CodeBaseRMIUnchunked;
  81. }
  82. // RepositoryIdInterface methods
  83. public Class getClassFromType() throws ClassNotFoundException {
  84. return delegate.getClassFromType();
  85. }
  86. public Class getClassFromType(String codebaseURL)
  87. throws ClassNotFoundException, MalformedURLException
  88. {
  89. return delegate.getClassFromType(codebaseURL);
  90. }
  91. public Class getClassFromType(Class expectedType,
  92. String codebaseURL)
  93. throws ClassNotFoundException, MalformedURLException
  94. {
  95. return delegate.getClassFromType(expectedType, codebaseURL);
  96. }
  97. public String getClassName() {
  98. return delegate.getClassName();
  99. }
  100. // Constructor used for factory/utility cases
  101. public RepIdDelegator_1_3_1() {}
  102. // Constructor used by getIdFromString. All non-static
  103. // RepositoryId methods will use the provided delegate.
  104. private RepIdDelegator_1_3_1(RepositoryId_1_3_1 _delegate) {
  105. this.delegate = _delegate;
  106. }
  107. private RepositoryId_1_3_1 delegate = null;
  108. public String toString() {
  109. if (delegate != null)
  110. return delegate.toString();
  111. else
  112. return this.getClass().getName();
  113. }
  114. public boolean equals(Object obj) {
  115. if (delegate != null)
  116. return delegate.equals(obj);
  117. else
  118. return super.equals(obj);
  119. }
  120. }