Read only archive ; use https://github.com/JacORB/JacORB/issues for new issues
View | Details | Raw Unified | Return to bug 962
Collapse All | Expand All

(-)a/src/org/jacorb/ir/RepositoryID.java (-45 / +46 lines)
Lines 21-26 package org.jacorb.ir; Link Here
21
 */
21
 */
22
22
23
import java.util.StringTokenizer;
23
import java.util.StringTokenizer;
24
import java.util.concurrent.ConcurrentHashMap;
24
import org.omg.CORBA.INTF_REPOS;
25
import org.omg.CORBA.INTF_REPOS;
25
import org.omg.CORBA.portable.BoxedValueHelper;
26
import org.omg.CORBA.portable.BoxedValueHelper;
26
import org.omg.CORBA.StringValueHelper;
27
import org.omg.CORBA.StringValueHelper;
Lines 33-38 import org.omg.CORBA.WStringValueHelper; Link Here
33
 */
34
 */
34
public class RepositoryID
35
public class RepositoryID
35
{
36
{
37
38
  private static ConcurrentHashMap<String, String> scopeCache = null;
39
36
    /**
40
    /**
37
     * Returns the fully qualified name of the Java class to which
41
     * Returns the fully qualified name of the Java class to which
38
     * the given Repository ID is mapped.
42
     * the given Repository ID is mapped.
Lines 129-140 public class RepositoryID Link Here
129
            char theChar = (char)(Integer.parseInt(id.substring(index+2, index+6), 16));
133
            char theChar = (char)(Integer.parseInt(id.substring(index+2, index+6), 16));
130
            dest.append(theChar);
134
            dest.append(theChar);
131
        }
135
        }
132
        
136
133
        if (pos < id.length()) 
137
        if (pos < id.length())
134
        {
138
        {
135
           dest.append(id.substring(pos));
139
           dest.append(id.substring(pos));
136
        }
140
        }
137
        
141
138
        return dest.toString();
142
        return dest.toString();
139
    }
143
    }
140
144
Lines 151-158 public class RepositoryID Link Here
151
    }
155
    }
152
156
153
    /**
157
    /**
154
     * FIXME: This method needs documentation.
158
     * Convert a repoID path string to a fully qualified class name.
155
     * What does this algorithm do, and why is it necessary?  AS.
159
     * Check to see if the final name in the class is actually nested within
160
     * a "intfPackage" package, and modify the FQ class name appropriately.
156
     */
161
     */
157
    private static String ir2scopes (String prefix,
162
    private static String ir2scopes (String prefix,
158
                                     String s,
163
                                     String s,
Lines 162-211 public class RepositoryID Link Here
162
        {
167
        {
163
            return s;
168
            return s;
164
        }
169
        }
165
        java.util.StringTokenizer strtok =
166
            new java.util.StringTokenizer( s, "/" );
167
170
168
        int count = strtok.countTokens();
171
        if (scopeCache == null)
172
          {
173
            scopeCache = new ConcurrentHashMap<String, String> ();
174
          }
175
        else
176
          {
177
            String scope = scopeCache.get (s);
178
            if (scope != null)
179
              {
180
                return scope;
181
              }
182
          }
183
169
        StringBuffer sb = new StringBuffer();
184
        StringBuffer sb = new StringBuffer();
170
        sb.append(prefix);
185
        if (prefix != null && prefix.length() > 0)
186
          {
187
            sb.append(prefix + ".");
188
          }
189
        sb.append (s);
190
        int lastdot = -1;
191
        for (int dotpos = sb.indexOf ("/"); dotpos >= 0;  dotpos = sb.indexOf ("/", dotpos))
192
          {
193
            sb.setCharAt (dotpos, '.');
194
            lastdot = dotpos;
195
          }
171
196
172
        for( int i = 0; strtok.hasMoreTokens(); i++ )
197
        String scope = sb.toString ();
173
        {
198
        if (loadClass (scope, loader) == null)
174
            String sc = strtok.nextToken();
199
          {
175
            Class c = null;
200
            sb.insert (lastdot,"Package");
176
            if( sb.toString().length() > 0 )
201
            String pkgscope = sb.toString ();
177
            {
202
            if (loadClass (pkgscope, loader) != null)
178
                c = loadClass (sb.toString() + "." + sc, loader);
203
              {
179
            }
204
                scope = pkgscope;
180
            else
205
              }
181
            {
206
          }
182
                c = loadClass (sc, loader);
183
            }
184
            if (c == null)
185
            {
186
                if( sb.toString().length() > 0 )
187
                {
188
                    sb.append( "." + sc );
189
                }
190
                else
191
                {
192
                    sb.append( sc );
193
                }
194
            }
195
            else
196
            {
197
                if( i < count-1)
198
                {
199
                    sb.append( "." + sc + "Package");
200
                }
201
                else
202
                {
203
                    sb.append( "." + sc );
204
                }
205
            }
206
        }
207
207
208
        return sb.toString();
208
        scopeCache.put (s, scope);
209
        return scope;
209
    }
210
    }
210
211
211
    public static String repId (Class c)
212
    public static String repId (Class c)

Return to bug 962