final move of files
[web.mtrack] / Zend / Search / Lucene / Search / Query / Empty.php
1 <?php
2 /**
3  * Zend Framework
4  *
5  * LICENSE
6  *
7  * This source file is subject to the new BSD license that is bundled
8  * with this package in the file LICENSE.txt.
9  * It is also available through the world-wide-web at this URL:
10  * http://framework.zend.com/license/new-bsd
11  * If you did not receive a copy of the license and are unable to
12  * obtain it through the world-wide-web, please send an email
13  * to license@zend.com so we can send you a copy immediately.
14  *
15  * @category   Zend
16  * @package    Zend_Search_Lucene
17  * @subpackage Search
18  * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
20  * @version    $Id: Empty.php 16971 2009-07-22 18:05:45Z mikaelkael $
21  */
22
23
24 /** Zend_Search_Lucene_Search_Query */
25 require_once 'Zend/Search/Lucene/Search/Query.php';
26
27 /** Zend_Search_Lucene_Search_Weight_Empty */
28 require_once 'Zend/Search/Lucene/Search/Weight/Empty.php';
29
30
31 /**
32  * @category   Zend
33  * @package    Zend_Search_Lucene
34  * @subpackage Search
35  * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
36  * @license    http://framework.zend.com/license/new-bsd     New BSD License
37  */
38 class Zend_Search_Lucene_Search_Query_Empty extends Zend_Search_Lucene_Search_Query
39 {
40     /**
41      * Re-write query into primitive queries in the context of specified index
42      *
43      * @param Zend_Search_Lucene_Interface $index
44      * @return Zend_Search_Lucene_Search_Query
45      */
46     public function rewrite(Zend_Search_Lucene_Interface $index)
47     {
48         return $this;
49     }
50
51     /**
52      * Optimize query in the context of specified index
53      *
54      * @param Zend_Search_Lucene_Interface $index
55      * @return Zend_Search_Lucene_Search_Query
56      */
57     public function optimize(Zend_Search_Lucene_Interface $index)
58     {
59         // "Empty" query is a primitive query and don't need to be optimized
60         return $this;
61     }
62
63     /**
64      * Constructs an appropriate Weight implementation for this query.
65      *
66      * @param Zend_Search_Lucene_Interface $reader
67      * @return Zend_Search_Lucene_Search_Weight
68      */
69     public function createWeight(Zend_Search_Lucene_Interface $reader)
70     {
71         return new Zend_Search_Lucene_Search_Weight_Empty();
72     }
73
74     /**
75      * Execute query in context of index reader
76      * It also initializes necessary internal structures
77      *
78      * @param Zend_Search_Lucene_Interface $reader
79      * @param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
80      */
81     public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
82     {
83         // Do nothing
84     }
85
86     /**
87      * Get document ids likely matching the query
88      *
89      * It's an array with document ids as keys (performance considerations)
90      *
91      * @return array
92      */
93     public function matchedDocs()
94     {
95         return array();
96     }
97
98     /**
99      * Score specified document
100      *
101      * @param integer $docId
102      * @param Zend_Search_Lucene_Interface $reader
103      * @return float
104      */
105     public function score($docId, Zend_Search_Lucene_Interface $reader)
106     {
107         return 0;
108     }
109
110     /**
111      * Return query terms
112      *
113      * @return array
114      */
115     public function getQueryTerms()
116     {
117         return array();
118     }
119
120     /**
121      * Query specific matches highlighting
122      *
123      * @param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter  Highlighter object (also contains doc for highlighting)
124      */
125     protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
126     {
127         // Do nothing
128     }
129
130     /**
131      * Print a query
132      *
133      * @return string
134      */
135     public function __toString()
136     {
137         return '<EmptyQuery>';
138     }
139 }
140