geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r593593 - /geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/
Date Fri, 09 Nov 2007 17:04:22 GMT
Author: rickmcguire
Date: Fri Nov  9 09:04:20 2007
New Revision: 593593

URL: http://svn.apache.org/viewvc?rev=593593&view=rev
Log:
GERONIMO-3594 Numerous problems in javamail SearchTerm impl.


Modified:
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/BodyTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/ComparisonTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/DateTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FlagTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FromStringTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FromTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/HeaderTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/IntegerComparisonTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/MessageIDTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/MessageNumberTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/ReceivedDateTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/RecipientStringTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/RecipientTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SentDateTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SizeTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/StringTerm.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SubjectTerm.java

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/BodyTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/BodyTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/BodyTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/BodyTerm.java
Fri Nov  9 09:04:20 2007
@@ -61,6 +61,9 @@
         } else if (part.isMimeType("text/*")) {
             String content = (String) part.getContent();
             return super.match(content);
+        } else if (part.isMimeType("message/rfc822")) {
+            // nested messages need recursion        
+            return matchPart((Part)part.getContent());
         } else {
             return false;
         }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/ComparisonTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/ComparisonTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/ComparisonTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/ComparisonTerm.java
Fri Nov  9 09:04:20 2007
@@ -38,10 +38,13 @@
     }
 
     public boolean equals(Object other) {
-        return super.equals(other);
+        if (!(other instanceof ComparisonTerm)) {
+            return false; 
+        }
+        return comparison == ((ComparisonTerm)other).comparison;
     }
 
     public int hashCode() {
-        return super.hashCode();
+        return comparison; 
     }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/DateTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/DateTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/DateTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/DateTerm.java
Fri Nov  9 09:04:20 2007
@@ -70,6 +70,6 @@
     }
 
     public int hashCode() {
-        return date.hashCode();
+        return date.hashCode() + super.hashCode();
     }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FlagTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FlagTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FlagTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FlagTerm.java
Fri Nov  9 09:04:20 2007
@@ -91,6 +91,6 @@
     }
 
     public int hashCode() {
-        return flags.hashCode();
+        return set ? flags.hashCode() : ~flags.hashCode();
     }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FromStringTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FromStringTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FromStringTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FromStringTerm.java
Fri Nov  9 09:04:20 2007
@@ -34,6 +34,10 @@
     public boolean match(Message message) {
         try {
             Address from[] = message.getFrom();
+            if (from == null) {
+                return false; 
+            }
+            
             for (int i = 0; i < from.length; i++) {
                 if (match(from[i])){
                     return true;

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FromTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FromTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FromTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/FromTerm.java
Fri Nov  9 09:04:20 2007
@@ -34,6 +34,9 @@
     public boolean match(Message message) {
         try {
             Address from[] = message.getFrom();
+            if (from == null) {
+                return false; 
+            }
             for (int i = 0; i < from.length; i++) {
                 if (match(from[i])) {
                     return true;

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/HeaderTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/HeaderTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/HeaderTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/HeaderTerm.java
Fri Nov  9 09:04:20 2007
@@ -57,10 +57,11 @@
     public boolean equals(Object other) {
         if (other == this) return true;
         if (other instanceof HeaderTerm == false) return false;
-        return headerName.equalsIgnoreCase(((HeaderTerm) other).headerName);
+        // we need to compare with more than just the header name. 
+        return headerName.equalsIgnoreCase(((HeaderTerm) other).headerName) && super.equals(other);
     }
 
     public int hashCode() {
-        return headerName.toLowerCase().hashCode();
+        return headerName.toLowerCase().hashCode() + super.hashCode();
     }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/IntegerComparisonTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/IntegerComparisonTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/IntegerComparisonTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/IntegerComparisonTerm.java
Fri Nov  9 09:04:20 2007
@@ -68,6 +68,6 @@
     }
 
     public int hashCode() {
-        return number;
+        return number + super.hashCode();
     }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/MessageIDTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/MessageIDTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/MessageIDTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/MessageIDTerm.java
Fri Nov  9 09:04:20 2007
@@ -46,4 +46,11 @@
             return false;
         }
     }
+    
+    public boolean equals(Object other) {
+        if (!(other instanceof MessageIDTerm)) {
+            return false; 
+        }
+        return super.equals(other); 
+    }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/MessageNumberTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/MessageNumberTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/MessageNumberTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/MessageNumberTerm.java
Fri Nov  9 09:04:20 2007
@@ -34,6 +34,9 @@
     }
 
     public boolean equals(Object other) {
+        if (!(other instanceof MessageNumberTerm)) {
+            return false; 
+        }
         return super.equals(other);
     }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/ReceivedDateTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/ReceivedDateTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/ReceivedDateTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/ReceivedDateTerm.java
Fri Nov  9 09:04:20 2007
@@ -33,9 +33,21 @@
 
     public boolean match(Message message) {
         try {
-            return match(message.getReceivedDate());
+            Date date = message.getReceivedDate();
+            if (date == null) {
+                return false; 
+            }
+            
+            return match(date);
         } catch (MessagingException e) {
             return false;
         }
+    }
+    
+    
+    public boolean equals(Object other) {
+        if (other == this) return true;
+        if (other instanceof ReceivedDateTerm == false) return false;
+        return super.equals(other); 
     }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/RecipientStringTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/RecipientStringTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/RecipientStringTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/RecipientStringTerm.java
Fri Nov  9 09:04:20 2007
@@ -41,6 +41,9 @@
     public boolean match(Message message) {
         try {
             Address from[] = message.getRecipients(type);
+            if (from == null) {
+                return false; 
+            }
             for (int i = 0; i < from.length; i++) {
                 Address address = from[i];
                 if (match(address)) {
@@ -61,6 +64,6 @@
     }
 
     public int hashCode() {
-        return pattern.hashCode();
+        return pattern.hashCode() + type.hashCode();
     }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/RecipientTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/RecipientTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/RecipientTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/RecipientTerm.java
Fri Nov  9 09:04:20 2007
@@ -41,6 +41,9 @@
     public boolean match(Message message) {
         try {
             Address from[] = message.getRecipients(type);
+            if (from == null) {
+                return false; 
+            }
             for (int i = 0; i < from.length; i++) {
                 Address address = from[i];
                 if (match(address)) {
@@ -62,6 +65,6 @@
     }
 
     public int hashCode() {
-        return address.hashCode();
+        return address.hashCode() + type.hashCode();
     }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SentDateTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SentDateTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SentDateTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SentDateTerm.java
Fri Nov  9 09:04:20 2007
@@ -33,9 +33,20 @@
 
     public boolean match(Message message) {
         try {
+            Date date = message.getSentDate(); 
+            if (date == null) {
+                return false; 
+            }
+            
             return match(message.getSentDate());
         } catch (MessagingException e) {
             return false;
         }
+    }
+
+    public boolean equals(Object other) {
+        if (this == other) return true;
+        if (other instanceof SentDateTerm == false) return false;
+        return super.equals(other);
     }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SizeTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SizeTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SizeTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SizeTerm.java
Fri Nov  9 09:04:20 2007
@@ -37,4 +37,10 @@
             return false;
         }
     }
+
+    public boolean equals(Object other) {
+        if (this == other) return true;
+        if (other instanceof SizeTerm == false) return false;
+        return super.equals(other);
+    }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/StringTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/StringTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/StringTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/StringTerm.java
Fri Nov  9 09:04:20 2007
@@ -78,35 +78,32 @@
      * @return true if this patter is a substring of the supplied String
      */
     protected boolean match(String match) {
-        match: for (int length = match.length() - pattern.length(); length > 0; length--)
{
-            for (int i = 0; i < pattern.length(); i++) {
-                char c1 = match.charAt(length + i);
-                char c2 = match.charAt(i);
-                if (c1 == c2) {
-                    continue;
-                }
-                if (ignoreCase) {
-                    if (Character.toLowerCase(c1) == Character.toLowerCase(c2)) {
-                        continue;
-                    }
-                    if (Character.toUpperCase(c1) == Character.toUpperCase(c2)) {
-                        continue;
-                    }
-                }
-                continue match;
+        int matchLength = pattern.length(); 
+        int length = match.length() - matchLength;        
+        
+        for (int i = 0; i <= length; i++) {
+            if (match.regionMatches(ignoreCase, i, pattern, 0, matchLength)) {
+                return true; 
             }
-            return true;
         }
         return false;
     }
 
     public boolean equals(Object other) {
-        return super.equals(other)
-                && ((StringTerm) other).pattern.equals(pattern)
-                && ((StringTerm) other).ignoreCase == ignoreCase;
+        if (this == other) return true;
+        if (other instanceof StringTerm == false) return false;
+        
+        StringTerm term = (StringTerm)other; 
+        
+        if (ignoreCase) {
+            return term.pattern.equalsIgnoreCase(pattern) && term.ignoreCase == ignoreCase;

+        }
+        else {
+            return term.pattern.equals(pattern) && term.ignoreCase == ignoreCase;

+        }
     }
 
     public int hashCode() {
-        return super.hashCode() + pattern.hashCode() + (ignoreCase ? 32 : 79);
+        return pattern.hashCode() + (ignoreCase ? 32 : 79);
     }
 }

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SubjectTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SubjectTerm.java?rev=593593&r1=593592&r2=593593&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SubjectTerm.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/search/SubjectTerm.java
Fri Nov  9 09:04:20 2007
@@ -32,9 +32,19 @@
 
     public boolean match(Message message) {
         try {
-            return match(message.getSubject());
+            String subject = message.getSubject(); 
+            if (subject == null) {
+                return false; 
+            }
+            return match(subject);
         } catch (MessagingException e) {
             return false;
         }
+    }
+
+    public boolean equals(Object other) {
+        if (this == other) return true;
+        if (other instanceof SubjectTerm == false) return false;
+        return super.equals(other); 
     }
 }



Mime
View raw message