4 // Copyright (C) 2005 Novell, Inc.
8 // Permission is hereby granted, free of charge, to any person obtaining a
9 // copy of this software and associated documentation files (the "Software"),
10 // to deal in the Software without restriction, including without limitation
11 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 // and/or sell copies of the Software, and to permit persons to whom the
13 // Software is furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 // DEALINGS IN THE SOFTWARE.
30 using System
.Collections
;
31 using System
.Xml
.Serialization
;
33 using BU
= Beagle
.Util
;
37 public enum QueryPartLogic
{
42 [XmlInclude (typeof (QueryPart_Text
)),
43 XmlInclude (typeof (QueryPart_Property
)),
44 XmlInclude (typeof (QueryPart_DateRange
)),
45 XmlInclude (typeof (QueryPart_Human
)),
46 XmlInclude (typeof (QueryPart_Or
))]
47 abstract public class QueryPart
{
49 private QueryPartLogic logic
= QueryPartLogic
.Required
;
54 public QueryPartLogic Logic
{
56 set { logic = value; }
60 public class QueryPart_Text
: QueryPart
{
63 private bool search_full_text
= true;
64 private bool search_properties
= true;
66 public QueryPart_Text ()
74 public bool SearchFullText
{
75 get { return search_full_text; }
76 set { search_full_text = value; }
79 public bool SearchTextProperties
{
80 get { return search_properties; }
81 set { search_properties = value; }
85 // AllProperties queries are not allowed on keywords.
86 public class QueryPart_Property
: QueryPart
{
88 public const string AllProperties
= "_all";
90 private PropertyType type
;
94 public QueryPart_Property ()
97 public PropertyType Type
{
107 public string Value
{
108 get { return value; }
109 set { this.value = value; }
// ugh
113 public class QueryPart_DateRange
: QueryPart
{
115 public const string AllProperties
= "_all";
117 private string key
= AllProperties
;
118 private DateTime start_date
;
119 private DateTime end_date
;
121 public QueryPart_DateRange ()
129 public DateTime StartDate
{
130 get { return start_date; }
131 set { start_date = value; }
134 public DateTime EndDate
{
135 get { return end_date; }
136 set { end_date = value; }
140 public class QueryPart_Human
: QueryPart
{
142 private string query_string
;
144 public QueryPart_Human ()
147 public string QueryString
{
148 get { return query_string; }
149 set { query_string = value; }
153 public class QueryPart_Or
: QueryPart
{
155 private ArrayList sub_parts
= new ArrayList ();
157 public QueryPart_Or ()
160 [XmlArray ("SubParts")]
161 [XmlArrayItem (ElementName
="SubPart", Type
=typeof (QueryPart
))]
162 public ArrayList SubParts_ShouldBePrivateSoPleaseDontUseThis
{
163 get { return sub_parts; }
167 public ICollection SubParts
{
168 get { return sub_parts; }
171 // FIXME: Really the only thing that is allowed as a subpart
172 // of an 'Or' part are required (not prohibited) text or
173 // property queries. We should be clearer about the rules,
175 public void Add (QueryPart part
)
177 sub_parts
.Add (part
);