KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > ipanema > person > util > PersonSearchFilterItem


1 /*
2  * Created on Dec 14, 2004
3  * by alex
4  *
5  */

6 package com.nightlabs.ipanema.person.util;
7 import java.util.ArrayList JavaDoc;
8 import java.util.List JavaDoc;
9
10 import com.nightlabs.ipanema.person.id.PersonStructFieldID;
11 import com.nightlabs.jdo.search.SearchFilterItem;
12
13
14 /**
15  * Representation of a {@link com.nightlabs.jdo.search.SearchFilterItem} for persons.
16  * <br/>
17  * Implements {@link com.nightlabs.jdo.search.SearchFilterItem#getSearchField()} and returns
18  * the property personStructFieldID of this filter item.
19  * <br/>
20  * Subclasses have to return an inheritor of {@link com.nightlabs.ipanema.person.AbstractPersonDataField}
21  * for {@link com.nightlabs.jdo.search.SearchFilterItem#getItemTargetClass()} in order to
22  * can be used by PersonSearchFilterItem.
23  * <br/>
24  *
25  *
26  * @author Alexander Bieber <alex[AT]nightlabs[DOT]de>
27  */

28 public abstract class PersonSearchFilterItem extends SearchFilterItem {
29     
30     /**
31      * @param matchType
32      * @param needle
33      */

34     protected PersonSearchFilterItem(PersonStructFieldID personStructFieldID, int matchType, String JavaDoc needle) {
35         super(matchType, needle);
36         this.personStructFieldIDs.clear();
37         this.personStructFieldIDs.add(personStructFieldID);
38     }
39     
40     /**
41      * @param matchType
42      * @param needle
43      */

44     protected PersonSearchFilterItem(PersonStructFieldID[] personStructFieldIDs, int matchType, String JavaDoc needle) {
45         super(matchType, needle);
46         if (personStructFieldIDs.length == 0)
47             throw new IllegalArgumentException JavaDoc("At least one PersonStructFieldID has to be defined in the given array.");
48         this.personStructFieldIDs.clear();
49         for (int i = 0; i < personStructFieldIDs.length; i++) {
50             this.personStructFieldIDs.add(personStructFieldIDs[i]);
51         }
52     }
53
54     protected PersonSearchFilterItem(int matchType, String JavaDoc needle) {
55         super(matchType, needle);
56     }
57     
58     public static final String JavaDoc QUERY_DATAFIELD_VARNAME = "personDataField";
59     
60 // protected PersonStructFieldID personStructFieldID;
61

62     protected List JavaDoc personStructFieldIDs = new ArrayList JavaDoc();
63     
64     public PersonStructFieldID getPersonStructFieldID() {
65         return (PersonStructFieldID)personStructFieldIDs.get(0);
66     }
67     
68     public List JavaDoc getPersonStructFieldIDs() {
69         return personStructFieldIDs;
70     }
71     
72     /**
73      * Default implementation returns {@link #getPersonStructFieldID()}.
74      * @see com.nightlabs.jdo.search.SearchFilterItem#getSearchField()
75      */

76     public Object JavaDoc getSearchField() {
77         throw new UnsupportedOperationException JavaDoc("Do not use getSearchField for PersonSearchFilterItem. Use getPersonStructFieldIDs instead.");
78     }
79 }
80
Popular Tags