001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.mail.filter;
019:
020: import org.columba.core.filter.FilterCriteria;
021: import org.columba.core.filter.IFilterCriteria;
022: import org.columba.core.xml.XmlElement;
023:
024: /**
025: * @author fdietz
026: *
027: */
028: public class MailFilterCriteria extends FilterCriteria {
029:
030: // header-item
031: private static final String HEADERFIELD = "headerfield";
032:
033: public final static int SUBJECT = 0;
034:
035: public final static int FROM = 1;
036:
037: public final static int TO = 2;
038:
039: public final static int CC = 3;
040:
041: public final static int BCC = 4;
042:
043: public final static int DATE = 5;
044:
045: public final static int SIZE = 6;
046:
047: public final static int BODY = 7;
048:
049: public final static int FLAGS = 8;
050:
051: public final static int PRIORITY = 9;
052:
053: public final static int CUSTOM_HEADERFIELD = 10;
054:
055: public final static int COLOR = 11;
056:
057: public final static int ACCOUNT = 12;
058:
059: private final String[] type = { "Subject", "From", "To", "Cc",
060: "Bcc", "Date", "Size", "Body", "Flags", "Priority",
061: "Custom Headerfield", "Color", "Account" };
062:
063: public MailFilterCriteria() {
064: super ();
065: }
066:
067: public MailFilterCriteria(IFilterCriteria c) {
068: super (c.getRoot());
069: }
070:
071: /**
072: * @param root
073: */
074: public MailFilterCriteria(XmlElement root) {
075: super (root);
076: }
077:
078: /**
079: * @see org.columba.core.filter.FilterCriteria#getType()
080: */
081: public int getType() {
082:
083: int result = -1;
084:
085: String h = getTypeString();
086:
087: for (int i = 0; i < type.length; i++) {
088: if (h.equals(type[i]))
089: result = i;
090: }
091:
092: return result;
093: }
094:
095: public void setType(int typeIndex) {
096: super .setTypeString(type[typeIndex]);
097: }
098:
099: public String getHeaderfieldString() {
100: return getRoot().getAttribute(MailFilterCriteria.HEADERFIELD);
101: }
102:
103: public void setHeaderfieldString(String s) {
104: getRoot().addAttribute(MailFilterCriteria.HEADERFIELD, s);
105: }
106:
107: }
|