1 /* 2 * Copyright (c) 2000, 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 com.sun.corba.se.impl.io.TypeMismatchException; 32 import java.net.MalformedURLException; 33 import com.sun.corba.se.impl.util.RepositoryId; 34 35 /** 36 * Delegates to the current RepositoryId implementation in 37 * com.sun.corba.se.impl.util. This is necessary to 38 * overcome the fact that many of RepositoryId's methods 39 * are static. 40 */ 41 public final class RepIdDelegator 42 implements RepositoryIdStrings, 43 RepositoryIdUtility, 44 RepositoryIdInterface 45 { 46 // RepositoryIdFactory methods 47 48 public String createForAnyType(Class type) { 49 return RepositoryId.createForAnyType(type); 50 } 51 52 public String createForJavaType(Serializable ser) 53 throws TypeMismatchException 54 { 55 return RepositoryId.createForJavaType(ser); 56 } 57 58 public String createForJavaType(Class clz) 59 throws TypeMismatchException 60 { 61 return RepositoryId.createForJavaType(clz); 62 } 63 64 public String createSequenceRepID(java.lang.Object ser) { 65 return RepositoryId.createSequenceRepID(ser); 66 } 67 68 public String createSequenceRepID(Class clazz) { 69 return RepositoryId.createSequenceRepID(clazz); 70 } 71 72 public RepositoryIdInterface getFromString(String repIdString) { 73 return new RepIdDelegator(RepositoryId.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.kClassDescValueRepID; 88 } 89 90 public String getWStringValueRepId() { 91 return RepositoryId.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() { 155 this(null); 156 } 157 158 // Constructor used by getIdFromString. All non-static 159 // RepositoryId methods will use the provided delegate. 160 private RepIdDelegator(RepositoryId _delegate) { 161 this.delegate = _delegate; 162 } 163 164 private final RepositoryId delegate; 165 166 public String toString() { 167 if (delegate != null) 168 return delegate.toString(); 169 else 170 return this.getClass().getName(); 171 } 172 173 public boolean equals(Object obj) { 174 if (delegate != null) 175 return delegate.equals(obj); 176 else 177 return super.equals(obj); 178 } 179 180 public int hashCode() { 181 if (delegate != null) { 182 return delegate.hashCode(); 183 } else { 184 return super.hashCode(); 185 } 186 } 187 }