1 /* 2 * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.corba.se.impl.orbutil; 27 28 import org.omg.CORBA.ORB; 29 import java.io.Serializable; 30 import java.util.Hashtable; 31 import java.net.MalformedURLException; 32 import com.sun.corba.se.impl.io.TypeMismatchException; 33 import com.sun.corba.se.impl.util.RepositoryId; 34 35 /** 36 * Delegates to the RepositoryId_1_3_1 implementation in 37 * com.sun.corba.se.impl.orbutil. This is necessary to 38 * overcome the fact that many of RepositoryId's methods 39 * are static. 40 */ 41 public final class RepIdDelegator_1_3_1 42 implements RepositoryIdStrings, 43 RepositoryIdUtility, 44 RepositoryIdInterface 45 { 46 // RepositoryIdFactory methods 47 48 public String createForAnyType(Class type) { 49 return RepositoryId_1_3_1.createForAnyType(type); 50 } 51 52 public String createForJavaType(Serializable ser) 53 throws TypeMismatchException 54 { 55 return RepositoryId_1_3_1.createForJavaType(ser); 56 } 57 58 public String createForJavaType(Class clz) 59 throws TypeMismatchException 60 { 61 return RepositoryId_1_3_1.createForJavaType(clz); 62 } 63 64 public String createSequenceRepID(java.lang.Object ser) { 65 return RepositoryId_1_3_1.createSequenceRepID(ser); 66 } 67 68 public String createSequenceRepID(Class clazz) { 69 return RepositoryId_1_3_1.createSequenceRepID(clazz); 70 } 71 72 public RepositoryIdInterface getFromString(String repIdString) { 73 return new RepIdDelegator_1_3_1(RepositoryId_1_3_1.cache.getId(repIdString)); 74 } 75 76 // RepositoryIdUtility methods 77 78 public boolean isChunkedEncoding(int valueTag) { 79 return RepositoryId.isChunkedEncoding(valueTag); 80 } 81 82 public boolean isCodeBasePresent(int valueTag) { 83 return RepositoryId.isCodeBasePresent(valueTag); 84 } 85 86 public String getClassDescValueRepId() { 87 return RepositoryId_1_3_1.kClassDescValueRepID; 88 } 89 90 public String getWStringValueRepId() { 91 return RepositoryId_1_3_1.kWStringValueRepID; 92 } 93 94 public int getTypeInfo(int valueTag) { 95 return RepositoryId.getTypeInfo(valueTag); 96 } 97 98 public int getStandardRMIChunkedNoRepStrId() { 99 return RepositoryId.kPreComputed_StandardRMIChunked_NoRep; 100 } 101 102 public int getCodeBaseRMIChunkedNoRepStrId() { 103 return RepositoryId.kPreComputed_CodeBaseRMIChunked_NoRep; 104 } 105 106 public int getStandardRMIChunkedId() { 107 return RepositoryId.kPreComputed_StandardRMIChunked; 108 } 109 110 public int getCodeBaseRMIChunkedId() { 111 return RepositoryId.kPreComputed_CodeBaseRMIChunked; 112 } 113 114 public int getStandardRMIUnchunkedId() { 115 return RepositoryId.kPreComputed_StandardRMIUnchunked; 116 } 117 118 public int getCodeBaseRMIUnchunkedId() { 119 return RepositoryId.kPreComputed_CodeBaseRMIUnchunked; 120 } 121 122 public int getStandardRMIUnchunkedNoRepStrId() { 123 return RepositoryId.kPreComputed_StandardRMIUnchunked_NoRep; 124 } 125 126 public int getCodeBaseRMIUnchunkedNoRepStrId() { 127 return RepositoryId.kPreComputed_CodeBaseRMIUnchunked_NoRep; 128 } 129 130 // RepositoryIdInterface methods 131 132 public Class getClassFromType() throws ClassNotFoundException { 133 return delegate.getClassFromType(); 134 } 135 136 public Class getClassFromType(String codebaseURL) 137 throws ClassNotFoundException, MalformedURLException 138 { 139 return delegate.getClassFromType(codebaseURL); 140 } 141 142 public Class getClassFromType(Class expectedType, 143 String codebaseURL) 144 throws ClassNotFoundException, MalformedURLException 145 { 146 return delegate.getClassFromType(expectedType, codebaseURL); 147 } 148 149 public String getClassName() { 150 return delegate.getClassName(); 151 } 152 153 // Constructor used for factory/utility cases 154 public RepIdDelegator_1_3_1() {} 155 156 // Constructor used by getIdFromString. All non-static 157 // RepositoryId methods will use the provided delegate. 158 private RepIdDelegator_1_3_1(RepositoryId_1_3_1 _delegate) { 159 this.delegate = _delegate; 160 } 161 162 private RepositoryId_1_3_1 delegate = null; 163 164 public String toString() { 165 if (delegate != null) 166 return delegate.toString(); 167 else 168 return this.getClass().getName(); 169 } 170 171 public boolean equals(Object obj) { 172 if (delegate != null) 173 return delegate.equals(obj); 174 else 175 return super.equals(obj); 176 } 177 }