Example #1
0
		override protected bool MatchesQueryPart (QueryPart abstract_part)
		{
			if (abstract_part is QueryPart_Text) {
				QueryPart_Text part;
				part = (QueryPart_Text) abstract_part;

				if (part.SearchFullText)
					foreach (string str in body)
						if (part.Text == str)
							return true;
			}

			return false;
		}
Example #2
0
		//////////////////////////////////////////////////////////////

		//
		// Code to determine a a file will match a particular query
		//

		private bool MatchesQueryPart (QueryPart abstract_part)
		{
			bool is_match;
			is_match = false;

			if (abstract_part is QueryPart_Text) {
				QueryPart_Text part;
				part = abstract_part as QueryPart_Text;

				if ((part.SearchTextProperties && Name == part.Text)
				    || (part.SearchFullText && BodyContains (part.Text)))
					is_match = true;

			} else if (abstract_part is QueryPart_Or) {
				QueryPart_Or part;
				part = abstract_part as QueryPart_Or;

				foreach (QueryPart sub_part in part.SubParts) {
					if (MatchesQueryPart (sub_part)) {
						is_match = true;
						break;
					}
				}
			} else if (abstract_part is QueryPart_Property) {
				QueryPart_Property part;
				part = abstract_part as QueryPart_Property;

				if (part.Key == "beagle:MimeType") {
					if (part.Value == "inode/directory")
						is_match = IsDirectory;
					else if (part.Value == "text/plain")
						is_match = IsFile;
					else
						is_match = false;
				} else if (part.Key == "beagle:ExactFilename") {
					is_match = (Name == part.Value);
				} else {
					throw new Exception ("Unsupported property " + part.Key);
				}
			} else if (abstract_part is QueryPart_DateRange) {
				QueryPart_DateRange part;
				part = abstract_part as QueryPart_DateRange;

				// FIXME: We assume that the query refers to the file timestamp.
				// Instead, we should explicitly check part.Key.
				is_match = (part.StartDate <= Mtime && Mtime <= part.EndDate);

			} else {
				throw new Exception ("Unsupported part");
			}

			if (abstract_part.Logic == QueryPartLogic.Prohibited)
				is_match = ! is_match;

			return is_match;
		}
Example #3
0
 // FIXME: Really the only thing that is allowed as a subpart
 // of an 'Or' part are required (not prohibited) text or
 // property queries.  We should be clearer about the rules,
 // and enforce them.
 public void Add(QueryPart part)
 {
     sub_parts.Add(part);
 }
		// Returns:
		//   1 if it is a match
		//   0 if it doesn't apply
		//  -1 if it doesn't match
		private int MatchesMetadata (QueryPart abstract_part)
		{
			int is_match = 0;

			if (abstract_part is QueryPart_Text) {

				QueryPart_Text part;
				part = (QueryPart_Text) abstract_part;

				if (part.SearchTextProperties && part.Text == base_name)
					is_match = 1;
					
			} else if (abstract_part is QueryPart_Property) {

				QueryPart_Property part;
				part = (QueryPart_Property) abstract_part;

				if (part.Key == "beagle:MimeType") {
					is_match = (part.Value == this.MimeType) ? 1 : -1;
				} else if (part.Key == "beagle:Filename") {
					is_match = (part.Value == base_name) ? 1 : -1;
				} else if (part.Key == "beagle:ExactFilename") {
					is_match = (part.Value == Name) ? 1 : -1;
				}
					
			} else if (abstract_part is QueryPart_DateRange) {

				QueryPart_DateRange part;
				part = (QueryPart_DateRange) abstract_part;

				is_match = (part.StartDate <= Timestamp && Timestamp <= part.EndDate) ? 1 : -1;
			}

			return is_match;
		}
Example #5
0
		/////////////////////////////////////////////////////////////

		static public string QueryPartToString (QueryPart abstract_part)
		{
			string msg;
			msg = "????";
				
			if (abstract_part is QueryPart_Text) {
				QueryPart_Text part;
				part = (QueryPart_Text) abstract_part;
				
				msg = part.Text;
				if (! (part.SearchFullText && part.SearchTextProperties)) {
					if (part.SearchFullText)
						msg += " IN FULLTEXT";
					else if (part.SearchTextProperties)
						msg += " IN TEXT PROPERTIES";
				} else
					msg += " IN ANY TEXT";

			} else if (abstract_part is QueryPart_Property) {
				QueryPart_Property part;
				part = (QueryPart_Property) abstract_part;
				msg = String.Format ("PROPERTY {0} = {1}", part.Key, part.Value);
			} else if (abstract_part is QueryPart_DateRange) {
				QueryPart_DateRange part;
				part = (QueryPart_DateRange) abstract_part;
				msg = String.Format ("DATE RANGE {0} to {1}", part.StartDate, part.EndDate);
			}

			if (abstract_part.Logic == QueryPartLogic.Prohibited)
				msg = "NOT " + msg;

			
			return msg;
		}
		////////////////////////////////////////////////////

		abstract protected bool MatchesQueryPart (QueryPart part);
Example #7
0
		public void AddPart (QueryPart part)
		{
			if (part != null)
				parts.Add (part);
		}
		override protected bool MatchesQueryPart (QueryPart part)
		{
			// The only thing that could match is the name, and we check
			// for that already in FileSystemObject.MatchesQuery.
			return false;
		}
		///////////////////////////////////////////////////////////////////////

		// All of the query parts than can possibly match a directory are handled
		// in FileSystemObject.MatchesQuery.
		override protected bool MatchesQueryPart (QueryPart abstract_part)
		{
			return false;
		}
Example #10
0
		// FIXME: Really the only thing that is allowed as a subpart
		// of an 'Or' part are required (not prohibited) text or
		// property queries.  We should be clearer about the rules,
		// and enforce them.
		public void Add (QueryPart part)
		{
			sub_parts.Add (part);
		}