corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepositoryId_1_3.java
author ohair
Tue, 25 May 2010 15:52:11 -0700
changeset 5555 b2b5ed3f0d0d
parent 4 02bb8761fcce
child 13052 63c6c4c360e1
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     2
 * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02bb8761fcce Initial load
duke
parents:
diff changeset
     4
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
02bb8761fcce Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    10
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
02bb8761fcce Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02bb8761fcce Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02bb8761fcce Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
02bb8761fcce Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
02bb8761fcce Initial load
duke
parents:
diff changeset
    16
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
02bb8761fcce Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
02bb8761fcce Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02bb8761fcce Initial load
duke
parents:
diff changeset
    20
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    23
 * questions.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    24
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    25
/*
02bb8761fcce Initial load
duke
parents:
diff changeset
    26
 * Licensed Materials - Property of IBM
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
 * RMI-IIOP v1.0
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
 * Copyright IBM Corp. 1998 1999  All Rights Reserved
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
package com.sun.corba.se.impl.orbutil;
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
import java.util.StringTokenizer;
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
import java.util.Hashtable;
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
import java.io.IOException;
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
import java.lang.reflect.Method;
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
// Imports for using codebase URL to load class
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
import java.net.MalformedURLException;
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
import org.omg.CORBA.portable.ValueBase;
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
import org.omg.CORBA.portable.IDLEntity;
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
import com.sun.corba.se.impl.util.JDKBridge;
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
import com.sun.corba.se.impl.util.Utility;
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
import com.sun.corba.se.impl.util.PackagePrefixChecker;
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
import com.sun.corba.se.impl.util.IdentityHashtable;
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
import com.sun.corba.se.impl.io.ObjectStreamClass;
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
import javax.rmi.CORBA.Util;
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
// keeping the original RepositoryId class that was shipped in
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
// JDK 1.3.  It has interoperability bugs
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
public class RepositoryId_1_3 {
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
    // Legal IDL Identifier characters (1 = legal). Note
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
    // that '.' (2E) is marked as legal even though it is
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
    // not legal in IDL. This allows us to treat a fully
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
    // qualified Java name with '.' package separators
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
    // uniformly, and is safe because that is the only
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
    // legal use of '.' in a Java name.
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
    public static final RepositoryIdCache_1_3 cache = new RepositoryIdCache_1_3();
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
    public static final byte[] IDL_IDENTIFIER_CHARS = {
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
        // 0 1 2 3  4 5 6 7  8 9 a b  c d e f
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 00-0f
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 10-1f
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,1,0, // 20-2f
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
        1,1,1,1, 1,1,1,1, 1,1,0,0, 0,0,0,0, // 30-3f
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
        0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // 40-4f
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
        1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,1, // 50-5f
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
        0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // 60-6f
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
        1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0, // 70-7f
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 80-8f
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 90-9f
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // a0-af
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
        0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // b0-bf
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
        1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // c0-cf
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
        0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1, // d0-df
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
        1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, // e0-ef
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
        0,1,1,1, 1,1,1,0, 1,1,1,1, 1,0,0,1, // f0-ff
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
    };
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
    private static String defaultServerURL = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
    private static boolean useCodebaseOnly = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
    static {
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
        if (defaultServerURL == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
            defaultServerURL = (String)JDKBridge.getLocalCodebase();
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
        useCodebaseOnly = JDKBridge.useCodebaseOnly();
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
    private static IdentityHashtable classToRepStr = new IdentityHashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
    private static IdentityHashtable classIDLToRepStr = new IdentityHashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
    private static IdentityHashtable classSeqToRepStr = new IdentityHashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
    private static IdentityHashtable repStrToByteArray = new IdentityHashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
    private static Hashtable repStrToClass = new Hashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
    private String repId = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
    private boolean isSupportedFormat = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
    private String typeString = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
    private String versionString = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
    private boolean isSequence = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
    private boolean isRMIValueType = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
    private boolean isIDLType = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
    private String completeClassName = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
    private String unqualifiedName = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
    private String definedInId = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
    private Class clazz = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
    private String suid = null, actualSuid = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
    private long suidLong = ObjectStreamClass.kDefaultUID, actualSuidLong = ObjectStreamClass.kDefaultUID;
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
    // Repository ID fragments
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
    private static final String kValuePrefix = "RMI:";
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
    private static final String kIDLPrefix = "IDL:";
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
    private static final String kIDLNamePrefix = "omg.org/";
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
    private static final String kIDLClassnamePrefix = "org.omg.";
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
    private static final String kSequencePrefix = "[";
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
    private static final String kCORBAPrefix = "CORBA/";
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
    private static final String kArrayPrefix = kValuePrefix + kSequencePrefix + kCORBAPrefix;
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
    private static final int kValuePrefixLength = kValuePrefix.length();
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
    private static final int kIDLPrefixLength = kIDLPrefix.length();
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
    private static final int kSequencePrefixLength = kSequencePrefix.length();
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
    private static final String kInterfaceHashCode = ":0000000000000000";
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
    private static final String kInterfaceOnlyHashStr = "0000000000000000";
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
    private static final String kExternalizableHashStr = "0000000000000001";
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
    // Value tag utility methods and constants
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
    public static final int kInitialValueTag= 0x7fffff00;
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
    public static final int kNoTypeInfo = 0;
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
    public static final int kSingleRepTypeInfo = 0x02;
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
    public static final int  kPartialListTypeInfo = 0x06;
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
    public static final int  kChunkedMask = 0x08;
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
    // Public, well known repository IDs
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
    // _REVISIT_ : A table structure with a good search routine for all of this
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
    // would be more efficient and easier to maintain...
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
    // String
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
    public static final String kWStringValueVersion = "1.0";
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
    public static final String kWStringValueHash = ":"+kWStringValueVersion;
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
    public static final String kWStringStubValue = "WStringValue";
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
    public static final String kWStringTypeStr = "omg.org/CORBA/"+kWStringStubValue;
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
    public static final String kWStringValueRepID = kIDLPrefix + kWStringTypeStr + kWStringValueHash;
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
    // Any
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
    public static final String kAnyRepID = kIDLPrefix + "omg.org/CORBA/Any";
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
    // Class
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
    public static final String kClassDescValueHash = ":" + Long.toHexString(
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
       ObjectStreamClass.getSerialVersionUID(javax.rmi.CORBA.ClassDesc.class));
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
    public static final String kClassDescStubValue = "ClassDesc";
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
    public static final String kClassDescTypeStr = "javax.rmi.CORBA."+kClassDescStubValue;
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
    public static final String kClassDescValueRepID = kValuePrefix + kClassDescTypeStr + kClassDescValueHash;
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
    // Object
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
    public static final String kObjectValueHash = ":1.0";
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
    public static final String kObjectStubValue = "Object";
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
    // Sequence
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
    public static final String kSequenceValueHash = ":1.0";
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
    public static final String kPrimitiveSequenceValueHash = ":0000000000000000";
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
    // Serializable
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
    public static final String kSerializableValueHash = ":1.0";
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
    public static final String kSerializableStubValue = "Serializable";
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
    // Externalizable
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
    public static final String kExternalizableValueHash = ":1.0";
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
    public static final String kExternalizableStubValue = "Externalizable";
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
    // Remote (The empty string is used for java.rmi.Remote)
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
    public static final String kRemoteValueHash = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
    public static final String kRemoteStubValue = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
    public static final String kRemoteTypeStr = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
    public static final String kRemoteValueRepID = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
    public static final Hashtable kSpecialArrayTypeStrings = new Hashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
    static {
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
        kSpecialArrayTypeStrings.put("CORBA.WStringValue", new StringBuffer(java.lang.String.class.getName()));
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
        kSpecialArrayTypeStrings.put("javax.rmi.CORBA.ClassDesc", new StringBuffer(java.lang.Class.class.getName()));
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
        kSpecialArrayTypeStrings.put("CORBA.Object", new StringBuffer(java.rmi.Remote.class.getName()));
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
    public static final Hashtable kSpecialCasesRepIDs = new Hashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
    static {
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
        kSpecialCasesRepIDs.put(java.lang.String.class, kWStringValueRepID);
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
        kSpecialCasesRepIDs.put(java.lang.Class.class, kClassDescValueRepID);
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
        kSpecialCasesRepIDs.put(java.rmi.Remote.class, kRemoteValueRepID);
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
    public static final Hashtable kSpecialCasesStubValues = new Hashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
    static {
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
        kSpecialCasesStubValues.put(java.lang.String.class, kWStringStubValue);
02bb8761fcce Initial load
duke
parents:
diff changeset
   204
        kSpecialCasesStubValues.put(java.lang.Class.class, kClassDescStubValue);
02bb8761fcce Initial load
duke
parents:
diff changeset
   205
        kSpecialCasesStubValues.put(java.lang.Object.class, kObjectStubValue);
02bb8761fcce Initial load
duke
parents:
diff changeset
   206
        kSpecialCasesStubValues.put(java.io.Serializable.class, kSerializableStubValue);
02bb8761fcce Initial load
duke
parents:
diff changeset
   207
        kSpecialCasesStubValues.put(java.io.Externalizable.class, kExternalizableStubValue);
02bb8761fcce Initial load
duke
parents:
diff changeset
   208
        kSpecialCasesStubValues.put(java.rmi.Remote.class, kRemoteStubValue);
02bb8761fcce Initial load
duke
parents:
diff changeset
   209
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   210
02bb8761fcce Initial load
duke
parents:
diff changeset
   211
02bb8761fcce Initial load
duke
parents:
diff changeset
   212
    public static final Hashtable kSpecialCasesVersions = new Hashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
   213
02bb8761fcce Initial load
duke
parents:
diff changeset
   214
    static {
02bb8761fcce Initial load
duke
parents:
diff changeset
   215
        kSpecialCasesVersions.put(java.lang.String.class, kWStringValueHash);
02bb8761fcce Initial load
duke
parents:
diff changeset
   216
        kSpecialCasesVersions.put(java.lang.Class.class, kClassDescValueHash);
02bb8761fcce Initial load
duke
parents:
diff changeset
   217
        kSpecialCasesVersions.put(java.lang.Object.class, kObjectValueHash);
02bb8761fcce Initial load
duke
parents:
diff changeset
   218
        kSpecialCasesVersions.put(java.io.Serializable.class, kSerializableValueHash);
02bb8761fcce Initial load
duke
parents:
diff changeset
   219
        kSpecialCasesVersions.put(java.io.Externalizable.class, kExternalizableValueHash);
02bb8761fcce Initial load
duke
parents:
diff changeset
   220
        kSpecialCasesVersions.put(java.rmi.Remote.class, kRemoteValueHash);
02bb8761fcce Initial load
duke
parents:
diff changeset
   221
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   222
02bb8761fcce Initial load
duke
parents:
diff changeset
   223
    public static final Hashtable kSpecialCasesClasses = new Hashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
   224
02bb8761fcce Initial load
duke
parents:
diff changeset
   225
    static {
02bb8761fcce Initial load
duke
parents:
diff changeset
   226
        kSpecialCasesClasses.put(kWStringTypeStr, java.lang.String.class);
02bb8761fcce Initial load
duke
parents:
diff changeset
   227
        kSpecialCasesClasses.put(kClassDescTypeStr, java.lang.Class.class);
02bb8761fcce Initial load
duke
parents:
diff changeset
   228
        kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
02bb8761fcce Initial load
duke
parents:
diff changeset
   229
02bb8761fcce Initial load
duke
parents:
diff changeset
   230
        kSpecialCasesClasses.put("org.omg.CORBA.WStringValue", java.lang.String.class);
02bb8761fcce Initial load
duke
parents:
diff changeset
   231
        kSpecialCasesClasses.put("javax.rmi.CORBA.ClassDesc", java.lang.Class.class);
02bb8761fcce Initial load
duke
parents:
diff changeset
   232
        //kSpecialCasesClasses.put(kRemoteTypeStr, java.rmi.Remote.class);
02bb8761fcce Initial load
duke
parents:
diff changeset
   233
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   234
02bb8761fcce Initial load
duke
parents:
diff changeset
   235
    public static final Hashtable kSpecialCasesArrayPrefix = new Hashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
   236
02bb8761fcce Initial load
duke
parents:
diff changeset
   237
    static {
02bb8761fcce Initial load
duke
parents:
diff changeset
   238
        kSpecialCasesArrayPrefix.put(java.lang.String.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
02bb8761fcce Initial load
duke
parents:
diff changeset
   239
        kSpecialCasesArrayPrefix.put(java.lang.Class.class, kValuePrefix + kSequencePrefix + "javax/rmi/CORBA/");
02bb8761fcce Initial load
duke
parents:
diff changeset
   240
        kSpecialCasesArrayPrefix.put(java.lang.Object.class, kValuePrefix + kSequencePrefix + "java/lang/");
02bb8761fcce Initial load
duke
parents:
diff changeset
   241
        kSpecialCasesArrayPrefix.put(java.io.Serializable.class, kValuePrefix + kSequencePrefix + "java/io/");
02bb8761fcce Initial load
duke
parents:
diff changeset
   242
        kSpecialCasesArrayPrefix.put(java.io.Externalizable.class, kValuePrefix + kSequencePrefix + "java/io/");
02bb8761fcce Initial load
duke
parents:
diff changeset
   243
        kSpecialCasesArrayPrefix.put(java.rmi.Remote.class, kValuePrefix + kSequencePrefix + kCORBAPrefix);
02bb8761fcce Initial load
duke
parents:
diff changeset
   244
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   245
02bb8761fcce Initial load
duke
parents:
diff changeset
   246
    public static final Hashtable kSpecialPrimitives = new Hashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
   247
02bb8761fcce Initial load
duke
parents:
diff changeset
   248
    static {
02bb8761fcce Initial load
duke
parents:
diff changeset
   249
        kSpecialPrimitives.put("int","long");
02bb8761fcce Initial load
duke
parents:
diff changeset
   250
        kSpecialPrimitives.put("long","longlong");
02bb8761fcce Initial load
duke
parents:
diff changeset
   251
        kSpecialPrimitives.put("byte","octet");
02bb8761fcce Initial load
duke
parents:
diff changeset
   252
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   253
02bb8761fcce Initial load
duke
parents:
diff changeset
   254
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   255
     * Used to convert ascii to hex.
02bb8761fcce Initial load
duke
parents:
diff changeset
   256
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   257
    private static final byte ASCII_HEX[] =     {
02bb8761fcce Initial load
duke
parents:
diff changeset
   258
        (byte)'0',
02bb8761fcce Initial load
duke
parents:
diff changeset
   259
        (byte)'1',
02bb8761fcce Initial load
duke
parents:
diff changeset
   260
        (byte)'2',
02bb8761fcce Initial load
duke
parents:
diff changeset
   261
        (byte)'3',
02bb8761fcce Initial load
duke
parents:
diff changeset
   262
        (byte)'4',
02bb8761fcce Initial load
duke
parents:
diff changeset
   263
        (byte)'5',
02bb8761fcce Initial load
duke
parents:
diff changeset
   264
        (byte)'6',
02bb8761fcce Initial load
duke
parents:
diff changeset
   265
        (byte)'7',
02bb8761fcce Initial load
duke
parents:
diff changeset
   266
        (byte)'8',
02bb8761fcce Initial load
duke
parents:
diff changeset
   267
        (byte)'9',
02bb8761fcce Initial load
duke
parents:
diff changeset
   268
        (byte)'A',
02bb8761fcce Initial load
duke
parents:
diff changeset
   269
        (byte)'B',
02bb8761fcce Initial load
duke
parents:
diff changeset
   270
        (byte)'C',
02bb8761fcce Initial load
duke
parents:
diff changeset
   271
        (byte)'D',
02bb8761fcce Initial load
duke
parents:
diff changeset
   272
        (byte)'E',
02bb8761fcce Initial load
duke
parents:
diff changeset
   273
        (byte)'F',
02bb8761fcce Initial load
duke
parents:
diff changeset
   274
    };
02bb8761fcce Initial load
duke
parents:
diff changeset
   275
02bb8761fcce Initial load
duke
parents:
diff changeset
   276
02bb8761fcce Initial load
duke
parents:
diff changeset
   277
    // Interface Rep ID Strings
02bb8761fcce Initial load
duke
parents:
diff changeset
   278
    public static final String kjava_rmi_Remote = createForAnyType(java.rmi.Remote.class);
02bb8761fcce Initial load
duke
parents:
diff changeset
   279
    public static final String korg_omg_CORBA_Object = createForAnyType(org.omg.CORBA.Object.class);
02bb8761fcce Initial load
duke
parents:
diff changeset
   280
02bb8761fcce Initial load
duke
parents:
diff changeset
   281
    // Dummy arguments for getIdFromHelper method
02bb8761fcce Initial load
duke
parents:
diff changeset
   282
    public static final Class kNoParamTypes[] ={};
02bb8761fcce Initial load
duke
parents:
diff changeset
   283
    public static final Object kNoArgs[] = {};
02bb8761fcce Initial load
duke
parents:
diff changeset
   284
02bb8761fcce Initial load
duke
parents:
diff changeset
   285
02bb8761fcce Initial load
duke
parents:
diff changeset
   286
    RepositoryId_1_3(){}
02bb8761fcce Initial load
duke
parents:
diff changeset
   287
02bb8761fcce Initial load
duke
parents:
diff changeset
   288
    RepositoryId_1_3(String aRepId){
02bb8761fcce Initial load
duke
parents:
diff changeset
   289
        init(aRepId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   290
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   291
02bb8761fcce Initial load
duke
parents:
diff changeset
   292
    RepositoryId_1_3 init(String aRepId){
02bb8761fcce Initial load
duke
parents:
diff changeset
   293
02bb8761fcce Initial load
duke
parents:
diff changeset
   294
        this.repId = aRepId;
02bb8761fcce Initial load
duke
parents:
diff changeset
   295
02bb8761fcce Initial load
duke
parents:
diff changeset
   296
        // Special case for remote
02bb8761fcce Initial load
duke
parents:
diff changeset
   297
        if (aRepId.length() == 0) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   298
            clazz = java.rmi.Remote.class;
02bb8761fcce Initial load
duke
parents:
diff changeset
   299
            typeString = "";
02bb8761fcce Initial load
duke
parents:
diff changeset
   300
            isRMIValueType = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   301
            suid = kInterfaceOnlyHashStr;
02bb8761fcce Initial load
duke
parents:
diff changeset
   302
            return this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   303
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   304
        else if (aRepId.equals(kWStringValueRepID)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   305
            clazz = java.lang.String.class;
02bb8761fcce Initial load
duke
parents:
diff changeset
   306
            typeString = kWStringTypeStr;
02bb8761fcce Initial load
duke
parents:
diff changeset
   307
            isIDLType = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   308
            versionString = kWStringValueVersion;
02bb8761fcce Initial load
duke
parents:
diff changeset
   309
            return this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   310
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   311
        else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   312
02bb8761fcce Initial load
duke
parents:
diff changeset
   313
        String repId = convertFromISOLatin1(aRepId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   314
02bb8761fcce Initial load
duke
parents:
diff changeset
   315
        versionString = repId.substring(repId.indexOf(':', repId.indexOf(':')+1));
02bb8761fcce Initial load
duke
parents:
diff changeset
   316
        if (repId.startsWith(kIDLPrefix)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   317
            typeString =
02bb8761fcce Initial load
duke
parents:
diff changeset
   318
                repId.substring(kIDLPrefixLength, repId.indexOf(':', kIDLPrefixLength));
02bb8761fcce Initial load
duke
parents:
diff changeset
   319
            isIDLType = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   320
            if (typeString.startsWith(kIDLNamePrefix))
02bb8761fcce Initial load
duke
parents:
diff changeset
   321
                completeClassName = kIDLClassnamePrefix +
02bb8761fcce Initial load
duke
parents:
diff changeset
   322
                    typeString.substring(kIDLNamePrefix.length()).replace('/','.');
02bb8761fcce Initial load
duke
parents:
diff changeset
   323
            else completeClassName = typeString.replace('/','.');
02bb8761fcce Initial load
duke
parents:
diff changeset
   324
02bb8761fcce Initial load
duke
parents:
diff changeset
   325
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   326
        else if (repId.startsWith(kValuePrefix)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   327
            typeString =
02bb8761fcce Initial load
duke
parents:
diff changeset
   328
                repId.substring(kValuePrefixLength, repId.indexOf(':', kValuePrefixLength));
02bb8761fcce Initial load
duke
parents:
diff changeset
   329
            isRMIValueType = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   330
02bb8761fcce Initial load
duke
parents:
diff changeset
   331
            if (versionString.indexOf('.') == -1) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   332
                    actualSuid = versionString.substring(1);
02bb8761fcce Initial load
duke
parents:
diff changeset
   333
                    suid = actualSuid;  // default if not explicitly specified
02bb8761fcce Initial load
duke
parents:
diff changeset
   334
02bb8761fcce Initial load
duke
parents:
diff changeset
   335
                    if (actualSuid.indexOf(':') != -1){
02bb8761fcce Initial load
duke
parents:
diff changeset
   336
                    // we have a declared hash also
02bb8761fcce Initial load
duke
parents:
diff changeset
   337
                        int pos = actualSuid.indexOf(':')+1;
02bb8761fcce Initial load
duke
parents:
diff changeset
   338
                        // actualSuid = suid.substring(pos);
02bb8761fcce Initial load
duke
parents:
diff changeset
   339
                        // suid = suid.substring(0, pos-1);
02bb8761fcce Initial load
duke
parents:
diff changeset
   340
                        suid = actualSuid.substring(pos);
02bb8761fcce Initial load
duke
parents:
diff changeset
   341
                        actualSuid = actualSuid.substring(0, pos-1);
02bb8761fcce Initial load
duke
parents:
diff changeset
   342
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   343
02bb8761fcce Initial load
duke
parents:
diff changeset
   344
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   345
            else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   346
                    // _REVISIT_ : Special case version failure ?
02bb8761fcce Initial load
duke
parents:
diff changeset
   347
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   348
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   349
        else isSupportedFormat = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   350
02bb8761fcce Initial load
duke
parents:
diff changeset
   351
        if (typeString.startsWith(kSequencePrefix)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   352
            isSequence = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   353
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   354
02bb8761fcce Initial load
duke
parents:
diff changeset
   355
02bb8761fcce Initial load
duke
parents:
diff changeset
   356
        return this;
02bb8761fcce Initial load
duke
parents:
diff changeset
   357
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   358
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   359
02bb8761fcce Initial load
duke
parents:
diff changeset
   360
    public final String getUnqualifiedName() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   361
        if (unqualifiedName == null){
02bb8761fcce Initial load
duke
parents:
diff changeset
   362
            String className = getClassName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   363
            int index = (className != null) ? className.lastIndexOf('.') : -1;
02bb8761fcce Initial load
duke
parents:
diff changeset
   364
            if (index == -1){
02bb8761fcce Initial load
duke
parents:
diff changeset
   365
                unqualifiedName = className;
02bb8761fcce Initial load
duke
parents:
diff changeset
   366
                definedInId = "IDL::1.0";
02bb8761fcce Initial load
duke
parents:
diff changeset
   367
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   368
            else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   369
                unqualifiedName = className.substring(index);
02bb8761fcce Initial load
duke
parents:
diff changeset
   370
                definedInId = "IDL:" + className.substring(0, index).replace('.','/') + ":1.0";
02bb8761fcce Initial load
duke
parents:
diff changeset
   371
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   372
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   373
02bb8761fcce Initial load
duke
parents:
diff changeset
   374
        return unqualifiedName;
02bb8761fcce Initial load
duke
parents:
diff changeset
   375
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   376
02bb8761fcce Initial load
duke
parents:
diff changeset
   377
    public final String getDefinedInId() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   378
        if (definedInId == null){
02bb8761fcce Initial load
duke
parents:
diff changeset
   379
            getUnqualifiedName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   380
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   381
02bb8761fcce Initial load
duke
parents:
diff changeset
   382
        return definedInId;
02bb8761fcce Initial load
duke
parents:
diff changeset
   383
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   384
02bb8761fcce Initial load
duke
parents:
diff changeset
   385
    public final String getTypeString() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   386
        return typeString;
02bb8761fcce Initial load
duke
parents:
diff changeset
   387
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   388
02bb8761fcce Initial load
duke
parents:
diff changeset
   389
    public final String getVersionString() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   390
        return versionString;
02bb8761fcce Initial load
duke
parents:
diff changeset
   391
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   392
02bb8761fcce Initial load
duke
parents:
diff changeset
   393
    public final String getSerialVersionUID() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   394
        return suid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   395
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   396
02bb8761fcce Initial load
duke
parents:
diff changeset
   397
    public final String getActualSerialVersionUID() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   398
        return actualSuid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   399
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   400
    public final long getSerialVersionUIDAsLong() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   401
        return suidLong;
02bb8761fcce Initial load
duke
parents:
diff changeset
   402
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   403
02bb8761fcce Initial load
duke
parents:
diff changeset
   404
    public final long getActualSerialVersionUIDAsLong() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   405
        return actualSuidLong;
02bb8761fcce Initial load
duke
parents:
diff changeset
   406
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   407
02bb8761fcce Initial load
duke
parents:
diff changeset
   408
    public final boolean isRMIValueType() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   409
        return isRMIValueType;
02bb8761fcce Initial load
duke
parents:
diff changeset
   410
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   411
02bb8761fcce Initial load
duke
parents:
diff changeset
   412
    public final boolean isIDLType() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   413
        return isIDLType;
02bb8761fcce Initial load
duke
parents:
diff changeset
   414
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   415
02bb8761fcce Initial load
duke
parents:
diff changeset
   416
    public final String getRepositoryId() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   417
        return repId;
02bb8761fcce Initial load
duke
parents:
diff changeset
   418
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   419
02bb8761fcce Initial load
duke
parents:
diff changeset
   420
    public static byte[] getByteArray(String repStr) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   421
        synchronized (repStrToByteArray){
02bb8761fcce Initial load
duke
parents:
diff changeset
   422
            return (byte[]) repStrToByteArray.get(repStr);
02bb8761fcce Initial load
duke
parents:
diff changeset
   423
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   424
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   425
02bb8761fcce Initial load
duke
parents:
diff changeset
   426
    public static void setByteArray(String repStr, byte[] repStrBytes) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   427
        synchronized (repStrToByteArray){
02bb8761fcce Initial load
duke
parents:
diff changeset
   428
            repStrToByteArray.put(repStr, repStrBytes);
02bb8761fcce Initial load
duke
parents:
diff changeset
   429
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   430
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   431
02bb8761fcce Initial load
duke
parents:
diff changeset
   432
    public final boolean isSequence() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   433
        return isSequence;
02bb8761fcce Initial load
duke
parents:
diff changeset
   434
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   435
02bb8761fcce Initial load
duke
parents:
diff changeset
   436
    public final boolean isSupportedFormat() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   437
        return isSupportedFormat;
02bb8761fcce Initial load
duke
parents:
diff changeset
   438
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   439
02bb8761fcce Initial load
duke
parents:
diff changeset
   440
02bb8761fcce Initial load
duke
parents:
diff changeset
   441
    // This method will return the classname from the typestring OR if the classname turns out to be
02bb8761fcce Initial load
duke
parents:
diff changeset
   442
    // a special class "pseudo" name, then the matching real classname is returned.
02bb8761fcce Initial load
duke
parents:
diff changeset
   443
    public final String getClassName() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   444
02bb8761fcce Initial load
duke
parents:
diff changeset
   445
        if (isRMIValueType)
02bb8761fcce Initial load
duke
parents:
diff changeset
   446
            return typeString;
02bb8761fcce Initial load
duke
parents:
diff changeset
   447
        else if (isIDLType)
02bb8761fcce Initial load
duke
parents:
diff changeset
   448
            return completeClassName;
02bb8761fcce Initial load
duke
parents:
diff changeset
   449
        else return null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   450
02bb8761fcce Initial load
duke
parents:
diff changeset
   451
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   452
02bb8761fcce Initial load
duke
parents:
diff changeset
   453
    // This method calls getClazzFromType() and falls back to the repStrToClass
02bb8761fcce Initial load
duke
parents:
diff changeset
   454
    // cache if no class was found.  It's used where any class matching the
02bb8761fcce Initial load
duke
parents:
diff changeset
   455
    // given repid is an acceptable result.
02bb8761fcce Initial load
duke
parents:
diff changeset
   456
    public final Class getAnyClassFromType() throws ClassNotFoundException {
02bb8761fcce Initial load
duke
parents:
diff changeset
   457
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   458
            return getClassFromType();
02bb8761fcce Initial load
duke
parents:
diff changeset
   459
        } catch (ClassNotFoundException cnfe) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   460
            Class clz = (Class)repStrToClass.get(repId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   461
            if (clz != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   462
                return clz;
02bb8761fcce Initial load
duke
parents:
diff changeset
   463
            else
02bb8761fcce Initial load
duke
parents:
diff changeset
   464
                throw cnfe;
02bb8761fcce Initial load
duke
parents:
diff changeset
   465
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   466
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   467
02bb8761fcce Initial load
duke
parents:
diff changeset
   468
    public final Class getClassFromType()
02bb8761fcce Initial load
duke
parents:
diff changeset
   469
        throws ClassNotFoundException {
02bb8761fcce Initial load
duke
parents:
diff changeset
   470
        if (clazz != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   471
            return clazz;
02bb8761fcce Initial load
duke
parents:
diff changeset
   472
02bb8761fcce Initial load
duke
parents:
diff changeset
   473
        Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());
02bb8761fcce Initial load
duke
parents:
diff changeset
   474
02bb8761fcce Initial load
duke
parents:
diff changeset
   475
        if (specialCase != null){
02bb8761fcce Initial load
duke
parents:
diff changeset
   476
            clazz = specialCase;
02bb8761fcce Initial load
duke
parents:
diff changeset
   477
            return specialCase;
02bb8761fcce Initial load
duke
parents:
diff changeset
   478
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   479
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   480
            {
02bb8761fcce Initial load
duke
parents:
diff changeset
   481
                try{
02bb8761fcce Initial load
duke
parents:
diff changeset
   482
                    return Util.loadClass(getClassName(), null, null);
02bb8761fcce Initial load
duke
parents:
diff changeset
   483
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   484
                catch(ClassNotFoundException cnfe){
02bb8761fcce Initial load
duke
parents:
diff changeset
   485
                    if (defaultServerURL != null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   486
                        try{
02bb8761fcce Initial load
duke
parents:
diff changeset
   487
                            return getClassFromType(defaultServerURL);
02bb8761fcce Initial load
duke
parents:
diff changeset
   488
                        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   489
                        catch(MalformedURLException mue){
02bb8761fcce Initial load
duke
parents:
diff changeset
   490
                            throw cnfe;
02bb8761fcce Initial load
duke
parents:
diff changeset
   491
                        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   492
                    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   493
                    else throw cnfe;
02bb8761fcce Initial load
duke
parents:
diff changeset
   494
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   495
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   496
02bb8761fcce Initial load
duke
parents:
diff changeset
   497
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   498
02bb8761fcce Initial load
duke
parents:
diff changeset
   499
    public final Class getClassFromType(Class expectedType, String codebase)
02bb8761fcce Initial load
duke
parents:
diff changeset
   500
        throws ClassNotFoundException {
02bb8761fcce Initial load
duke
parents:
diff changeset
   501
        if (clazz != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   502
            return clazz;
02bb8761fcce Initial load
duke
parents:
diff changeset
   503
02bb8761fcce Initial load
duke
parents:
diff changeset
   504
        Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());
02bb8761fcce Initial load
duke
parents:
diff changeset
   505
02bb8761fcce Initial load
duke
parents:
diff changeset
   506
        if (specialCase != null){
02bb8761fcce Initial load
duke
parents:
diff changeset
   507
            clazz = specialCase;
02bb8761fcce Initial load
duke
parents:
diff changeset
   508
            return specialCase;
02bb8761fcce Initial load
duke
parents:
diff changeset
   509
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   510
            ClassLoader expectedTypeClassLoader = (expectedType == null ? null : expectedType.getClassLoader());
02bb8761fcce Initial load
duke
parents:
diff changeset
   511
            return loadClassOfType(getClassName(),
02bb8761fcce Initial load
duke
parents:
diff changeset
   512
                                            codebase,
02bb8761fcce Initial load
duke
parents:
diff changeset
   513
                                            expectedTypeClassLoader,
02bb8761fcce Initial load
duke
parents:
diff changeset
   514
                                            expectedType,
02bb8761fcce Initial load
duke
parents:
diff changeset
   515
                                            expectedTypeClassLoader);
02bb8761fcce Initial load
duke
parents:
diff changeset
   516
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   517
02bb8761fcce Initial load
duke
parents:
diff changeset
   518
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   519
02bb8761fcce Initial load
duke
parents:
diff changeset
   520
    public final Class getClassFromType(String url)
02bb8761fcce Initial load
duke
parents:
diff changeset
   521
        throws ClassNotFoundException, MalformedURLException {
02bb8761fcce Initial load
duke
parents:
diff changeset
   522
        return Util.loadClass(getClassName(), url, null);
02bb8761fcce Initial load
duke
parents:
diff changeset
   523
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   524
02bb8761fcce Initial load
duke
parents:
diff changeset
   525
    public final String toString() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   526
        return repId;
02bb8761fcce Initial load
duke
parents:
diff changeset
   527
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   528
02bb8761fcce Initial load
duke
parents:
diff changeset
   529
    private static String createHashString(java.io.Serializable ser) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   530
02bb8761fcce Initial load
duke
parents:
diff changeset
   531
        return createHashString(ser.getClass());
02bb8761fcce Initial load
duke
parents:
diff changeset
   532
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   533
02bb8761fcce Initial load
duke
parents:
diff changeset
   534
    private static String createHashString(java.lang.Class clazz) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   535
02bb8761fcce Initial load
duke
parents:
diff changeset
   536
        if (clazz.isInterface() || !java.io.Serializable.class.isAssignableFrom(clazz))
02bb8761fcce Initial load
duke
parents:
diff changeset
   537
            return kInterfaceHashCode;
02bb8761fcce Initial load
duke
parents:
diff changeset
   538
02bb8761fcce Initial load
duke
parents:
diff changeset
   539
02bb8761fcce Initial load
duke
parents:
diff changeset
   540
        long actualLong = ObjectStreamClassUtil_1_3.computeStructuralUID(false, clazz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   541
        String hash = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   542
        if (actualLong == 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
   543
            hash = kInterfaceOnlyHashStr;
02bb8761fcce Initial load
duke
parents:
diff changeset
   544
        else if (actualLong == 1)
02bb8761fcce Initial load
duke
parents:
diff changeset
   545
            hash = kExternalizableHashStr;
02bb8761fcce Initial load
duke
parents:
diff changeset
   546
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   547
            hash = Long.toHexString(actualLong).toUpperCase();
02bb8761fcce Initial load
duke
parents:
diff changeset
   548
        while(hash.length() < 16){
02bb8761fcce Initial load
duke
parents:
diff changeset
   549
            hash = "0" + hash;
02bb8761fcce Initial load
duke
parents:
diff changeset
   550
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   551
02bb8761fcce Initial load
duke
parents:
diff changeset
   552
        long declaredLong = ObjectStreamClassUtil_1_3.computeSerialVersionUID(clazz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   553
        String declared = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   554
        if (declaredLong == 0)
02bb8761fcce Initial load
duke
parents:
diff changeset
   555
            declared = kInterfaceOnlyHashStr;
02bb8761fcce Initial load
duke
parents:
diff changeset
   556
        else if (declaredLong == 1)
02bb8761fcce Initial load
duke
parents:
diff changeset
   557
            declared = kExternalizableHashStr;
02bb8761fcce Initial load
duke
parents:
diff changeset
   558
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   559
            declared = Long.toHexString(declaredLong).toUpperCase();
02bb8761fcce Initial load
duke
parents:
diff changeset
   560
        while (declared.length() < 16){
02bb8761fcce Initial load
duke
parents:
diff changeset
   561
            declared = "0" + declared;
02bb8761fcce Initial load
duke
parents:
diff changeset
   562
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   563
        hash = hash + ":" + declared;
02bb8761fcce Initial load
duke
parents:
diff changeset
   564
02bb8761fcce Initial load
duke
parents:
diff changeset
   565
        return ":" + hash;
02bb8761fcce Initial load
duke
parents:
diff changeset
   566
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   567
02bb8761fcce Initial load
duke
parents:
diff changeset
   568
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   569
     * Creates a repository ID for a sequence.  This is for expert users only as
02bb8761fcce Initial load
duke
parents:
diff changeset
   570
     * this method assumes the object passed is an array.  If passed an object
02bb8761fcce Initial load
duke
parents:
diff changeset
   571
     * that is not an array, it will produce a rep id for a sequence of zero
02bb8761fcce Initial load
duke
parents:
diff changeset
   572
     * length.  This would be an error.
02bb8761fcce Initial load
duke
parents:
diff changeset
   573
     * @param ser The Java object to create a repository ID for
02bb8761fcce Initial load
duke
parents:
diff changeset
   574
     **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   575
    public static String createSequenceRepID(java.lang.Object ser){
02bb8761fcce Initial load
duke
parents:
diff changeset
   576
        return createSequenceRepID(ser.getClass());
02bb8761fcce Initial load
duke
parents:
diff changeset
   577
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   578
02bb8761fcce Initial load
duke
parents:
diff changeset
   579
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   580
     * Creates a repository ID for a sequence.  This is for expert users only as
02bb8761fcce Initial load
duke
parents:
diff changeset
   581
     * this method assumes the object passed is an array.  If passed an object
02bb8761fcce Initial load
duke
parents:
diff changeset
   582
     * that is not an array, it will produce a malformed rep id.
02bb8761fcce Initial load
duke
parents:
diff changeset
   583
     * @param clazz The Java class to create a repository ID for
02bb8761fcce Initial load
duke
parents:
diff changeset
   584
     **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   585
    public static String createSequenceRepID(java.lang.Class clazz){
02bb8761fcce Initial load
duke
parents:
diff changeset
   586
        synchronized (classSeqToRepStr){
02bb8761fcce Initial load
duke
parents:
diff changeset
   587
02bb8761fcce Initial load
duke
parents:
diff changeset
   588
        String repid = (String)classSeqToRepStr.get(clazz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   589
        if (repid != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   590
            return repid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   591
02bb8761fcce Initial load
duke
parents:
diff changeset
   592
        Class originalClazz = clazz;
02bb8761fcce Initial load
duke
parents:
diff changeset
   593
02bb8761fcce Initial load
duke
parents:
diff changeset
   594
        Class type = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   595
        int numOfDims = 0;
02bb8761fcce Initial load
duke
parents:
diff changeset
   596
02bb8761fcce Initial load
duke
parents:
diff changeset
   597
        while ((type = clazz.getComponentType()) != null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   598
            numOfDims++;
02bb8761fcce Initial load
duke
parents:
diff changeset
   599
            clazz = type;
02bb8761fcce Initial load
duke
parents:
diff changeset
   600
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   601
02bb8761fcce Initial load
duke
parents:
diff changeset
   602
        if (clazz.isPrimitive())
02bb8761fcce Initial load
duke
parents:
diff changeset
   603
            repid = kValuePrefix + originalClazz.getName() + kPrimitiveSequenceValueHash;
02bb8761fcce Initial load
duke
parents:
diff changeset
   604
        else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   605
            StringBuffer buf = new StringBuffer();
02bb8761fcce Initial load
duke
parents:
diff changeset
   606
            buf.append(kValuePrefix);
02bb8761fcce Initial load
duke
parents:
diff changeset
   607
            while(numOfDims-- > 0) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   608
                buf.append("[");
02bb8761fcce Initial load
duke
parents:
diff changeset
   609
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   610
            buf.append("L");
02bb8761fcce Initial load
duke
parents:
diff changeset
   611
            buf.append(convertToISOLatin1(clazz.getName()));
02bb8761fcce Initial load
duke
parents:
diff changeset
   612
            buf.append(";");
02bb8761fcce Initial load
duke
parents:
diff changeset
   613
            buf.append(createHashString(clazz));
02bb8761fcce Initial load
duke
parents:
diff changeset
   614
            repid = buf.toString();
02bb8761fcce Initial load
duke
parents:
diff changeset
   615
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   616
        classSeqToRepStr.put(originalClazz,repid);
02bb8761fcce Initial load
duke
parents:
diff changeset
   617
        return repid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   618
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   619
02bb8761fcce Initial load
duke
parents:
diff changeset
   620
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   621
02bb8761fcce Initial load
duke
parents:
diff changeset
   622
02bb8761fcce Initial load
duke
parents:
diff changeset
   623
    public static String createForSpecialCase(java.lang.Class clazz){
02bb8761fcce Initial load
duke
parents:
diff changeset
   624
        if (clazz.isArray()){
02bb8761fcce Initial load
duke
parents:
diff changeset
   625
            return createSequenceRepID(clazz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   626
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   627
        else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   628
            return (String)kSpecialCasesRepIDs.get(clazz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   629
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   630
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   631
02bb8761fcce Initial load
duke
parents:
diff changeset
   632
    public static String createForSpecialCase(java.io.Serializable ser){
02bb8761fcce Initial load
duke
parents:
diff changeset
   633
        Class clazz = ser.getClass();
02bb8761fcce Initial load
duke
parents:
diff changeset
   634
        if (clazz.isArray()){
02bb8761fcce Initial load
duke
parents:
diff changeset
   635
            return createSequenceRepID(ser);
02bb8761fcce Initial load
duke
parents:
diff changeset
   636
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   637
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   638
            return createForSpecialCase(clazz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   639
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   640
02bb8761fcce Initial load
duke
parents:
diff changeset
   641
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   642
     * Creates a repository ID for a normal Java Type.
02bb8761fcce Initial load
duke
parents:
diff changeset
   643
     * @param ser The Java object to create a repository ID for
02bb8761fcce Initial load
duke
parents:
diff changeset
   644
     * @exception com.sun.corba.se.impl.io.TypeMismatchException if ser implements the
02bb8761fcce Initial load
duke
parents:
diff changeset
   645
     * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
02bb8761fcce Initial load
duke
parents:
diff changeset
   646
     **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   647
    public static String createForJavaType(java.io.Serializable ser)
02bb8761fcce Initial load
duke
parents:
diff changeset
   648
        throws com.sun.corba.se.impl.io.TypeMismatchException
02bb8761fcce Initial load
duke
parents:
diff changeset
   649
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   650
        synchronized (classToRepStr) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   651
        String repid = createForSpecialCase(ser);
02bb8761fcce Initial load
duke
parents:
diff changeset
   652
        if (repid != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   653
            return repid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   654
        Class clazz = ser.getClass();
02bb8761fcce Initial load
duke
parents:
diff changeset
   655
        repid = (String)classToRepStr.get(clazz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   656
02bb8761fcce Initial load
duke
parents:
diff changeset
   657
        if (repid != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   658
            return repid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   659
02bb8761fcce Initial load
duke
parents:
diff changeset
   660
        repid = kValuePrefix + convertToISOLatin1(clazz.getName()) +
02bb8761fcce Initial load
duke
parents:
diff changeset
   661
            createHashString(clazz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   662
02bb8761fcce Initial load
duke
parents:
diff changeset
   663
        classToRepStr.put(clazz, repid);
02bb8761fcce Initial load
duke
parents:
diff changeset
   664
            repStrToClass.put(repid, clazz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   665
        return repid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   666
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   667
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   668
02bb8761fcce Initial load
duke
parents:
diff changeset
   669
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   670
     * Creates a repository ID for a normal Java Type.
02bb8761fcce Initial load
duke
parents:
diff changeset
   671
     * @param clz The Java class to create a repository ID for
02bb8761fcce Initial load
duke
parents:
diff changeset
   672
     * @exception com.sun.corba.se.impl.io.TypeMismatchException if ser implements the
02bb8761fcce Initial load
duke
parents:
diff changeset
   673
     * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
02bb8761fcce Initial load
duke
parents:
diff changeset
   674
     **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   675
    public static String createForJavaType(Class clz)
02bb8761fcce Initial load
duke
parents:
diff changeset
   676
        throws com.sun.corba.se.impl.io.TypeMismatchException
02bb8761fcce Initial load
duke
parents:
diff changeset
   677
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   678
        synchronized (classToRepStr){
02bb8761fcce Initial load
duke
parents:
diff changeset
   679
        String repid = createForSpecialCase(clz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   680
        if (repid != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   681
            return repid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   682
02bb8761fcce Initial load
duke
parents:
diff changeset
   683
        repid = (String)classToRepStr.get(clz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   684
        if (repid != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   685
            return repid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   686
02bb8761fcce Initial load
duke
parents:
diff changeset
   687
        repid = kValuePrefix + convertToISOLatin1(clz.getName()) +
02bb8761fcce Initial load
duke
parents:
diff changeset
   688
            createHashString(clz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   689
02bb8761fcce Initial load
duke
parents:
diff changeset
   690
        classToRepStr.put(clz, repid);
02bb8761fcce Initial load
duke
parents:
diff changeset
   691
            repStrToClass.put(repid, clz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   692
        return repid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   693
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   694
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   695
02bb8761fcce Initial load
duke
parents:
diff changeset
   696
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   697
     * Creates a repository ID for an IDL Java Type.
02bb8761fcce Initial load
duke
parents:
diff changeset
   698
     * @param ser The IDL Value object to create a repository ID for
02bb8761fcce Initial load
duke
parents:
diff changeset
   699
     * @param major The major version number
02bb8761fcce Initial load
duke
parents:
diff changeset
   700
     * @param minor The minor version number
02bb8761fcce Initial load
duke
parents:
diff changeset
   701
     * @exception com.sun.corba.se.impl.io.TypeMismatchException if ser does not implement the
02bb8761fcce Initial load
duke
parents:
diff changeset
   702
     * org.omg.CORBA.portable.IDLEntity interface which indicates it is an IDL Value type.
02bb8761fcce Initial load
duke
parents:
diff changeset
   703
     **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   704
    public static String createForIDLType(Class ser, int major, int minor)
02bb8761fcce Initial load
duke
parents:
diff changeset
   705
        throws com.sun.corba.se.impl.io.TypeMismatchException
02bb8761fcce Initial load
duke
parents:
diff changeset
   706
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   707
        synchronized (classIDLToRepStr){
02bb8761fcce Initial load
duke
parents:
diff changeset
   708
        String repid = (String)classIDLToRepStr.get(ser);
02bb8761fcce Initial load
duke
parents:
diff changeset
   709
        if (repid != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   710
            return repid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   711
02bb8761fcce Initial load
duke
parents:
diff changeset
   712
        repid = kIDLPrefix + convertToISOLatin1(ser.getName()).replace('.','/') +
02bb8761fcce Initial load
duke
parents:
diff changeset
   713
            ":" + major + "." + minor;
02bb8761fcce Initial load
duke
parents:
diff changeset
   714
        classIDLToRepStr.put(ser, repid);
02bb8761fcce Initial load
duke
parents:
diff changeset
   715
        return repid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   716
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   717
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   718
02bb8761fcce Initial load
duke
parents:
diff changeset
   719
    private static String getIdFromHelper(Class clazz){
02bb8761fcce Initial load
duke
parents:
diff changeset
   720
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   721
            Class helperClazz = Utility.loadClassForClass(clazz.getName()+"Helper", null,
02bb8761fcce Initial load
duke
parents:
diff changeset
   722
                                    clazz.getClassLoader(), clazz, clazz.getClassLoader());
02bb8761fcce Initial load
duke
parents:
diff changeset
   723
            Method idMethod = helperClazz.getDeclaredMethod("id", kNoParamTypes);
02bb8761fcce Initial load
duke
parents:
diff changeset
   724
            return (String)idMethod.invoke(null, kNoArgs);
02bb8761fcce Initial load
duke
parents:
diff changeset
   725
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   726
        catch(java.lang.ClassNotFoundException cnfe)
02bb8761fcce Initial load
duke
parents:
diff changeset
   727
            {
02bb8761fcce Initial load
duke
parents:
diff changeset
   728
                throw new org.omg.CORBA.MARSHAL(cnfe.toString());
02bb8761fcce Initial load
duke
parents:
diff changeset
   729
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   730
        catch(java.lang.NoSuchMethodException nsme)
02bb8761fcce Initial load
duke
parents:
diff changeset
   731
            {
02bb8761fcce Initial load
duke
parents:
diff changeset
   732
                throw new org.omg.CORBA.MARSHAL(nsme.toString());
02bb8761fcce Initial load
duke
parents:
diff changeset
   733
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   734
        catch(java.lang.reflect.InvocationTargetException ite)
02bb8761fcce Initial load
duke
parents:
diff changeset
   735
            {
02bb8761fcce Initial load
duke
parents:
diff changeset
   736
                throw new org.omg.CORBA.MARSHAL(ite.toString());
02bb8761fcce Initial load
duke
parents:
diff changeset
   737
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   738
        catch(java.lang.IllegalAccessException iae)
02bb8761fcce Initial load
duke
parents:
diff changeset
   739
            {
02bb8761fcce Initial load
duke
parents:
diff changeset
   740
                throw new org.omg.CORBA.MARSHAL(iae.toString());
02bb8761fcce Initial load
duke
parents:
diff changeset
   741
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   742
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   743
02bb8761fcce Initial load
duke
parents:
diff changeset
   744
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   745
     * Createa a repository ID for the type if it is either a java type
02bb8761fcce Initial load
duke
parents:
diff changeset
   746
     * or an IDL type.
02bb8761fcce Initial load
duke
parents:
diff changeset
   747
     * @param type The type to create rep. id for
02bb8761fcce Initial load
duke
parents:
diff changeset
   748
     * @return The rep. id.
02bb8761fcce Initial load
duke
parents:
diff changeset
   749
     **/
02bb8761fcce Initial load
duke
parents:
diff changeset
   750
    public static String createForAnyType(Class type) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   751
        try{
02bb8761fcce Initial load
duke
parents:
diff changeset
   752
            if (type.isArray())
02bb8761fcce Initial load
duke
parents:
diff changeset
   753
                return createSequenceRepID(type);
02bb8761fcce Initial load
duke
parents:
diff changeset
   754
            else if (IDLEntity.class.isAssignableFrom(type))
02bb8761fcce Initial load
duke
parents:
diff changeset
   755
                {
02bb8761fcce Initial load
duke
parents:
diff changeset
   756
                    try{
02bb8761fcce Initial load
duke
parents:
diff changeset
   757
                        return getIdFromHelper(type);
02bb8761fcce Initial load
duke
parents:
diff changeset
   758
                    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   759
                    catch(Throwable t) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   760
                        return createForIDLType(type, 1, 0);
02bb8761fcce Initial load
duke
parents:
diff changeset
   761
                    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   762
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   763
            else return createForJavaType(type);
02bb8761fcce Initial load
duke
parents:
diff changeset
   764
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   765
        catch(com.sun.corba.se.impl.io.TypeMismatchException e){
02bb8761fcce Initial load
duke
parents:
diff changeset
   766
            return null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   767
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   768
02bb8761fcce Initial load
duke
parents:
diff changeset
   769
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   770
02bb8761fcce Initial load
duke
parents:
diff changeset
   771
    public static boolean isAbstractBase(Class clazz) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   772
        return (clazz.isInterface() &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   773
                IDLEntity.class.isAssignableFrom(clazz) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   774
                (!ValueBase.class.isAssignableFrom(clazz)) &&
02bb8761fcce Initial load
duke
parents:
diff changeset
   775
                (!org.omg.CORBA.Object.class.isAssignableFrom(clazz)));
02bb8761fcce Initial load
duke
parents:
diff changeset
   776
02bb8761fcce Initial load
duke
parents:
diff changeset
   777
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   778
02bb8761fcce Initial load
duke
parents:
diff changeset
   779
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   780
     * Convert strings with illegal IDL identifier characters.
02bb8761fcce Initial load
duke
parents:
diff changeset
   781
     * <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   782
     * Section 5.5.7 of OBV spec.
02bb8761fcce Initial load
duke
parents:
diff changeset
   783
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   784
    private static String convertToISOLatin1 (String name) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   785
02bb8761fcce Initial load
duke
parents:
diff changeset
   786
        int length = name.length();
02bb8761fcce Initial load
duke
parents:
diff changeset
   787
        if (length == 0) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   788
            return name;
02bb8761fcce Initial load
duke
parents:
diff changeset
   789
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   790
        StringBuffer buffer = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   791
02bb8761fcce Initial load
duke
parents:
diff changeset
   792
        for (int i = 0; i < length; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   793
02bb8761fcce Initial load
duke
parents:
diff changeset
   794
            char c = name.charAt(i);
02bb8761fcce Initial load
duke
parents:
diff changeset
   795
02bb8761fcce Initial load
duke
parents:
diff changeset
   796
            if (c > 255 || IDL_IDENTIFIER_CHARS[c] == 0) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   797
02bb8761fcce Initial load
duke
parents:
diff changeset
   798
                // We gotta convert. Have we already started?
02bb8761fcce Initial load
duke
parents:
diff changeset
   799
02bb8761fcce Initial load
duke
parents:
diff changeset
   800
                if (buffer == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   801
02bb8761fcce Initial load
duke
parents:
diff changeset
   802
                    // No, so get set up...
02bb8761fcce Initial load
duke
parents:
diff changeset
   803
02bb8761fcce Initial load
duke
parents:
diff changeset
   804
                    buffer = new StringBuffer(name.substring(0,i));
02bb8761fcce Initial load
duke
parents:
diff changeset
   805
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   806
02bb8761fcce Initial load
duke
parents:
diff changeset
   807
                // Convert the character into the IDL escape syntax...
02bb8761fcce Initial load
duke
parents:
diff changeset
   808
                buffer.append(
02bb8761fcce Initial load
duke
parents:
diff changeset
   809
                              "\\U" +
02bb8761fcce Initial load
duke
parents:
diff changeset
   810
                              (char)ASCII_HEX[(c & 0xF000) >>> 12] +
02bb8761fcce Initial load
duke
parents:
diff changeset
   811
                              (char)ASCII_HEX[(c & 0x0F00) >>> 8] +
02bb8761fcce Initial load
duke
parents:
diff changeset
   812
                              (char)ASCII_HEX[(c & 0x00F0) >>> 4] +
02bb8761fcce Initial load
duke
parents:
diff changeset
   813
                              (char)ASCII_HEX[(c & 0x000F)]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   814
02bb8761fcce Initial load
duke
parents:
diff changeset
   815
            } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   816
                if (buffer != null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   817
                    buffer.append(c);
02bb8761fcce Initial load
duke
parents:
diff changeset
   818
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   819
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   820
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   821
02bb8761fcce Initial load
duke
parents:
diff changeset
   822
        if (buffer != null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   823
            name = buffer.toString();
02bb8761fcce Initial load
duke
parents:
diff changeset
   824
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   825
02bb8761fcce Initial load
duke
parents:
diff changeset
   826
        return name;
02bb8761fcce Initial load
duke
parents:
diff changeset
   827
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   828
02bb8761fcce Initial load
duke
parents:
diff changeset
   829
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   830
     * Convert strings with ISO Latin 1 escape sequences back to original strings.
02bb8761fcce Initial load
duke
parents:
diff changeset
   831
     * <p>
02bb8761fcce Initial load
duke
parents:
diff changeset
   832
     * Section 5.5.7 of OBV spec.
02bb8761fcce Initial load
duke
parents:
diff changeset
   833
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   834
    private static String convertFromISOLatin1 (String name) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   835
02bb8761fcce Initial load
duke
parents:
diff changeset
   836
        int index = -1;
02bb8761fcce Initial load
duke
parents:
diff changeset
   837
        StringBuffer buf = new StringBuffer(name);
02bb8761fcce Initial load
duke
parents:
diff changeset
   838
02bb8761fcce Initial load
duke
parents:
diff changeset
   839
        while ((index = buf.toString().indexOf("\\U")) != -1){
02bb8761fcce Initial load
duke
parents:
diff changeset
   840
            String str = "0000" + buf.toString().substring(index+2, index+6);
02bb8761fcce Initial load
duke
parents:
diff changeset
   841
02bb8761fcce Initial load
duke
parents:
diff changeset
   842
            // Convert Hexadecimal
02bb8761fcce Initial load
duke
parents:
diff changeset
   843
            byte[] buffer = new byte[(str.length() - 4) / 2];
02bb8761fcce Initial load
duke
parents:
diff changeset
   844
            for (int i=4, j=0; i < str.length(); i +=2, j++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   845
                buffer[j] = (byte)((ORBUtility.hexOf(str.charAt(i)) << 4) & 0xF0);
02bb8761fcce Initial load
duke
parents:
diff changeset
   846
                buffer[j] |= (byte)((ORBUtility.hexOf(str.charAt(i+1)) << 0) & 0x0F);
02bb8761fcce Initial load
duke
parents:
diff changeset
   847
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   848
            buf = new StringBuffer(delete(buf.toString(), index, index+6));
02bb8761fcce Initial load
duke
parents:
diff changeset
   849
            buf.insert(index, (char)buffer[1]);
02bb8761fcce Initial load
duke
parents:
diff changeset
   850
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   851
02bb8761fcce Initial load
duke
parents:
diff changeset
   852
        return buf.toString();
02bb8761fcce Initial load
duke
parents:
diff changeset
   853
02bb8761fcce Initial load
duke
parents:
diff changeset
   854
02bb8761fcce Initial load
duke
parents:
diff changeset
   855
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   856
02bb8761fcce Initial load
duke
parents:
diff changeset
   857
    private static String delete(String str, int from, int to)
02bb8761fcce Initial load
duke
parents:
diff changeset
   858
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   859
        return str.substring(0, from) + str.substring(to, str.length());
02bb8761fcce Initial load
duke
parents:
diff changeset
   860
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   861
02bb8761fcce Initial load
duke
parents:
diff changeset
   862
    private static String replace(String target, String arg, String source)
02bb8761fcce Initial load
duke
parents:
diff changeset
   863
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   864
        int i = 0;
02bb8761fcce Initial load
duke
parents:
diff changeset
   865
        i = target.indexOf(arg);
02bb8761fcce Initial load
duke
parents:
diff changeset
   866
02bb8761fcce Initial load
duke
parents:
diff changeset
   867
        while(i != -1)
02bb8761fcce Initial load
duke
parents:
diff changeset
   868
            {
02bb8761fcce Initial load
duke
parents:
diff changeset
   869
                String left = target.substring(0, i);
02bb8761fcce Initial load
duke
parents:
diff changeset
   870
                String right = target.substring(i+arg.length());
02bb8761fcce Initial load
duke
parents:
diff changeset
   871
                target = new String(left+source+right);
02bb8761fcce Initial load
duke
parents:
diff changeset
   872
                i = target.indexOf(arg);
02bb8761fcce Initial load
duke
parents:
diff changeset
   873
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   874
        return target;
02bb8761fcce Initial load
duke
parents:
diff changeset
   875
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   876
02bb8761fcce Initial load
duke
parents:
diff changeset
   877
    /*
02bb8761fcce Initial load
duke
parents:
diff changeset
   878
     * Load a class and check that it is assignable to a given type.
02bb8761fcce Initial load
duke
parents:
diff changeset
   879
     * @param className the class name.
02bb8761fcce Initial load
duke
parents:
diff changeset
   880
     * @param remoteCodebase the codebase to use. May be null.
02bb8761fcce Initial load
duke
parents:
diff changeset
   881
     * @param loader the class loader of last resort. May be null.
02bb8761fcce Initial load
duke
parents:
diff changeset
   882
     * @param expectedType the expected type. May be null.
02bb8761fcce Initial load
duke
parents:
diff changeset
   883
     * @return the loaded class.
02bb8761fcce Initial load
duke
parents:
diff changeset
   884
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   885
    private Class loadClassOfType (String className,
02bb8761fcce Initial load
duke
parents:
diff changeset
   886
                                  String remoteCodebase,
02bb8761fcce Initial load
duke
parents:
diff changeset
   887
                                  ClassLoader loader,
02bb8761fcce Initial load
duke
parents:
diff changeset
   888
                                  Class expectedType,
02bb8761fcce Initial load
duke
parents:
diff changeset
   889
                                  ClassLoader expectedTypeClassLoader)
02bb8761fcce Initial load
duke
parents:
diff changeset
   890
        throws ClassNotFoundException {
02bb8761fcce Initial load
duke
parents:
diff changeset
   891
02bb8761fcce Initial load
duke
parents:
diff changeset
   892
        Class loadedClass = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   893
02bb8761fcce Initial load
duke
parents:
diff changeset
   894
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   895
            //Sequence finding of the stubs according to spec
02bb8761fcce Initial load
duke
parents:
diff changeset
   896
            try{
02bb8761fcce Initial load
duke
parents:
diff changeset
   897
                //If-else is put here for speed up of J2EE.
02bb8761fcce Initial load
duke
parents:
diff changeset
   898
                //According to the OMG spec, the if clause is not dead code.
02bb8761fcce Initial load
duke
parents:
diff changeset
   899
                //It can occur if some compiler has allowed generation
02bb8761fcce Initial load
duke
parents:
diff changeset
   900
                //into org.omg.stub hierarchy for non-offending
02bb8761fcce Initial load
duke
parents:
diff changeset
   901
                //classes. This will encourage people to
02bb8761fcce Initial load
duke
parents:
diff changeset
   902
                //produce non-offending class stubs in their own hierarchy.
02bb8761fcce Initial load
duke
parents:
diff changeset
   903
                if(!PackagePrefixChecker
02bb8761fcce Initial load
duke
parents:
diff changeset
   904
                   .hasOffendingPrefix(PackagePrefixChecker
02bb8761fcce Initial load
duke
parents:
diff changeset
   905
                                       .withoutPackagePrefix(className))){
02bb8761fcce Initial load
duke
parents:
diff changeset
   906
                    loadedClass = Util.loadClass
02bb8761fcce Initial load
duke
parents:
diff changeset
   907
                        (PackagePrefixChecker.withoutPackagePrefix(className),
02bb8761fcce Initial load
duke
parents:
diff changeset
   908
                         remoteCodebase,
02bb8761fcce Initial load
duke
parents:
diff changeset
   909
                         loader);
02bb8761fcce Initial load
duke
parents:
diff changeset
   910
                } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   911
                    loadedClass = Util.loadClass
02bb8761fcce Initial load
duke
parents:
diff changeset
   912
                        (className,
02bb8761fcce Initial load
duke
parents:
diff changeset
   913
                         remoteCodebase,
02bb8761fcce Initial load
duke
parents:
diff changeset
   914
                         loader);
02bb8761fcce Initial load
duke
parents:
diff changeset
   915
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   916
            } catch (ClassNotFoundException cnfe) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   917
                loadedClass = Util.loadClass
02bb8761fcce Initial load
duke
parents:
diff changeset
   918
                    (className,
02bb8761fcce Initial load
duke
parents:
diff changeset
   919
                     remoteCodebase,
02bb8761fcce Initial load
duke
parents:
diff changeset
   920
                     loader);
02bb8761fcce Initial load
duke
parents:
diff changeset
   921
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   922
            if (expectedType == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   923
                return loadedClass;
02bb8761fcce Initial load
duke
parents:
diff changeset
   924
        } catch (ClassNotFoundException cnfe) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   925
            if (expectedType == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   926
                throw cnfe;
02bb8761fcce Initial load
duke
parents:
diff changeset
   927
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   928
02bb8761fcce Initial load
duke
parents:
diff changeset
   929
        // If no class was not loaded, or if the loaded class is not of the
02bb8761fcce Initial load
duke
parents:
diff changeset
   930
        // correct type, make a further attempt to load the correct class
02bb8761fcce Initial load
duke
parents:
diff changeset
   931
        // using the classloader of the expected type.
02bb8761fcce Initial load
duke
parents:
diff changeset
   932
        // _REVISIT_ Is this step necessary, or should the Util,loadClass
02bb8761fcce Initial load
duke
parents:
diff changeset
   933
        // algorithm always produce a valid class if the setup is correct?
02bb8761fcce Initial load
duke
parents:
diff changeset
   934
        // Does the OMG standard algorithm need to be changed to include
02bb8761fcce Initial load
duke
parents:
diff changeset
   935
        // this step?
02bb8761fcce Initial load
duke
parents:
diff changeset
   936
        if (loadedClass == null || !expectedType.isAssignableFrom(loadedClass)) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   937
            if (expectedType.getClassLoader() != expectedTypeClassLoader)
02bb8761fcce Initial load
duke
parents:
diff changeset
   938
                throw new IllegalArgumentException("expectedTypeClassLoader not class loader of expectedType.");
02bb8761fcce Initial load
duke
parents:
diff changeset
   939
02bb8761fcce Initial load
duke
parents:
diff changeset
   940
            if (expectedTypeClassLoader != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   941
                loadedClass = expectedTypeClassLoader.loadClass(className);
02bb8761fcce Initial load
duke
parents:
diff changeset
   942
            else
02bb8761fcce Initial load
duke
parents:
diff changeset
   943
                loadedClass = ORBClassLoader.loadClass(className);
02bb8761fcce Initial load
duke
parents:
diff changeset
   944
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   945
02bb8761fcce Initial load
duke
parents:
diff changeset
   946
        return loadedClass;
02bb8761fcce Initial load
duke
parents:
diff changeset
   947
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   948
02bb8761fcce Initial load
duke
parents:
diff changeset
   949
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   950
     * Checks to see if the FullValueDescription should be retrieved.
02bb8761fcce Initial load
duke
parents:
diff changeset
   951
     * @exception Throws IOException if suids do not match or if the repositoryID
02bb8761fcce Initial load
duke
parents:
diff changeset
   952
     * is not an RMIValueType
02bb8761fcce Initial load
duke
parents:
diff changeset
   953
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   954
    public static boolean useFullValueDescription(Class clazz, String repositoryID)
02bb8761fcce Initial load
duke
parents:
diff changeset
   955
        throws IOException{
02bb8761fcce Initial load
duke
parents:
diff changeset
   956
02bb8761fcce Initial load
duke
parents:
diff changeset
   957
        String clazzRepIDStr = createForAnyType(clazz);
02bb8761fcce Initial load
duke
parents:
diff changeset
   958
02bb8761fcce Initial load
duke
parents:
diff changeset
   959
        if (clazzRepIDStr.equals(repositoryID))
02bb8761fcce Initial load
duke
parents:
diff changeset
   960
            return false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   961
02bb8761fcce Initial load
duke
parents:
diff changeset
   962
        RepositoryId_1_3 targetRepid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   963
        RepositoryId_1_3 clazzRepid;
02bb8761fcce Initial load
duke
parents:
diff changeset
   964
02bb8761fcce Initial load
duke
parents:
diff changeset
   965
        synchronized(cache) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   966
        // to avoid race condition where multiple threads could be
02bb8761fcce Initial load
duke
parents:
diff changeset
   967
        // accessing this method, and their access to the cache may
02bb8761fcce Initial load
duke
parents:
diff changeset
   968
        // be interleaved giving unexpected results
02bb8761fcce Initial load
duke
parents:
diff changeset
   969
02bb8761fcce Initial load
duke
parents:
diff changeset
   970
            targetRepid = cache.getId(repositoryID);
02bb8761fcce Initial load
duke
parents:
diff changeset
   971
            clazzRepid = cache.getId(clazzRepIDStr);
02bb8761fcce Initial load
duke
parents:
diff changeset
   972
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   973
02bb8761fcce Initial load
duke
parents:
diff changeset
   974
        if ((targetRepid.isRMIValueType()) && (clazzRepid.isRMIValueType())){
02bb8761fcce Initial load
duke
parents:
diff changeset
   975
            if (!targetRepid.getSerialVersionUID().equals(clazzRepid.getSerialVersionUID())) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   976
02bb8761fcce Initial load
duke
parents:
diff changeset
   977
                String mssg = "Mismatched serialization UIDs : Source (Rep. ID" +
02bb8761fcce Initial load
duke
parents:
diff changeset
   978
                    clazzRepid + ") = " +
02bb8761fcce Initial load
duke
parents:
diff changeset
   979
                    clazzRepid.getSerialVersionUID() + " whereas Target (Rep. ID " + repositoryID +
02bb8761fcce Initial load
duke
parents:
diff changeset
   980
                    ") = " + targetRepid.getSerialVersionUID();
02bb8761fcce Initial load
duke
parents:
diff changeset
   981
                throw new IOException(mssg);
02bb8761fcce Initial load
duke
parents:
diff changeset
   982
            } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   983
                return true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   984
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   985
        } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   986
02bb8761fcce Initial load
duke
parents:
diff changeset
   987
            throw new IOException("The repository ID is not of an RMI value type (Expected ID = " + clazzRepIDStr + "; Received ID = " + repositoryID +")");
02bb8761fcce Initial load
duke
parents:
diff changeset
   988
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   989
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   990
}