pgoldstein    2002/08/16 14:06:32

  Modified:    src/java/org/apache/james/util
                        CharTerminatedInputStream.java
                        DebugInputStream.java ExtraDotOutputStream.java
                        InternetPrintWriter.java JDBCUtil.java Lock.java
                        RFC2980DateFormat.java RFC822Date.java
                        RFC822DateFormat.java RFC977DateFormat.java
                        SchedulerNotifyInputStream.java
                        SchedulerNotifyOutputStream.java
                        SimplifiedDateFormat.java SqlResources.java
                        SynchronizedDateFormat.java
               src/java/org/apache/james/util/mordred JdbcDataSource.java
                        PoolConnEntry.java
  Added:       src/java/org/apache/james/util package.html
  Log:
  Added extensive comments.
  Replaced tabs with spaces.
  
  Revision  Changes    Path
  1.2       +50 -0     
jakarta-james/src/java/org/apache/james/util/CharTerminatedInputStream.java
  
  Index: CharTerminatedInputStream.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/CharTerminatedInputStream.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CharTerminatedInputStream.java    11 May 2001 09:52:29 -0000      1.1
  +++ CharTerminatedInputStream.java    16 Aug 2002 21:06:32 -0000      1.2
  @@ -11,19 +11,58 @@
   import java.io.InputStream;
   
   /**
  + * An InputStream class that terminates the stream when it encounters a
  + * particular byte sequence.
  + *
    * @version 1.0.0, 24/04/1999
    * @author  Federico Barbieri <[EMAIL PROTECTED]>
    */
   public class CharTerminatedInputStream
       extends InputStream {
   
  +    /**
  +     * The wrapped input stream
  +     */
       private InputStream in;
  +
  +    /**
  +     * The terminating character array
  +     */
       private int match[];
  +
  +    /**
  +     * An array containing the last N characters read from the stream, where
  +     * N is the length of the terminating character array
  +     */
       private int buffer[];
  +
  +    /**
  +     * The number of bytes that have been read that have not been placed
  +     * in the internal buffer.
  +     */
       private int pos = 0;
  +
  +    /**
  +     * Whether the terminating sequence has been read from the stream
  +     */
       private boolean endFound = false;
   
  +    /**
  +     * A constructor for this object that takes a stream to be wrapped
  +     * and a terminating character sequence.
  +     *
  +     * @param in the <code>InputStream</code> to be wrapped
  +     * @param terminator the array of characters that will terminate the stream.
  +     *
  +     * @throws IllegalArgumentException if the terminator array is null or empty
  +     */
       public CharTerminatedInputStream(InputStream in, char[] terminator) {
  +        if (terminator == null) {
  +            throw new IllegalArgumentException("The terminating character array 
cannot be null.");
  +        }
  +        if (terminator.length == 0) {
  +            throw new IllegalArgumentException("The terminating character array 
cannot be of zero length.");
  +        }
           match = new int[terminator.length];
           buffer = new int[terminator.length];
           for (int i = 0; i < terminator.length; i++) {
  @@ -33,6 +72,12 @@
           this.in = in;
       }
   
  +    /**
  +     * Read a byte off this stream.
  +     *
  +     * @return the byte read off the stream
  +     * @throws IOException if an IOException is encountered while reading off the 
stream
  +     */
       public int read() throws IOException {
           if (endFound) {
               //We've found the match to the terminator
  @@ -90,6 +135,11 @@
           return -1;
       }
   
  +    /**
  +     * Private helper method to update the internal buffer of last read characters
  +     *
  +     * @return the byte that was previously at the front of the internal buffer
  +     */
       private int topChar() {
           int b = buffer[0];
           if (pos > 1) {
  
  
  
  1.4       +26 -3     
jakarta-james/src/java/org/apache/james/util/DebugInputStream.java
  
  Index: DebugInputStream.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/DebugInputStream.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DebugInputStream.java     18 Jan 2002 02:48:39 -0000      1.3
  +++ DebugInputStream.java     16 Aug 2002 21:06:32 -0000      1.4
  @@ -10,19 +10,42 @@
   import java.io.IOException;
   import java.io.InputStream;
   
  +/**
  + * Reads data off a stream, printing every byte read to System.err.
  + */
   public class DebugInputStream extends InputStream {
  +
  +    /**
  +     * The input stream being wrapped
  +     */
       InputStream in = null;
   
  +    /**
  +     * Constructor that takes an InputStream to be wrapped.
  +     *
  +     * @param in the InputStream to be wrapped
  +     */
       public DebugInputStream(InputStream in) {
           this.in = in;
       }
   
  -     public int read() throws IOException {
  +    /**
  +     * Read a byte off the stream
  +     *
  +     * @return the byte read off the stream
  +     * @throws IOException if an exception is encountered when reading
  +     */
  +    public int read() throws IOException {
           int b = in.read();
  -         System.err.write(b);
  +        System.err.write(b);
           return b;
  -     }
  +    }
   
  +    /**
  +     * Close the stream
  +     *
  +     * @throws IOException if an exception is encountered when closing
  +     */
       public void close() throws IOException {
           in.close();
       }
  
  
  
  1.2       +12 -0     
jakarta-james/src/java/org/apache/james/util/ExtraDotOutputStream.java
  
  Index: ExtraDotOutputStream.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/ExtraDotOutputStream.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExtraDotOutputStream.java 27 Feb 2002 04:47:41 -0000      1.1
  +++ ExtraDotOutputStream.java 16 Aug 2002 21:06:32 -0000      1.2
  @@ -24,11 +24,23 @@
        */
       protected int countLast0A0D;
   
  +    /**
  +     * Constructor that wraps an OutputStream.
  +     *
  +     * @param out the OutputStream to be wrapped
  +     */
       public ExtraDotOutputStream(OutputStream out) {
           super(out);
           countLast0A0D = 2; // we already assume a CRLF at beginning (otherwise TOP 
would not work correctly !)
       }
   
  +    /**
  +     * Writes a byte to the stream, adding dots where appropriate.
  +     *
  +     * @param b the byte to write
  +     *
  +     * @throws IOException if an error occurs writing the byte
  +     */
       public void write(int b) throws IOException {
           out.write(b);
           if (b == '.') {
  
  
  
  1.2       +79 -0     
jakarta-james/src/java/org/apache/james/util/InternetPrintWriter.java
  
  Index: InternetPrintWriter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/InternetPrintWriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InternetPrintWriter.java  11 May 2001 09:52:30 -0000      1.1
  +++ InternetPrintWriter.java  16 Aug 2002 21:06:32 -0000      1.2
  @@ -11,32 +11,71 @@
   import java.io.PrintWriter;
   import java.io.Writer;
   
  +/**
  + * Writes to a wrapped Writer class, ensuring that all line separators are '\r\n', 
regardless
  + * of platform.
  + */
   public class InternetPrintWriter
       extends PrintWriter {
   
  +/**
  + * The line separator to use.
  + */
       private static String lineSeparator = "\r\n";
   
  +/**
  + * Constructor that takes a writer to wrap.
  + *
  + * @param out the wrapped Writer
  + */
       public InternetPrintWriter (Writer out) {
           super (out);
       }
   
  +// TODO: This class handles autoflush incorrectly
  +
  +/**
  + * Constructor that takes a writer to wrap.
  + *
  + * @param out the wrapped Writer
  + * @param autoFlush whether to flush after each print call
  + */
       public InternetPrintWriter (Writer out, boolean autoFlush) {
           super (out, autoFlush);
       }
   
  +/**
  + * Constructor that takes a stream to wrap.
  + *
  + * @param out the wrapped OutputStream
  + */
       public InternetPrintWriter (OutputStream out) {
           super (out);
       }
   
  +/**
  + * Constructor that takes a stream to wrap.
  + *
  + * @param out the wrapped OutputStream
  + * @param autoFlush whether to flush after each print call
  + */
       public InternetPrintWriter (OutputStream out, boolean autoFlush) {
           super (out, autoFlush);
       }
   
  +/**
  + * Print a line separator.
  + */
       public void println () {
           print (lineSeparator);
           super.flush();
       }
   
  +/**
  + * Print a boolean followed by a line separator.
  + *
  + * @param x the boolean to print
  + */
       public void println(boolean x) {
           synchronized (lock) {
               print(x);
  @@ -44,6 +83,11 @@
           }
       }
   
  +/**
  + * Print a char followed by a line separator.
  + *
  + * @param x the char to print
  + */
       public void println(char x) {
           synchronized (lock) {
               print (x);
  @@ -51,6 +95,11 @@
           }
       }
   
  +/**
  + * Print a int followed by a line separator.
  + *
  + * @param x the int to print
  + */
       public void println (int x) {
           synchronized (lock) {
               print (x);
  @@ -58,6 +107,11 @@
           }
       }
   
  +/**
  + * Print a long followed by a line separator.
  + *
  + * @param x the long to print
  + */
       public void println (long x) {
           synchronized (lock) {
               print (x);
  @@ -65,6 +119,11 @@
           }
       }
   
  +/**
  + * Print a float followed by a line separator.
  + *
  + * @param x the float to print
  + */
       public void println (float x) {
           synchronized (lock) {
               print (x);
  @@ -72,6 +131,11 @@
           }
       }
   
  +/**
  + * Print a double followed by a line separator.
  + *
  + * @param x the double to print
  + */
       public void println (double x) {
           synchronized (lock) {
               print (x);
  @@ -79,6 +143,11 @@
           }
       }
   
  +/**
  + * Print a character array followed by a line separator.
  + *
  + * @param x the character array to print
  + */
       public void println (char[] x) {
           synchronized (lock) {
               print (x);
  @@ -86,6 +155,11 @@
           }
       }
   
  +/**
  + * Print a String followed by a line separator.
  + *
  + * @param x the String to print
  + */
       public void println (String x) {
           synchronized (lock) {
               print (x);
  @@ -93,6 +167,11 @@
           }
       }
   
  +/**
  + * Print an Object followed by a line separator.
  + *
  + * @param x the Object to print
  + */
       public void println (Object x) {
           synchronized (lock) {
               print (x);
  
  
  
  1.2       +11 -5     jakarta-james/src/java/org/apache/james/util/JDBCUtil.java
  
  Index: JDBCUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/util/JDBCUtil.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JDBCUtil.java     12 Aug 2002 07:41:36 -0000      1.1
  +++ JDBCUtil.java     16 Aug 2002 21:06:32 -0000      1.2
  @@ -11,11 +11,11 @@
   import java.util.Locale;
   
   /**
  - * Helper class for managing common JDBC tasks.
  + * <p>Helper class for managing common JDBC tasks.</p>
    *
  - * This class is abstract to allow implementations to 
  + * <p>This class is abstract to allow implementations to 
    * take advantage of different logging capabilities/interfaces in
  - * different parts of the code.
  + * different parts of the code.</p>
    *
    * @author Noel Bergman <[EMAIL PROTECTED]>
    * @author Peter M. Goldstein <[EMAIL PROTECTED]>
  @@ -23,6 +23,12 @@
    */
   abstract public class JDBCUtil
   {
  +    /**
  +     * An abstract method which child classes override to handle logging of
  +     * errors in their particular environments.
  +     *
  +     * @param errorString the error message generated
  +     */
       abstract protected void delegatedLog(String errorString);
   
       /**
  @@ -32,7 +38,7 @@
        * @param dbMetaData the database metadata to be used to look up this table
        * @param tableName the table name
        *
  -     * @exception SQLException thrown if an exception is encountered while 
accessing the database
  +     * @throws SQLException if an exception is encountered while accessing the 
database
        */
       public boolean tableExists(DatabaseMetaData dbMetaData, String tableName)
           throws SQLException {
  @@ -48,7 +54,7 @@
        * @param dbMetaData the database metadata to be used to look up this table
        * @param tableName the case sensitive table name
        *
  -     * @exception SQLException thrown if an exception is encountered while 
accessing the database
  +     * @throws SQLException if an exception is encountered while accessing the 
database
        */
       public boolean tableExistsCaseSensitive(DatabaseMetaData dbMetaData, String 
tableName)
           throws SQLException {
  
  
  
  1.3       +34 -0     jakarta-james/src/java/org/apache/james/util/Lock.java
  
  Index: Lock.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/util/Lock.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Lock.java 6 Aug 2001 04:15:16 -0000       1.2
  +++ Lock.java 16 Aug 2002 21:06:32 -0000      1.3
  @@ -10,15 +10,32 @@
   import java.util.Hashtable;
   
   /**
  + * Provides Lock functionality
  + *
    * @author Federico Barbieri <[EMAIL PROTECTED]>
    */
   public class Lock {
  +    /**
  +     * An internal hash table of keys to locks
  +     */
       private Hashtable locks = new Hashtable();
   
  +    /**
  +     * Check to see if the object is locked
  +     *
  +     * @param key the Object on which to check the lock
  +     * @return true if the object is locked, false otherwise
  +     */
       public boolean isLocked(final Object key) {
           return (locks.get(key) != null);
       }
   
  +    /**
  +     * Check to see if we can lock on a given object.
  +     *
  +     * @param key the Object on which to lock
  +     * @return true if the calling thread can lock, false otherwise
  +     */
       public boolean canI(final Object key) {
           Object o = locks.get( key );
   
  @@ -29,6 +46,12 @@
           return false;
       }
   
  +    /**
  +     * Lock on a given object.
  +     *
  +     * @param key the Object on which to lock
  +     * @return true if the locking was successful, false otherwise
  +     */
       public boolean lock(final Object key) {
           Object theLock;
   
  @@ -46,6 +69,12 @@
           }
       }
   
  +    /**
  +     * Release the lock on a given object.
  +     *
  +     * @param key the Object on which the lock is held
  +     * @return true if the unlocking was successful, false otherwise
  +     */
       public boolean unlock(final Object key) {
           Object theLock;
           synchronized (this) {
  @@ -62,6 +91,11 @@
           }
       }
   
  +    /**
  +     * Private helper method to abstract away caller ID.
  +     *
  +     * @return the id of the caller (i.e. the Thread reference)
  +     */
       private Object getCallerId() {
           return Thread.currentThread();
       }
  
  
  
  1.2       +3 -0      
jakarta-james/src/java/org/apache/james/util/RFC2980DateFormat.java
  
  Index: RFC2980DateFormat.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/RFC2980DateFormat.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RFC2980DateFormat.java    28 Jul 2002 11:46:40 -0000      1.1
  +++ RFC2980DateFormat.java    16 Aug 2002 21:06:32 -0000      1.2
  @@ -17,6 +17,9 @@
    */
   public class RFC2980DateFormat extends SynchronizedDateFormat {
   
  +    /**
  +     * Constructor for RFC2980DateFormat
  +     */
       public RFC2980DateFormat() {
           super("yyyyMMddHHmmss", Locale.ENGLISH);
       }
  
  
  
  1.5       +73 -73    jakarta-james/src/java/org/apache/james/util/RFC822Date.java
  
  Index: RFC822Date.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/util/RFC822Date.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RFC822Date.java   28 Jul 2002 11:46:40 -0000      1.4
  +++ RFC822Date.java   16 Aug 2002 21:06:32 -0000      1.5
  @@ -39,99 +39,99 @@
           df = new SimpleDateFormat("EE, d MMM yyyy HH:mm:ss", Locale.US);
           dx = new SimpleDateFormat("EE, d MMM yyyy HH:mm:ss zzzzz", Locale.US);
           dy = new SimpleDateFormat("EE d MMM yyyy HH:mm:ss zzzzz", Locale.US);
  -             dz = new SimpleDateFormat("d MMM yyyy HH:mm:ss zzzzz", Locale.US);
  -       }   
  +        dz = new SimpleDateFormat("d MMM yyyy HH:mm:ss zzzzz", Locale.US);
  +      }   
      
      /**
  -     * creates a current timestamp 
  -     * using this machines system timezone<br>
  -     * 
  -     */
  +    * creates a current timestamp 
  +    * using this machines system timezone<br>
  +    * 
  +    */
       public RFC822Date(){
  -     d = new Date();
  +        d = new Date();
       }
       
      /**
  -     * creates object using date supplied 
  -     * and this machines system timezone<br>
  -     * @param da java.util.Date, A date object
  -     */
  +    * creates object using date supplied 
  +    * and this machines system timezone<br>
  +    * @param da java.util.Date, A date object
  +    */
       public RFC822Date(Date da) {
  -     d = da;
  +        d = da;
       }
       
      /**
  -     * creates object using date supplied 
  -     * and the timezone string supplied<br>
  -     * useTZ can be either an abbreviation such as "PST",
  -     * a full name such as "America/Los_Angeles",<br> 
  -     * or a custom ID such as "GMT-8:00".<br>
  -     * Note that this is dependant on java.util.TimeZone<br>
  -     * Note that the support of abbreviations is for 
  -     * JDK 1.1.x compatibility only and full names should be used.<br>
  -     * @param da java.util.Date, a date object
  -     * @param useTZ java.lang.Sting, a timezone string such as 
"America/Los_Angeles" or "GMT+02:00"
  -     */
  +    * creates object using date supplied 
  +    * and the timezone string supplied<br>
  +    * useTZ can be either an abbreviation such as "PST",
  +    * a full name such as "America/Los_Angeles",<br> 
  +    * or a custom ID such as "GMT-8:00".<br>
  +    * Note that this is dependant on java.util.TimeZone<br>
  +    * Note that the support of abbreviations is for 
  +    * JDK 1.1.x compatibility only and full names should be used.<br>
  +    * @param da java.util.Date, a date object
  +    * @param useTZ java.lang.Sting, a timezone string such as "America/Los_Angeles" 
or "GMT+02:00"
  +    */
       public RFC822Date(Date da, String useTZ){
  -     d = da;
  +        d = da;
       }
   
  -     /**
  -     * creates object from 
  -     * RFC822 date string supplied 
  -     * and the system default time zone <br>
  -     * In practice it converts RFC822 date string to the local timezone<br>
  -     * @param rfcdate java.lang.String - date in RFC822 format "3 Oct 2001 08:32:44 
-0000"
  -     */
  -     public RFC822Date(String rfcdate) {
  -             setDate(rfcdate);
  -     }
  -     /**
  -     * creates object from 
  -     * RFC822 date string supplied 
  -     * using the supplied time zone string<br>
  -     * @param rfcdate java.lang.String - date in RFC822 format
  -     * @param useTZ java.lang.String - timezone string *doesn't support Z style or 
UT*
  -     */      
  -     public RFC822Date(String rfcdate, String useTZ)  {
  -             setDate(rfcdate);
  -             setTimeZone(useTZ);
  -     }       
  +    /**
  +    * creates object from 
  +    * RFC822 date string supplied 
  +    * and the system default time zone <br>
  +    * In practice it converts RFC822 date string to the local timezone<br>
  +    * @param rfcdate java.lang.String - date in RFC822 format "3 Oct 2001 08:32:44 
-0000"
  +    */
  +    public RFC822Date(String rfcdate) {
  +        setDate(rfcdate);
  +    }
  +    /**
  +    * creates object from 
  +    * RFC822 date string supplied 
  +    * using the supplied time zone string<br>
  +    * @param rfcdate java.lang.String - date in RFC822 format
  +    * @param useTZ java.lang.String - timezone string *doesn't support Z style or 
UT*
  +    */  
  +    public RFC822Date(String rfcdate, String useTZ)  {
  +        setDate(rfcdate);
  +        setTimeZone(useTZ);
  +    }   
   
       public void setDate(Date da){
  -     d = da;
  +        d = da;
       }
       
    /**
    * The following styles of rfc date strings can be parsed<br>
  - *   Wed, 3 Oct 2001 06:42:27 GMT+02:10<br>
  - *   Wed 3 Oct 2001 06:42:27 PST <br>
  - *   3 October 2001 06:42:27 +0100  <br>  
  + *  Wed, 3 Oct 2001 06:42:27 GMT+02:10<br>
  + *  Wed 3 Oct 2001 06:42:27 PST <br>
  + *  3 October 2001 06:42:27 +0100  <br>  
    * the military style timezones, ZM, ZA, etc cannot (yet) <br>
    * @param rfcdate java.lang.String - date in RFC822 format
    */
       public void setDate(String rfcdate)  {
  -             try {
  -                     synchronized (dx) {
  -                         d= dx.parse(rfcdate);
  -                     }
  -             } catch(ParseException e) {
  -                     try {
  -                             synchronized (dz) {
  -                                     d= dz.parse(rfcdate);
  -                             }
  -                     } catch(ParseException f) {
  -                             try {
  -                                     synchronized (dy) {
  -                                             d = dy.parse(rfcdate);
  -                                     }
  -                             } catch(ParseException g) {
  -                                     d = new Date();
  -                             }
  -                     }
  -                     
  -             }
  -     
  +        try {
  +            synchronized (dx) {
  +                d= dx.parse(rfcdate);
  +            }
  +        } catch(ParseException e) {
  +            try {
  +                synchronized (dz) {
  +                    d= dz.parse(rfcdate);
  +                }
  +            } catch(ParseException f) {
  +                try {
  +                    synchronized (dy) {
  +                        d = dy.parse(rfcdate);
  +                    }
  +                } catch(ParseException g) {
  +                    d = new Date();
  +                }
  +            }
  +            
  +        }
  +        
       }
    
       public void setTimeZone(TimeZone useTZ) {
  @@ -139,16 +139,16 @@
       }
       
       public void setTimeZone(String useTZ) {
  -     setTimeZone(TimeZone.getTimeZone(useTZ));
  +        setTimeZone(TimeZone.getTimeZone(useTZ));
       }
       
   
  -     /**
  +    /**
        * returns the java.util.Date object this RFC822Date represents.
        * @return java.util.Date - the java.util.Date object this RFC822Date 
represents.
        */
       public Date getDate() {
  -     return d;
  +        return d;
       }
   
       /**
  
  
  
  1.5       +6 -0      
jakarta-james/src/java/org/apache/james/util/RFC822DateFormat.java
  
  Index: RFC822DateFormat.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/RFC822DateFormat.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RFC822DateFormat.java     28 Jul 2002 11:46:40 -0000      1.4
  +++ RFC822DateFormat.java     16 Aug 2002 21:06:32 -0000      1.5
  @@ -17,6 +17,9 @@
    * @author Peter M. Goldstein <[EMAIL PROTECTED]>
    */
   public class RFC822DateFormat extends SynchronizedDateFormat {
  +    /**
  +     * A static instance of the RFC822DateFormat, used by toString
  +     */
       private static RFC822DateFormat instance; 
   
       static {
  @@ -39,6 +42,9 @@
           return instance.format(d);
       }
   
  +    /**
  +     * Constructor for RFC822DateFormat
  +     */
       public RFC822DateFormat() {
           super(new MailDateFormat());
       }
  
  
  
  1.2       +13 -2     
jakarta-james/src/java/org/apache/james/util/RFC977DateFormat.java
  
  Index: RFC977DateFormat.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/RFC977DateFormat.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RFC977DateFormat.java     28 Jul 2002 11:46:40 -0000      1.1
  +++ RFC977DateFormat.java     16 Aug 2002 21:06:32 -0000      1.2
  @@ -21,9 +21,20 @@
    * @author Peter M. Goldstein <[EMAIL PROTECTED]>
    */
   public class RFC977DateFormat implements SimplifiedDateFormat {
  +
  +    /**
  +     * Internal date formatter for long date formats
  +     */
       private final SynchronizedDateFormat internalLongDateFormat;
  +
  +    /**
  +     * Internal date formatter for short date formats
  +     */
       private final SynchronizedDateFormat internalShortDateFormat;
   
  +    /**
  +     * Constructor for RFC977DateFormat
  +     */
       public RFC977DateFormat() {
           internalLongDateFormat = new SynchronizedDateFormat("yyyyMMdd HHmmss", 
Locale.ENGLISH);
           internalShortDateFormat = new SynchronizedDateFormat("yyMMdd HHmmss", 
Locale.ENGLISH);
  @@ -48,8 +59,8 @@
        *
        * @param source A <code>String</code> whose beginning should be parsed.
        * @return A <code>Date</code> parsed from the string.
  -     * @exception ParseException if the beginning of the specified string
  -     *            cannot be parsed.
  +     * @throws ParseException if the beginning of the specified string
  +     *         cannot be parsed.
        */
       public Date parse(String source) throws ParseException {
           source = source.trim();
  
  
  
  1.3       +38 -0     
jakarta-james/src/java/org/apache/james/util/SchedulerNotifyInputStream.java
  
  Index: SchedulerNotifyInputStream.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/SchedulerNotifyInputStream.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SchedulerNotifyInputStream.java   18 Jan 2002 02:48:39 -0000      1.2
  +++ SchedulerNotifyInputStream.java   16 Aug 2002 21:06:32 -0000      1.3
  @@ -19,11 +19,27 @@
    * not timing out during large data transfers.
    */
   public class SchedulerNotifyInputStream extends InputStream {
  +
  +    /**
  +     * The wrapped InputStream
  +     */
       InputStream in = null;
  +
       TimeScheduler scheduler = null;
  +
  +    /**
  +     * The name of the trigger
  +     */
       String triggerName = null;
  +
  +    /**
  +     * The number of bytes that need to be read before the counter is reset.
  +     */
       int lengthReset = 0;
   
  +    /**
  +     * The number of bytes read since the counter was last reset
  +     */
       int readCounter = 0;
   
       public SchedulerNotifyInputStream(InputStream in,
  @@ -36,6 +52,17 @@
           readCounter = 0;
       }
   
  +    /**
  +     * Read an array of bytes from the stream
  +     *
  +     * @param b the array of bytes to read from the stream
  +     * @param off the index in the array where we start writing
  +     * @param len the number of bytes of the array to read
  +     *
  +     * @return the number of bytes read
  +     *
  +     * @throws IOException if an exception is encountered when reading
  +     */
       public int read(byte[] b, int off, int len) throws IOException {
           int l = in.read(b, off, len);
           readCounter += l;
  @@ -48,6 +75,12 @@
           return l;
       }
   
  +    /**
  +     * Read a byte from the stream
  +     *
  +     * @return the byte read from the stream
  +     * @throws IOException if an exception is encountered when reading
  +     */
       public int read() throws IOException {
           int b = in.read();
           readCounter++;
  @@ -60,6 +93,11 @@
           return b;
       }
   
  +    /**
  +     * Close the stream
  +     *
  +     * @throws IOException if an exception is encountered when closing
  +     */
       public void close() throws IOException {
           in.close();
       }
  
  
  
  1.4       +45 -0     
jakarta-james/src/java/org/apache/james/util/SchedulerNotifyOutputStream.java
  
  Index: SchedulerNotifyOutputStream.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/SchedulerNotifyOutputStream.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SchedulerNotifyOutputStream.java  18 Jan 2002 02:48:39 -0000      1.3
  +++ SchedulerNotifyOutputStream.java  16 Aug 2002 21:06:32 -0000      1.4
  @@ -19,11 +19,30 @@
    * not timing out during large data transfers.
    */
   public class SchedulerNotifyOutputStream extends OutputStream {
  +
  +    /**
  +     * The output stream wrapped by this method
  +     */
       OutputStream out = null;
  +
  +    /**
  +     * The scheduler used by this class to timeout
  +     */
       TimeScheduler scheduler = null;
  +
  +    /**
  +     * The name of the trigger
  +     */
       String triggerName = null;
  +
  +    /**
  +     * The number of bytes that need to be written before the counter is reset.
  +     */
       int lengthReset = 0;
   
  +    /**
  +     * The number of bytes written since the counter was last reset
  +     */
       int writtenCounter = 0;
   
       public SchedulerNotifyOutputStream(OutputStream out,
  @@ -36,6 +55,15 @@
           writtenCounter = 0;
       }
   
  +    /**
  +     * Write an array of bytes to the stream
  +     *
  +     * @param b the array of bytes to write to the stream
  +     * @param off the index in the array where we start writing
  +     * @param len the number of bytes of the array to write
  +     *
  +     * @throws IOException if an exception is encountered when writing
  +     */
       public void write(byte[] b, int off, int len) throws IOException {
           out.write(b, off, len);
           writtenCounter += len;
  @@ -46,6 +74,13 @@
           }
       }
   
  +    /**
  +     * Write a byte to the stream
  +     *
  +     * @param b the byte to write to the stream
  +     *
  +     * @throws IOException if an exception is encountered when writing
  +     */
       public void write(int b) throws IOException {
           out.write(b);
           writtenCounter++;
  @@ -56,10 +91,20 @@
           }
       }
   
  +    /**
  +     * Flush the stream
  +     *
  +     * @throws IOException if an exception is encountered when flushing
  +     */
       public void flush() throws IOException {
           out.flush();
       }
   
  +    /**
  +     * Close the stream
  +     *
  +     * @throws IOException if an exception is encountered when closing
  +     */
       public void close() throws IOException {
           out.close();
       }
  
  
  
  1.2       +6 -6      
jakarta-james/src/java/org/apache/james/util/SimplifiedDateFormat.java
  
  Index: SimplifiedDateFormat.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/SimplifiedDateFormat.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimplifiedDateFormat.java 28 Jul 2002 11:46:40 -0000      1.1
  +++ SimplifiedDateFormat.java 16 Aug 2002 21:06:32 -0000      1.2
  @@ -13,14 +13,14 @@
   import java.util.TimeZone;
   
   /**
  - * This interface is designed to provide a simplified subset of the
  - * methods provided by the <code>java.text.DateFormat</code> class.
  + * <p>This interface is designed to provide a simplified subset of the
  + * methods provided by the <code>java.text.DateFormat</code> class.</p>
    *
  - * This interface is necessary because of the difficulty in writing
  + * <p>This interface is necessary because of the difficulty in writing
    * thread safe classes that inherit from <code>java.text.DateFormat</code>.
    * This difficulty leads us to approach the problem using composition
    * rather than inheritance.  In general classes that implement this
  - * interface will delegate these calls to an internal DateFormat object.
  + * interface will delegate these calls to an internal DateFormat object.</p>
    *    
    * @author Peter M. Goldstein <[EMAIL PROTECTED]>
    */
  @@ -39,8 +39,8 @@
        *
        * @param source A <code>String</code> whose beginning should be parsed.
        * @return A <code>Date</code> parsed from the string.
  -     * @exception ParseException if the beginning of the specified string
  -     *            cannot be parsed.
  +     * @throws ParseException if the beginning of the specified string
  +     *         cannot be parsed.
        */
       public Date parse(String source) throws ParseException;
   
  
  
  
  1.4       +17 -5     jakarta-james/src/java/org/apache/james/util/SqlResources.java
  
  Index: SqlResources.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/util/SqlResources.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SqlResources.java 7 Aug 2002 23:23:37 -0000       1.3
  +++ SqlResources.java 16 Aug 2002 21:06:32 -0000      1.4
  @@ -33,6 +33,16 @@
   public class SqlResources
   {
       /**
  +     * A map of statement types to SQL statements
  +     */
  +    private Map m_sql = new HashMap();
  +
  +    /**
  +     * A Perl5 regexp matching helper class
  +     */
  +    private Perl5Util m_perl5Util = new Perl5Util();
  +
  +    /**
        * Configures a DbResources object to provide SQL statements from a file.
        * 
        * SQL statements returned may be specific to the particular type
  @@ -174,6 +184,11 @@
        * connected to. This value is then used to choose the specific SQL 
        * expressions to use.
        *
  +     * @param conn the JDBC connection being tested
  +     * @param dbMatchersElement the XML element containing the database type 
information
  +     *
  +     * @return the type of database to which James is connected
  +     *
        */
       private String matchDbConnection(Connection conn, 
                                        Element dbMatchersElement)
  @@ -250,8 +265,8 @@
        * @param name     the name of the SQL resource required.
        * @param required true if the resource is required
        * @return the requested resource
  -     * @exception ConfigurationException
  -     *                   if a required resource cannot be found.
  +     * @throws ConfigurationException
  +     *         if a required resource cannot be found.
        */
       public String getSqlString(String name, boolean required)
       {
  @@ -267,7 +282,4 @@
           }
           return sql;
       }
  -
  -    private Map m_sql = new HashMap();
  -    private Perl5Util m_perl5Util = new Perl5Util();
   }
  
  
  
  1.2       +17 -2     
jakarta-james/src/java/org/apache/james/util/SynchronizedDateFormat.java
  
  Index: SynchronizedDateFormat.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/SynchronizedDateFormat.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SynchronizedDateFormat.java       28 Jul 2002 11:46:40 -0000      1.1
  +++ SynchronizedDateFormat.java       16 Aug 2002 21:06:32 -0000      1.2
  @@ -26,10 +26,25 @@
   public class SynchronizedDateFormat implements SimplifiedDateFormat {
       private final DateFormat internalDateFormat;
   
  +    /**
  +     * Public constructor that mimics that of SimpleDateFormat.  See
  +     * java.text.SimpleDateFormat for more details.
  +     *
  +     * @param pattern the pattern that defines this DateFormat
  +     * @param locale the locale
  +     */
       public SynchronizedDateFormat(String pattern, Locale locale) {
           internalDateFormat = new SimpleDateFormat(pattern, locale);
       }
   
  +    /**
  +     * <p>Wrapper method to allow child classes to synchronize a preexisting
  +     * DateFormat.</p>
  +     *
  +     * <p>TODO: Investigate replacing this with a factory method.</p>
  +     *
  +     * @param the DateFormat to synchronize
  +     */
       protected SynchronizedDateFormat(DateFormat theDateFormat) {
           internalDateFormat = theDateFormat;
       }
  @@ -57,8 +72,8 @@
        *
        * @param source A <code>String</code> whose beginning should be parsed.
        * @return A <code>Date</code> parsed from the string.
  -     * @exception ParseException if the beginning of the specified string
  -     *            cannot be parsed.
  +     * @throws ParseException if the beginning of the specified string
  +     *         cannot be parsed.
        */
       public Date parse(String source) throws ParseException {
           synchronized (internalDateFormat) {
  
  
  
  1.1                  jakarta-james/src/java/org/apache/james/util/package.html
  
  Index: package.html
  ===================================================================
  <body>
  <p>A variety of utility classes used inside James.</p>
  </body>
  
  
  
  1.13      +5 -2      
jakarta-james/src/java/org/apache/james/util/mordred/JdbcDataSource.java
  
  Index: JdbcDataSource.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/mordred/JdbcDataSource.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- JdbcDataSource.java       12 Aug 2002 07:41:36 -0000      1.12
  +++ JdbcDataSource.java       16 Aug 2002 21:06:32 -0000      1.13
  @@ -272,7 +272,10 @@
       }
   
       /**
  -     * Need to clean up all connections
  +     * The dispose operation is called at the end of a components lifecycle.
  +     * Cleans up all JDBC connections.
  +     *
  +     * @throws Exception if an error is encountered during shutdown
        */
       public void dispose() {
           // Stop the background monitoring thread
  
  
  
  1.6       +10 -3     
jakarta-james/src/java/org/apache/james/util/mordred/PoolConnEntry.java
  
  Index: PoolConnEntry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/util/mordred/PoolConnEntry.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PoolConnEntry.java        7 Aug 2002 23:22:33 -0000       1.5
  +++ PoolConnEntry.java        16 Aug 2002 21:06:32 -0000      1.6
  @@ -13,8 +13,8 @@
   import java.util.Map;
   
   /**
  - * Insert the type's description here.
  - * Creation date: (8/24/99 11:41:10 AM)
  + * An entry in a connection pool.
  + *
    * @author Serge Knystautas <[EMAIL PROTECTED]>
    */
   public class PoolConnEntry implements java.sql.Connection{
  @@ -23,7 +23,9 @@
       // States for connections (in use, being tested, or active)
       public final static int     AVAILABLE = 0;
       public final static int     ACTIVE = 1;
  +
       private JdbcDataSource      container;
  +
       private Connection          connection;
       private int                 status;
       private long                lockTime;
  @@ -124,7 +126,7 @@
       /**
        * Insert the method's description here.
        * Creation date: (8/24/99 11:43:19 AM)
  -     * @return long
  +     * @return a long representing the time this entry was created
        */
       public long getCreateDate() {
           return createDate;
  @@ -222,6 +224,11 @@
           container.releaseConnection(this);
       }
   
  +    /**
  +     * Returns whether this entry is closed.
  +     *
  +     * @return whether the underlying conntection is closed
  +     */
       public boolean isClosed() throws SQLException {
           return connection.isClosed();
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to