corba/src/share/classes/com/sun/corba/se/impl/orbutil/RepIdDelegator.java
author alanb
Mon, 10 Jun 2013 17:15:42 +0100
changeset 18302 3b06314efbd0
parent 5555 b2b5ed3f0d0d
child 22131 4d7b21463768
permissions -rw-r--r--
8016218: Warnings building corba repo due to missing hashCode methods Reviewed-by: chegar, coffeys, dfuchs
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, 2004, 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
package com.sun.corba.se.impl.orbutil;
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
import org.omg.CORBA.ORB;
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
import java.io.Serializable;
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
import java.util.Hashtable;
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
import com.sun.corba.se.impl.io.TypeMismatchException;
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
import java.net.MalformedURLException;
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
import com.sun.corba.se.impl.util.RepositoryId;
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
/**
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
 * Delegates to the current RepositoryId implementation in
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
 * com.sun.corba.se.impl.util.  This is necessary to
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
 * overcome the fact that many of RepositoryId's methods
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
 * are static.
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
public final class RepIdDelegator
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
    implements RepositoryIdStrings,
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
               RepositoryIdUtility,
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
               RepositoryIdInterface
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
{
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
    // RepositoryIdFactory methods
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
    public String createForAnyType(Class type) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
        return RepositoryId.createForAnyType(type);
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
    public String createForJavaType(Serializable ser)
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
        throws TypeMismatchException
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
        return RepositoryId.createForJavaType(ser);
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
    public String createForJavaType(Class clz)
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
        throws TypeMismatchException
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
        return RepositoryId.createForJavaType(clz);
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
    public String createSequenceRepID(java.lang.Object ser) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
        return RepositoryId.createSequenceRepID(ser);
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
    public String createSequenceRepID(Class clazz) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
        return RepositoryId.createSequenceRepID(clazz);
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
    public RepositoryIdInterface getFromString(String repIdString) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
        return new RepIdDelegator(RepositoryId.cache.getId(repIdString));
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
    // RepositoryIdUtility methods
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
    public boolean isChunkedEncoding(int valueTag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
        return RepositoryId.isChunkedEncoding(valueTag);
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
    public boolean isCodeBasePresent(int valueTag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
        return RepositoryId.isCodeBasePresent(valueTag);
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
    public String getClassDescValueRepId() {
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
        return RepositoryId.kClassDescValueRepID;
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
    public String getWStringValueRepId() {
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
        return RepositoryId.kWStringValueRepID;
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
    public int getTypeInfo(int valueTag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
        return RepositoryId.getTypeInfo(valueTag);
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
    public int getStandardRMIChunkedNoRepStrId() {
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
        return RepositoryId.kPreComputed_StandardRMIChunked_NoRep;
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
    public int getCodeBaseRMIChunkedNoRepStrId() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
        return RepositoryId.kPreComputed_CodeBaseRMIChunked_NoRep;
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
    public int getStandardRMIChunkedId() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
        return RepositoryId.kPreComputed_StandardRMIChunked;
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
    public int getCodeBaseRMIChunkedId() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
        return RepositoryId.kPreComputed_CodeBaseRMIChunked;
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
    public int getStandardRMIUnchunkedId() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
        return RepositoryId.kPreComputed_StandardRMIUnchunked;
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
    public int getCodeBaseRMIUnchunkedId() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
        return RepositoryId.kPreComputed_CodeBaseRMIUnchunked;
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
    public int getStandardRMIUnchunkedNoRepStrId() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
        return RepositoryId.kPreComputed_StandardRMIUnchunked_NoRep;
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
    public int getCodeBaseRMIUnchunkedNoRepStrId() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
        return RepositoryId.kPreComputed_CodeBaseRMIUnchunked_NoRep;
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
    // RepositoryIdInterface methods
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
    public Class getClassFromType() throws ClassNotFoundException {
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
        return delegate.getClassFromType();
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
    public Class getClassFromType(String codebaseURL)
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
        throws ClassNotFoundException, MalformedURLException
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
        return delegate.getClassFromType(codebaseURL);
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
    public Class getClassFromType(Class expectedType,
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
                                  String codebaseURL)
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
        throws ClassNotFoundException, MalformedURLException
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
        return delegate.getClassFromType(expectedType, codebaseURL);
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
    public String getClassName() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
        return delegate.getClassName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
    // Constructor used for factory/utility cases
18302
3b06314efbd0 8016218: Warnings building corba repo due to missing hashCode methods
alanb
parents: 5555
diff changeset
   154
    public RepIdDelegator() {
3b06314efbd0 8016218: Warnings building corba repo due to missing hashCode methods
alanb
parents: 5555
diff changeset
   155
        this(null);
3b06314efbd0 8016218: Warnings building corba repo due to missing hashCode methods
alanb
parents: 5555
diff changeset
   156
    }
4
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
    // Constructor used by getIdFromString.  All non-static
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
    // RepositoryId methods will use the provided delegate.
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
    private RepIdDelegator(RepositoryId _delegate) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
        this.delegate = _delegate;
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
18302
3b06314efbd0 8016218: Warnings building corba repo due to missing hashCode methods
alanb
parents: 5555
diff changeset
   164
    private final RepositoryId delegate;
4
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
    public String toString() {
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
        if (delegate != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
            return delegate.toString();
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
            return this.getClass().getName();
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
    public boolean equals(Object obj) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
        if (delegate != null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
            return delegate.equals(obj);
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
            return super.equals(obj);
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
    }
18302
3b06314efbd0 8016218: Warnings building corba repo due to missing hashCode methods
alanb
parents: 5555
diff changeset
   179
3b06314efbd0 8016218: Warnings building corba repo due to missing hashCode methods
alanb
parents: 5555
diff changeset
   180
    public int hashCode() {
3b06314efbd0 8016218: Warnings building corba repo due to missing hashCode methods
alanb
parents: 5555
diff changeset
   181
        if (delegate != null) {
3b06314efbd0 8016218: Warnings building corba repo due to missing hashCode methods
alanb
parents: 5555
diff changeset
   182
            return delegate.hashCode();
3b06314efbd0 8016218: Warnings building corba repo due to missing hashCode methods
alanb
parents: 5555
diff changeset
   183
        } else {
3b06314efbd0 8016218: Warnings building corba repo due to missing hashCode methods
alanb
parents: 5555
diff changeset
   184
            return super.hashCode();
3b06314efbd0 8016218: Warnings building corba repo due to missing hashCode methods
alanb
parents: 5555
diff changeset
   185
        }
3b06314efbd0 8016218: Warnings building corba repo due to missing hashCode methods
alanb
parents: 5555
diff changeset
   186
    }
4
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
}