/[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.18 by mark, Sat Oct 26 18:41:59 2002 UTC revision 1.19 by mark, Sun Oct 27 01:17:56 2002 UTC
# Line 515  public abstract class ClassLoader Line 515  public abstract class ClassLoader
515     */     */
516    public URL getResource(String name)    public URL getResource(String name)
517    {    {
518        name = normalize(name);
519      URL result;      URL result;
520    
521      if (parent == null)      if (parent == null)
# Line 549  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    {    {
553        name = normalize(name);
554      Enumeration parentResources;      Enumeration parentResources;
555      if (parent == null)      if (parent == null)
556        parentResources = VMClassLoader.getResources(name);        parentResources = VMClassLoader.getResources(name);
# Line 558  public abstract class ClassLoader Line 560  public abstract class ClassLoader
560    }    }
561    
562    /**    /**
563       * Normalizes a resource path name. This removes all ./ from the start and
564       * all further '//', "/../" and "/./" from the given name.
565       */
566      private static String normalize(String resource)
567      {
568        while (resource.startsWith("./"))
569          resource = resource.substring(2);
570    
571        int index = resource.indexOf("//");
572        while (index != -1)
573          {
574            resource = resource.substring(0, index) + resource.substring(index+1);
575            index = resource.indexOf("//");
576          }
577    
578        index = resource.indexOf("/../");
579        while (index != -1)
580          {
581            int last = resource.lastIndexOf('/', index-1);
582            if (last != -1)
583              resource = resource.substring(0, last+1)
584                      + resource.substring(index+4);
585            else
586              resource = resource.substring(index+4);
587            index = resource.indexOf("/../");
588          }
589    
590        index = resource.indexOf("/./");
591        while (index != -1)
592          {
593            resource = resource.substring(0, index) + resource.substring(index+2);
594            index = resource.indexOf("/./");
595          }
596    
597        return resource;
598      }
599    
600      /**
601     * Called whenever all locations of a named resource are needed.     * Called whenever all locations of a named resource are needed.
602     * It is called by <code>getResources()</code> after it has called     * It is called by <code>getResources()</code> after it has called
603     * <code>parent.getResources()</code>. The results are combined by     * <code>parent.getResources()</code>. The results are combined by

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

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