/[classpath]/classpath/java/net/URLClassLoader.java
ViewVC logotype

Diff of /classpath/java/net/URLClassLoader.java

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

revision 1.21.2.3 by gnu_andrew, Sat Feb 19 10:50:38 2005 UTC revision 1.21.2.4 by gnu_andrew, Sun Mar 13 14:38:41 2005 UTC
# Line 536  public class URLClassLoader extends Secu Line 536  public class URLClassLoader extends Secu
536      Resource getResource(String name)      Resource getResource(String name)
537      {      {
538        File file = new File(dir, name);        File file = new File(dir, name);
539        if (file.exists() && ! file.isDirectory())        if (file.exists())
540          return new FileResource(this, name, file);          return new FileResource(this, name, file);
541        return null;        return null;
542      }      }
# Line 554  public class URLClassLoader extends Secu Line 554  public class URLClassLoader extends Secu
554    
555      InputStream getInputStream() throws IOException      InputStream getInputStream() throws IOException
556      {      {
557          // Delegate to the URL content handler mechanism to retrieve an
558          // HTML representation of the directory listing if a directory
559          if (file.isDirectory())
560            {
561              URL url = getURL();
562              return url.openStream();
563            }
564          // Otherwise simply return a FileInputStream
565        return new FileInputStream(file);        return new FileInputStream(file);
566      }      }
567    
568      public int getLength()      public int getLength()
569      {      {
570          // Delegate to the URL content handler mechanism to retrieve the
571          // length of the HTML representation of the directory listing if
572          // a directory, or -1 if an exception occurs opening the directory.
573          if (file.isDirectory())
574            {
575              URL url = getURL();
576              try
577                {
578                  URLConnection connection = url.openConnection();
579                  return connection.getContentLength();
580                }
581              catch (IOException e)
582                {
583                  return -1;
584                }
585            }
586          // Otherwise simply return the file length
587        return (int) file.length();        return (int) file.length();
588      }      }
589    
# Line 706  public class URLClassLoader extends Secu Line 731  public class URLClassLoader extends Secu
731          if (newUrl == null)          if (newUrl == null)
732            return; // Silently ignore...            return; // Silently ignore...
733    
734            // Reset the toString() value.
735            thisString = null;
736    
737          // Check global cache to see if there're already url loader          // Check global cache to see if there're already url loader
738          // for this url.          // for this url.
739          URLLoader loader = (URLLoader) urlloaders.get(newUrl);          URLLoader loader = (URLLoader) urlloaders.get(newUrl);
# Line 919  public class URLClassLoader extends Secu Line 947  public class URLClassLoader extends Secu
947     */     */
948    public String toString()    public String toString()
949    {    {
950      if (thisString == null)      synchronized (urlloaders)
951        {        {
952          StringBuffer sb = new StringBuffer();          if (thisString == null)
         sb.append(this.getClass().getName());  
         sb.append("{urls=[" );  
         URL[] thisURLs = getURLs();  
         for (int i = 0; i < thisURLs.length; i++)  
953            {            {
954              sb.append(thisURLs[i]);              StringBuffer sb = new StringBuffer();
955              if (i < thisURLs.length - 1)              sb.append(this.getClass().getName());
956                sb.append(',');              sb.append("{urls=[" );
957                URL[] thisURLs = getURLs();
958                for (int i = 0; i < thisURLs.length; i++)
959                  {
960                    sb.append(thisURLs[i]);
961                    if (i < thisURLs.length - 1)
962                      sb.append(',');
963                  }
964                sb.append(']');
965                sb.append(", parent=");
966                sb.append(getParent());
967                sb.append('}');
968                thisString = sb.toString();
969            }            }
970          sb.append(']');          return thisString;
         sb.append(", parent=");  
         sb.append(getParent());  
         sb.append('}');  
         thisString = sb.toString();  
971        }        }
     return thisString;  
972    }    }
973    
974    /**    /**

Legend:
Removed from v.1.21.2.3  
changed lines
  Added in v.1.21.2.4

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