You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ri...@apache.org on 2006/07/14 12:02:29 UTC
svn commit: r421852 [9/15] - in /geronimo/specs/trunk: ./
geronimo-spec-j2ee/ geronimo-spec-javamail-1.3.1/
geronimo-spec-javamail-1.3.1/src/ geronimo-spec-javamail-1.4/
geronimo-spec-javamail-1.4/src/ geronimo-spec-javamail-1.4/src/main/
geronimo-spec...
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/BodyTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/BodyTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/BodyTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/BodyTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import java.io.IOException;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Part;
+import javax.mail.Multipart;
+import javax.mail.BodyPart;
+
+/**
+ * Term that matches on a message body. All {@link javax.mail.BodyPart parts} that have
+ * a MIME type of "text/*" are searched.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class BodyTerm extends StringTerm {
+ public BodyTerm(String pattern) {
+ super(pattern);
+ }
+
+ public boolean match(Message message) {
+ try {
+ return matchPart(message);
+ } catch (IOException e) {
+ return false;
+ } catch (MessagingException e) {
+ return false;
+ }
+ }
+
+ private boolean matchPart(Part part) throws MessagingException, IOException {
+ if (part.isMimeType("multipart/*")) {
+ Multipart mp = (Multipart) part.getContent();
+ int count = mp.getCount();
+ for (int i=0; i < count; i++) {
+ BodyPart bp = mp.getBodyPart(i);
+ if (matchPart(bp)) {
+ return true;
+ }
+ }
+ return false;
+ } else if (part.isMimeType("text/*")) {
+ String content = (String) part.getContent();
+ return super.match(content);
+ } else {
+ return false;
+ }
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/BodyTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/BodyTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/BodyTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ComparisonTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ComparisonTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ComparisonTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ComparisonTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+/**
+ * Base for comparison terms.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ComparisonTerm extends SearchTerm {
+ public static final int LE = 1;
+ public static final int LT = 2;
+ public static final int EQ = 3;
+ public static final int NE = 4;
+ public static final int GT = 5;
+ public static final int GE = 6;
+
+ protected int comparison;
+
+ public ComparisonTerm() {
+ }
+
+ public boolean equals(Object other) {
+ return super.equals(other);
+ }
+
+ public int hashCode() {
+ return super.hashCode();
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ComparisonTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ComparisonTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ComparisonTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/DateTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/DateTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/DateTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/DateTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,73 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import java.util.Date;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class DateTerm extends ComparisonTerm {
+ protected Date date;
+
+ protected DateTerm(int comparison, Date date) {
+ super();
+ this.comparison = comparison;
+ this.date = date;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public int getComparison() {
+ return comparison;
+ }
+
+ protected boolean match(Date match) {
+ long matchTime = match.getTime();
+ long mytime = date.getTime();
+ switch (comparison) {
+ case EQ:
+ return matchTime == mytime;
+ case NE:
+ return matchTime != mytime;
+ case LE:
+ return matchTime <= mytime;
+ case LT:
+ return matchTime < mytime;
+ case GT:
+ return matchTime > mytime;
+ case GE:
+ return matchTime >= mytime;
+ default:
+ return false;
+ }
+ }
+
+ public boolean equals(Object other) {
+ if (other == this) return true;
+ if (other instanceof DateTerm == false) return false;
+ final DateTerm term = (DateTerm) other;
+ return this.comparison == term.comparison && this.date.equals(term.date);
+ }
+
+ public int hashCode() {
+ return date.hashCode();
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/DateTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/DateTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/DateTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FlagTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FlagTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FlagTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FlagTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,94 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import javax.mail.Flags;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+/**
+ * Term for matching message {@link Flags}.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class FlagTerm extends SearchTerm {
+ /**
+ * If true, test that all flags are set; if false, test that all flags are clear.
+ */
+ protected boolean set;
+ /**
+ * The flags to test.
+ */
+ protected Flags flags;
+
+ /**
+ * @param flags the flags to test
+ * @param set test for set or clear; {@link #set}
+ */
+ public FlagTerm(Flags flags, boolean set) {
+ this.set = set;
+ this.flags = flags;
+ }
+
+ public Flags getFlags() {
+ return flags;
+ }
+
+ public boolean getTestSet() {
+ return set;
+ }
+
+ public boolean match(Message message) {
+ try {
+ Flags msgFlags = message.getFlags();
+ if (set) {
+ return msgFlags.contains(flags);
+ } else {
+ // yuk - I wish we could get at the internal state of the Flags
+ Flags.Flag[] system = flags.getSystemFlags();
+ for (int i = 0; i < system.length; i++) {
+ Flags.Flag flag = system[i];
+ if (msgFlags.contains(flag)) {
+ return false;
+ }
+ }
+ String[] user = flags.getUserFlags();
+ for (int i = 0; i < user.length; i++) {
+ String flag = user[i];
+ if (msgFlags.contains(flag)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ } catch (MessagingException e) {
+ return false;
+ }
+ }
+
+ public boolean equals(Object other) {
+ if (other == this) return true;
+ if (other instanceof FlagTerm == false) return false;
+ final FlagTerm otherFlags = (FlagTerm) other;
+ return otherFlags.set == this.set && otherFlags.flags.equals(flags);
+ }
+
+ public int hashCode() {
+ return flags.hashCode();
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FlagTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FlagTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FlagTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromStringTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromStringTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromStringTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromStringTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import javax.mail.Address;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class FromStringTerm extends AddressStringTerm {
+ public FromStringTerm(String string) {
+ super(string);
+ }
+
+ public boolean match(Message message) {
+ try {
+ Address from[] = message.getFrom();
+ for (int i = 0; i < from.length; i++) {
+ if (match(from[i])){
+ return true;
+ }
+ }
+ return false;
+ } catch (MessagingException e) {
+ return false;
+ }
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromStringTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromStringTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromStringTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import javax.mail.Address;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class FromTerm extends AddressTerm {
+ public FromTerm(Address match) {
+ super(match);
+ }
+
+ public boolean match(Message message) {
+ try {
+ Address from[] = message.getFrom();
+ for (int i = 0; i < from.length; i++) {
+ if (match(from[i])) {
+ return true;
+ }
+ }
+ return false;
+ } catch (MessagingException e) {
+ return false;
+ }
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/FromTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/HeaderTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/HeaderTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/HeaderTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/HeaderTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class HeaderTerm extends StringTerm {
+ protected String headerName;
+
+ public HeaderTerm(String header, String pattern) {
+ super(pattern);
+ this.headerName = header;
+ }
+
+ public String getHeaderName() {
+ return headerName;
+ }
+
+ public boolean match(Message message) {
+ try {
+ String values[] = message.getHeader(headerName);
+ if (values != null) {
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+ if (match(value)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ } catch (MessagingException e) {
+ return false;
+ }
+ }
+
+ public boolean equals(Object other) {
+ if (other == this) return true;
+ if (other instanceof HeaderTerm == false) return false;
+ return headerName.equalsIgnoreCase(((HeaderTerm) other).headerName);
+ }
+
+ public int hashCode() {
+ return headerName.toLowerCase().hashCode();
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/HeaderTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/HeaderTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/HeaderTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/IntegerComparisonTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/IntegerComparisonTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/IntegerComparisonTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/IntegerComparisonTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,71 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+/**
+ * A Term that provides comparisons for integers.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class IntegerComparisonTerm extends ComparisonTerm {
+ protected int number;
+
+ protected IntegerComparisonTerm(int comparison, int number) {
+ super();
+ this.comparison = comparison;
+ this.number = number;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public int getComparison() {
+ return comparison;
+ }
+
+ protected boolean match(int match) {
+ switch (comparison) {
+ case EQ:
+ return match == number;
+ case NE:
+ return match != number;
+ case GT:
+ return match > number;
+ case GE:
+ return match >= number;
+ case LT:
+ return match < number;
+ case LE:
+ return match <= number;
+ default:
+ return false;
+ }
+ }
+
+ public boolean equals(Object other) {
+ if (other == this) return true;
+ if (other instanceof IntegerComparisonTerm == false) return false;
+ final IntegerComparisonTerm term = (IntegerComparisonTerm) other;
+ return this.comparison == term.comparison && this.number == term.number;
+ }
+
+ public int hashCode() {
+ return number;
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/IntegerComparisonTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/IntegerComparisonTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/IntegerComparisonTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageIDTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageIDTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageIDTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageIDTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class MessageIDTerm extends StringTerm {
+ public MessageIDTerm(String id) {
+ super(id);
+ }
+
+ public boolean match(Message message) {
+ try {
+ String values[] = message.getHeader("Message-ID");
+ if (values != null) {
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+ if (match(value)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ } catch (MessagingException e) {
+ return false;
+ }
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageIDTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageIDTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageIDTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageNumberTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageNumberTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageNumberTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageNumberTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import javax.mail.Message;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class MessageNumberTerm extends IntegerComparisonTerm {
+ public MessageNumberTerm(int number) {
+ super(EQ, number);
+ }
+
+ public boolean match(Message message) {
+ return match(message.getMessageNumber());
+ }
+
+ public boolean equals(Object other) {
+ return super.equals(other);
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageNumberTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageNumberTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/MessageNumberTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/NotTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/NotTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/NotTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/NotTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,51 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import javax.mail.Message;
+
+/**
+ * Term that implements a logical negation.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class NotTerm extends SearchTerm {
+ protected SearchTerm term;
+
+ public NotTerm(SearchTerm term) {
+ this.term = term;
+ }
+
+ public SearchTerm getTerm() {
+ return term;
+ }
+
+ public boolean match(Message message) {
+ return !term.match(message);
+ }
+
+ public boolean equals(Object other) {
+ if (other == this) return true;
+ if (other instanceof NotTerm == false) return false;
+ return term.equals(((NotTerm) other).term);
+ }
+
+ public int hashCode() {
+ return term.hashCode();
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/NotTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/NotTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/NotTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/OrTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/OrTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/OrTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/OrTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import java.util.Arrays;
+import javax.mail.Message;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class OrTerm extends SearchTerm {
+ protected SearchTerm[] terms;
+
+ public OrTerm(SearchTerm a, SearchTerm b) {
+ terms = new SearchTerm[]{a, b};
+ }
+
+ public OrTerm(SearchTerm[] terms) {
+ this.terms = terms;
+ }
+
+ public SearchTerm[] getTerms() {
+ return terms;
+ }
+
+ public boolean match(Message message) {
+ for (int i = 0; i < terms.length; i++) {
+ SearchTerm term = terms[i];
+ if (term.match(message)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean equals(Object other) {
+ if (other == this) return true;
+ if (other instanceof OrTerm == false) return false;
+ return Arrays.equals(terms, ((OrTerm) other).terms);
+ }
+
+ public int hashCode() {
+ int hash = 0;
+ for (int i = 0; i < terms.length; i++) {
+ hash = hash * 37 + terms[i].hashCode();
+ }
+ return hash;
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/OrTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/OrTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/OrTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ReceivedDateTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ReceivedDateTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ReceivedDateTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ReceivedDateTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import java.util.Date;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class ReceivedDateTerm extends DateTerm {
+ public ReceivedDateTerm(int comparison, Date date) {
+ super(comparison, date);
+ }
+
+ public boolean match(Message message) {
+ try {
+ return match(message.getReceivedDate());
+ } catch (MessagingException e) {
+ return false;
+ }
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ReceivedDateTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ReceivedDateTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/ReceivedDateTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientStringTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientStringTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientStringTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientStringTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,64 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import javax.mail.Address;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class RecipientStringTerm extends AddressStringTerm {
+ private Message.RecipientType type;
+
+ public RecipientStringTerm(Message.RecipientType type, String pattern) {
+ super(pattern);
+ this.type = type;
+ }
+
+ public Message.RecipientType getRecipientType() {
+ return type;
+ }
+
+ public boolean match(Message message) {
+ try {
+ Address from[] = message.getRecipients(type);
+ for (int i = 0; i < from.length; i++) {
+ Address address = from[i];
+ if (match(address)) {
+ return true;
+ }
+ }
+ return false;
+ } catch (MessagingException e) {
+ return false;
+ }
+ }
+
+ public boolean equals(Object other) {
+ if (other == this) return true;
+ if (other instanceof RecipientStringTerm == false) return false;
+ final RecipientStringTerm otherTerm = (RecipientStringTerm) other;
+ return this.pattern.equals(otherTerm.pattern) && this.type == otherTerm.type;
+ }
+
+ public int hashCode() {
+ return pattern.hashCode();
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientStringTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientStringTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientStringTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,65 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import javax.mail.Address;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class RecipientTerm extends AddressTerm {
+ protected Message.RecipientType type;
+
+ public RecipientTerm(Message.RecipientType type, Address address) {
+ super(address);
+ this.type = type;
+ }
+
+ public Message.RecipientType getRecipientType() {
+ return type;
+ }
+
+ public boolean match(Message message) {
+ try {
+ Address from[] = message.getRecipients(type);
+ for (int i = 0; i < from.length; i++) {
+ Address address = from[i];
+ if (match(address)) {
+ return true;
+ }
+ }
+ return false;
+ } catch (MessagingException e) {
+ return false;
+ }
+ }
+
+ public boolean equals(Object other) {
+ if (this == other) return true;
+ if (other instanceof RecipientTerm == false) return false;
+
+ final RecipientTerm recipientTerm = (RecipientTerm) other;
+ return address.equals(recipientTerm.address) && type == recipientTerm.type;
+ }
+
+ public int hashCode() {
+ return address.hashCode();
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/RecipientTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchException.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchException.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchException.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchException.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import javax.mail.MessagingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SearchException extends MessagingException {
+ public SearchException() {
+ super();
+ }
+
+ public SearchException(String message) {
+ super(message);
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchException.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import java.io.Serializable;
+import javax.mail.Message;
+
+/**
+ * Base class for Terms in a parse tree used to represent a search condition.
+ *
+ * This class is Serializable to allow for the short term persistence of
+ * searches between Sessions; this is not intended for long-term persistence.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class SearchTerm implements Serializable {
+ /**
+ * Checks a matching criteria defined by the concrete subclass of this Term.
+ *
+ * @param message the message to apply the matching criteria to
+ * @return true if the matching criteria is met
+ */
+ public abstract boolean match(Message message);
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SearchTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SentDateTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SentDateTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SentDateTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SentDateTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import java.util.Date;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class SentDateTerm extends DateTerm {
+ public SentDateTerm(int comparison, Date date) {
+ super(comparison, date);
+ }
+
+ public boolean match(Message message) {
+ try {
+ return match(message.getSentDate());
+ } catch (MessagingException e) {
+ return false;
+ }
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SentDateTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SentDateTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SentDateTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SizeTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SizeTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SizeTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SizeTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class SizeTerm extends IntegerComparisonTerm {
+ public SizeTerm(int comparison, int size) {
+ super(comparison, size);
+ }
+
+ public boolean match(Message message) {
+ try {
+ return match(message.getSize());
+ } catch (MessagingException e) {
+ return false;
+ }
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SizeTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SizeTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SizeTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/StringTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/StringTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/StringTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/StringTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,110 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+/**
+ * A Term that provides matching criteria for Strings.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class StringTerm extends SearchTerm {
+ /**
+ * If true, case should be ignored during matching.
+ */
+ protected boolean ignoreCase;
+
+ /**
+ * The pattern associated with this term.
+ */
+ protected String pattern;
+
+ /**
+ * Constructor specifying a pattern.
+ * Defaults to case insensitive matching.
+ * @param pattern the pattern for this term
+ */
+ protected StringTerm(String pattern) {
+ this(pattern, true);
+ }
+
+ /**
+ * Constructor specifying pattern and case sensitivity.
+ * @param pattern the pattern for this term
+ * @param ignoreCase if true, case should be ignored during matching
+ */
+ protected StringTerm(String pattern, boolean ignoreCase) {
+ this.pattern = pattern;
+ this.ignoreCase = ignoreCase;
+ }
+
+ /**
+ * Return the pattern associated with this term.
+ * @return the pattern associated with this term
+ */
+ public String getPattern() {
+ return pattern;
+ }
+
+ /**
+ * Indicate if case should be ignored when matching.
+ * @return if true, case should be ignored during matching
+ */
+ public boolean getIgnoreCase() {
+ return ignoreCase;
+ }
+
+ /**
+ * Determine if the pattern associated with this term is a substring of the
+ * supplied String. If ignoreCase is true then case will be ignored.
+ *
+ * @param match the String to compare to
+ * @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;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public boolean equals(Object other) {
+ return super.equals(other)
+ && ((StringTerm) other).pattern.equals(pattern)
+ && ((StringTerm) other).ignoreCase == ignoreCase;
+ }
+
+ public int hashCode() {
+ return super.hashCode() + pattern.hashCode() + (ignoreCase ? 32 : 79);
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/StringTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/StringTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/StringTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SubjectTerm.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SubjectTerm.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SubjectTerm.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SubjectTerm.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.search;
+
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class SubjectTerm extends StringTerm {
+ public SubjectTerm(String subject) {
+ super(subject);
+ }
+
+ public boolean match(Message message) {
+ try {
+ return match(message.getSubject());
+ } catch (MessagingException e) {
+ return false;
+ }
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SubjectTerm.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SubjectTerm.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/search/SubjectTerm.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/ByteArrayDataSource.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/ByteArrayDataSource.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/ByteArrayDataSource.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/ByteArrayDataSource.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,171 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.activation.DataSource;
+import javax.mail.internet.ContentType;
+import javax.mail.internet.ParseException;
+import javax.mail.internet.MimeUtility;
+
+
+/**
+ * An activation DataSource object that sources the data from
+ * a byte[] array.
+ * @version $Rev$ $Date$
+ */
+public class ByteArrayDataSource implements DataSource {
+ // the data source
+ private byte[] source;
+ // the content MIME type
+ private String contentType;
+ // the name information (defaults to a null string)
+ private String name = "";
+
+
+ /**
+ * Create a ByteArrayDataSource from an input stream.
+ *
+ * @param in The source input stream.
+ * @param type The MIME-type of the data.
+ *
+ * @exception IOException
+ */
+ public ByteArrayDataSource(InputStream in, String type) throws IOException {
+ ByteArrayOutputStream sink = new ByteArrayOutputStream();
+
+ // ok, how I wish you could just pipe an input stream into an output stream :-)
+ byte[] buffer = new byte[8192];
+ int bytesRead;
+
+ while ((bytesRead = in.read(buffer)) > 0) {
+ sink.write(buffer, 0, bytesRead);
+ }
+
+ source = sink.toByteArray();
+ contentType = type;
+ }
+
+
+ /**
+ * Create a ByteArrayDataSource directly from a byte array.
+ *
+ * @param data The source byte array (not copied).
+ * @param type The content MIME-type.
+ */
+ public ByteArrayDataSource(byte[] data, String type) {
+ source = data;
+ contentType = type;
+ }
+
+ /**
+ * Create a ByteArrayDataSource from a string value. If the
+ * type information includes a charset parameter, that charset
+ * is used to extract the bytes. Otherwise, the default Java
+ * char set is used.
+ *
+ * @param data The source data string.
+ * @param type The MIME type information.
+ *
+ * @exception IOException
+ */
+ public ByteArrayDataSource(String data, String type) throws IOException {
+ String charset = null;
+ try {
+ // the charset can be encoded in the content type, which we parse using
+ // the ContentType class.
+ ContentType content = new ContentType(type);
+ charset = content.getParameter("charset");
+ } catch (ParseException e) {
+ // ignored...just use the default if this fails
+ }
+ if (charset == null) {
+ charset = MimeUtility.getDefaultJavaCharset();
+ }
+ else {
+ // the type information encodes a MIME charset, which may need mapping to a Java one.
+ charset = MimeUtility.javaCharset(charset);
+ }
+
+ // get the source using the specified charset
+ source = data.getBytes(charset);
+ contentType = type;
+ }
+
+
+ /**
+ * Create an input stream for this data. A new input stream
+ * is created each time.
+ *
+ * @return An InputStream for reading the encapsulated data.
+ * @exception IOException
+ */
+ public InputStream getInputStream() throws IOException {
+ return new ByteArrayInputStream(source);
+ }
+
+
+ /**
+ * Open an output stream for the DataSource. This is not
+ * supported by this DataSource, so an IOException is always
+ * throws.
+ *
+ * @return Nothing...an IOException is always thrown.
+ * @exception IOException
+ */
+ public OutputStream getOutputStream() throws IOException {
+ throw new IOException("Writing to a ByteArrayDataSource is not supported");
+ }
+
+
+ /**
+ * Get the MIME content type information for this DataSource.
+ *
+ * @return The MIME content type string.
+ */
+ public String getContentType() {
+ return contentType;
+ }
+
+
+ /**
+ * Retrieve the DataSource name. If not explicitly set, this
+ * returns "".
+ *
+ * @return The currently set DataSource name.
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /**
+ * Set a new DataSource name.
+ *
+ * @param name The new name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
+
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/ByteArrayDataSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/ByteArrayDataSource.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/ByteArrayDataSource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/SharedByteArrayInputStream.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/SharedByteArrayInputStream.java?rev=421852&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/SharedByteArrayInputStream.java (added)
+++ geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/SharedByteArrayInputStream.java Fri Jul 14 03:02:19 2006
@@ -0,0 +1,91 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.mail.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.mail.internet.SharedInputStream;
+
+public class SharedByteArrayInputStream extends ByteArrayInputStream implements SharedInputStream {
+
+ /**
+ * Position within shared buffer that this stream starts at.
+ */
+ protected int start;
+
+ /**
+ * Create a SharedByteArrayInputStream that shares the entire
+ * buffer.
+ *
+ * @param buf The input data.
+ */
+ public SharedByteArrayInputStream(byte[] buf) {
+ this(buf, 0, buf.length);
+ }
+
+
+ /**
+ * Create a SharedByteArrayInputStream using a subset of the
+ * array data.
+ *
+ * @param buf The source data array.
+ * @param offset The starting offset within the array.
+ * @param length The length of data to use.
+ */
+ public SharedByteArrayInputStream(byte[] buf, int offset, int length) {
+ super(buf, offset, length);
+ start = offset;
+ }
+
+
+ /**
+ * Get the position within the output stream, adjusted by the
+ * starting offset.
+ *
+ * @return The adjusted position within the stream.
+ */
+ public long getPosition() {
+ return pos - start;
+ }
+
+
+ /**
+ * Create a new input stream from this input stream, accessing
+ * a subset of the data. Think of it as a substring operation
+ * for a stream.
+ *
+ * The starting offset must be non-negative. The end offset can
+ * by -1, which means use the remainder of the stream.
+ *
+ * @param offset The starting offset.
+ * @param end The end offset (which can be -1).
+ *
+ * @return An InputStream configured to access the indicated data subrange.
+ */
+ public InputStream newStream(long offset, long end) {
+ if (offset < 0) {
+ throw new IllegalArgumentException("Starting position must be non-negative");
+ }
+ if (end == -1) {
+ end = count - start;
+ }
+ return new SharedByteArrayInputStream(buf, start + (int)offset, (int)(end - offset));
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/SharedByteArrayInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/SharedByteArrayInputStream.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-spec-javamail-1.4/src/main/java/javax/mail/util/SharedByteArrayInputStream.java
------------------------------------------------------------------------------
svn:mime-type = text/plain