/[classpath]/classpath/java/lang/ClassLoader.java
ViewVC logotype

Diff of /classpath/java/lang/ClassLoader.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by jewel, Wed Dec 18 10:28:29 2002 UTC revision 1.23 by mark, Fri Jan 17 19:14:07 2003 UTC
# Line 516  public abstract class ClassLoader Line 516  public abstract class ClassLoader
516     */     */
517    public URL getResource(String name)    public URL getResource(String name)
518    {    {
     name = normalize(name);  
519      URL result;      URL result;
520    
521      if (parent == null)      if (parent == null)
# Line 551  public abstract class ClassLoader Line 550  public abstract class ClassLoader
550     */     */
551    public final Enumeration getResources(String name) throws IOException    public final Enumeration getResources(String name) throws IOException
552    {    {
     name = normalize(name);  
553      Enumeration parentResources;      Enumeration parentResources;
554      if (parent == null)      if (parent == null)
555        parentResources = VMClassLoader.getResources(name);        parentResources = VMClassLoader.getResources(name);
# Line 561  public abstract class ClassLoader Line 559  public abstract class ClassLoader
559    }    }
560    
561    /**    /**
    * Normalizes a resource path name. This removes all ./ from the start and  
    * all further '//', "/../" and "/./" from the given name.  
    */  
   private static String normalize(String resource)  
   {  
     while (resource.startsWith("./"))  
       resource = resource.substring(2);  
   
     int index = resource.indexOf("//");  
     while (index != -1)  
       {  
         resource = resource.substring(0, index) + resource.substring(index+1);  
         index = resource.indexOf("//");  
       }  
   
     index = resource.indexOf("/../");  
     while (index != -1)  
       {  
         int last = resource.lastIndexOf('/', index-1);  
         if (last != -1)  
           resource = resource.substring(0, last+1)  
                   + resource.substring(index+4);  
         else  
           resource = resource.substring(index+4);  
         index = resource.indexOf("/../");  
       }  
   
     index = resource.indexOf("/./");  
     while (index != -1)  
       {  
         resource = resource.substring(0, index) + resource.substring(index+2);  
         index = resource.indexOf("/./");  
       }  
   
     return resource;  
   }  
   
   /**  
562     * Called whenever all locations of a named resource are needed.     * Called whenever all locations of a named resource are needed.
563     * It is called by <code>getResources()</code> after it has called     * It is called by <code>getResources()</code> after it has called
564     * <code>parent.getResources()</code>. The results are combined by     * <code>parent.getResources()</code>. The results are combined by

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26