User: rinkrank
  Date: 02/05/28 14:30:18

  Modified:    core/src/xdoclet/util FileManager.java
  Log:
  Merged MODULE_REFACTORING_BRANCH back to MAIN
  
  Revision  Changes    Path
  1.11      +91 -109   xdoclet/core/src/xdoclet/util/FileManager.java
  
  Index: FileManager.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/util/FileManager.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -w -r1.10 -r1.11
  --- FileManager.java  9 Apr 2002 00:07:17 -0000       1.10
  +++ FileManager.java  28 May 2002 21:30:18 -0000      1.11
  @@ -4,35 +4,29 @@
    */
   package xdoclet.util;
   
  -import java.io.InputStream;
   import java.io.BufferedInputStream;
   import java.io.ByteArrayOutputStream;
  -import java.io.FileOutputStream;
  -import java.io.OutputStream;
  -import java.io.FileNotFoundException;
   import java.io.File;
  +import java.io.FileNotFoundException;
  +import java.io.FileOutputStream;
   import java.io.IOException;
  +import java.io.InputStream;
  +import java.io.OutputStream;
   import java.net.URL;
   import java.util.HashMap;
   import java.util.Map;
  -import xdoclet.XDocletException;
  -import org.apache.log4j.Category;
   
   /**
  - * A utility class for handling common filing operations. It also caches loaded
  - * files.
  + * A utility class for handling common filing operations. It also caches loaded 
files.
    *
    * @author    Ara Abrahamian ([EMAIL PROTECTED])
    * @created   Aug 5, 2001
  - * @version   $Revision: 1.10 $
  - * @todo      Deal with Translator.getString()'s exception better (throw it so
  - *      the build stops?) in getFileContent(String)
  + * @version   $Revision: 1.11 $
  + * @todo      Deal with Translator.getString()'s exception better (throw it so the 
build stops?) in
  + *      getFileContent(String)
    */
   public final class FileManager
   {
  -     /**
  -      * @todo-javadoc   Describe the field
  -      */
        private final static Map urlCache = new HashMap();
   
        /**
  @@ -40,27 +34,26 @@
         *
         * @param url      Describe what the parameter does
         * @return         The URLContent value
  -      * @todo-javadoc   Write javadocs for method parameter
         */
        public static synchronized String getURLContent( URL url )
        {
  +        if (url == null) {
  +            throw new IllegalArgumentException("url shouldn't be null!");
  +        }
  +
                String content = ( String ) urlCache.get( url );
   
  -             if( content != null )
  -             {
  +        if (content != null) {
                        return content;
                }
   
  -             try
  -             {
  +        try {
                        InputStream is = null;
   
  -                     if( "file".equals( url.getProtocol() ) )
  -                     {
  +            if ("file".equals(url.getProtocol())) {
                                is = new java.io.FileInputStream( url.getFile() );
                        }
  -                     else
  -                     {
  +            else {
                                is = url.openStream();
                        }
   
  @@ -73,12 +66,10 @@
   
                        return content;
                }
  -             catch( FileNotFoundException e )
  -             {
  +        catch (FileNotFoundException e) {
                        return null;
                }
  -             catch( Exception e )
  -             {
  +        catch (Exception e) {
                        e.printStackTrace();
                        System.err.println( Translator.getString( 
"exception_reading_merge_file", new String[]{e.toString()} ) );
                        return null;
  @@ -91,10 +82,6 @@
         * @param url              Describe what the parameter does
         * @param destination      Describe what the parameter does
         * @exception IOException  Describe the exception
  -      * @todo-javadoc           Write javadocs for method
  -      * @todo-javadoc           Write javadocs for method parameter
  -      * @todo-javadoc           Write javadocs for method parameter
  -      * @todo-javadoc           Write javadocs for exception
         */
        public static synchronized void writeURLContent( URL url, File destination ) 
throws IOException
        {
  @@ -111,10 +98,6 @@
         * @param is               Describe what the parameter does
         * @param os               Describe what the parameter does
         * @exception IOException  Describe the exception
  -      * @todo-javadoc           Write javadocs for method
  -      * @todo-javadoc           Write javadocs for method parameter
  -      * @todo-javadoc           Write javadocs for method parameter
  -      * @todo-javadoc           Write javadocs for exception
         */
        private static void pump( InputStream is, OutputStream os ) throws IOException
        {
  @@ -122,8 +105,7 @@
                byte[] b = new byte[is.available()];
                int len;
   
  -             while( is.available() > 0 && ( len = is.read( b ) ) != -1 )
  -             {
  +        while (is.available() > 0 && (len = is.read(b)) != -1) {
                        os.write( b, 0, len );
                }
        }
  
  
  

_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm

_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to