james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pgoldst...@apache.org
Subject cvs commit: jakarta-james/src/java/org/apache/mailet MailAddress.java GenericMatcher.java GenericMailet.java
Date Wed, 07 Aug 2002 23:21:33 GMT
pgoldstein    2002/08/07 16:21:33

  Modified:    src/java/org/apache/mailet MailAddress.java
                        GenericMatcher.java GenericMailet.java
  Log:
  Part of the String=>StringBuffer changes.  Includes some additional
  commenting, formatting fixes, and wrapping of logging calls in log
  level checks.  Also converted equalsIgnoreCase paradigm as discussed on
  mailing list.  Locale issue for both toUpperCase() and toLowerCase() was
  addressed as well.
  
  Revision  Changes    Path
  1.7       +15 -6     jakarta-james/src/java/org/apache/mailet/MailAddress.java
  
  Index: MailAddress.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/mailet/MailAddress.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MailAddress.java	30 Jul 2002 10:46:50 -0000	1.6
  +++ MailAddress.java	7 Aug 2002 23:21:33 -0000	1.7
  @@ -7,6 +7,7 @@
    */
   package org.apache.mailet;
   
  +import java.util.Locale;
   import javax.mail.internet.InternetAddress;
   import javax.mail.internet.ParseException;
   
  @@ -177,7 +178,12 @@
       }
   
       public String toString() {
  -        return user + "@" + host;
  +        StringBuffer addressBuffer = 
  +            new StringBuffer(128)
  +                    .append(user)
  +                    .append("@")
  +                    .append(host);
  +        return addressBuffer.toString();
       }
   
       public InternetAddress toInternetAddress() {
  @@ -193,7 +199,8 @@
           if (obj == null) {
               return false;
           } else if (obj instanceof String) {
  -            return toString().equalsIgnoreCase(obj.toString());
  +            String theString = (String)obj;
  +            return toString().equalsIgnoreCase(theString);
           } else if (obj instanceof MailAddress) {
               MailAddress addr = (MailAddress)obj;
               return getUser().equalsIgnoreCase(addr.getUser()) && getHost().equalsIgnoreCase(addr.getHost());
  @@ -211,7 +218,7 @@
        * @return the hashcode.
        */
       public int hashCode() {
  -        return toString().toLowerCase().hashCode();
  +        return toString().toLowerCase(Locale.US).hashCode();
       }
   
       private String parseQuotedLocalPart(String address) throws ParseException {
  @@ -412,9 +419,11 @@
                   break;
               }
               char ch = address.charAt(pos);
  -            if (ch >= '0' && ch <= '9' || ch >= 'a' && ch <=
'z' || ch >= 'A' && ch <= 'Z'
  -                || ch == '-') {
  -                resultSB.append(ch + "");
  +            if ((ch >= '0' && ch <= '9') || 
  +                (ch >= 'a' && ch <= 'z') || 
  +                (ch >= 'A' && ch <= 'Z') ||
  +                (ch == '-')) {
  +                resultSB.append(ch);
                   pos++;
                   continue;
               }
  
  
  
  1.3       +12 -2     jakarta-james/src/java/org/apache/mailet/GenericMatcher.java
  
  Index: GenericMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/mailet/GenericMatcher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GenericMatcher.java	18 Jan 2002 02:48:40 -0000	1.2
  +++ GenericMatcher.java	7 Aug 2002 23:21:33 -0000	1.3
  @@ -126,7 +126,12 @@
        * @param msg - a String specifying the message to be written to the log file
        */
       public void log(String message) {
  -        getMailetContext().log(getMatcherName() + ": " + message);
  +        StringBuffer logBuffer = 
  +            new StringBuffer(256)
  +                    .append(getMatcherName())
  +                    .append(": ")
  +                    .append(message);
  +        getMailetContext().log(logBuffer.toString());
       }
   
       /**
  @@ -137,7 +142,12 @@
        * @param t - the java.lang.Throwable error or exception
        */
       public void log(String message, Throwable t) {
  -        getMailetContext().log(getMatcherName() + ": " + message, t);
  +        StringBuffer logBuffer = 
  +            new StringBuffer(256)
  +                    .append(getMatcherName())
  +                    .append(": ")
  +                    .append(message);
  +        getMailetContext().log(logBuffer.toString(), t);
       }
   
       /**
  
  
  
  1.3       +12 -2     jakarta-james/src/java/org/apache/mailet/GenericMailet.java
  
  Index: GenericMailet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/mailet/GenericMailet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GenericMailet.java	18 Jan 2002 02:48:40 -0000	1.2
  +++ GenericMailet.java	7 Aug 2002 23:21:33 -0000	1.3
  @@ -145,7 +145,12 @@
        * @param msg - a String specifying the message to be written to the log file
        */
       public void log(String message) {
  -        getMailetContext().log(config.getMailetName() + ": " + message);
  +        StringBuffer logBuffer =
  +            new StringBuffer(256)
  +                    .append(getMailetName())
  +                    .append(": ")
  +                    .append(message);
  +        getMailetContext().log(logBuffer.toString());
       }
   
       /**
  @@ -156,7 +161,12 @@
        * @param t - the java.lang.Throwable error or exception
        */
       public void log(String message, Throwable t) {
  -        getMailetContext().log(config.getMailetName() + ": " + message, t);
  +        StringBuffer logBuffer =
  +            new StringBuffer(256)
  +                    .append(config.getMailetName())
  +                    .append(": ")
  +                    .append(message);
  +        getMailetContext().log(logBuffer.toString(), t);
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:james-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:james-dev-help@jakarta.apache.org>


Mime
View raw message