Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * Zend Framework
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to version 1.0 of the Zend Framework
8
 * license, that is bundled with this package in the file LICENSE, and
9
 * is available through the world-wide-web at the following URL:
10
 * http://www.zend.com/license/framework/1_0.txt. If you did not receive
11
 * a copy of the Zend Framework license and are unable to obtain it
12
 * through the world-wide-web, please send a note to license@zend.com
13
 * so we can mail you a copy immediately.
14
 *
15
 * @package    Zend_Search_Lucene
16
 * @subpackage Search
17
 * @copyright  Copyright (c) 2005-2006 Zend Technologies USA Inc. (http://www.zend.com)
18
 * @license    http://www.zend.com/license/framework/1_0.txt Zend Framework License version 1.0
19
 */
20
 
21
 
22
/** Zend_Search_Lucene_Exception */
23
require_once 'Zend/Search/Lucene/Exception.php';
24
 
25
 
26
/**
27
 * @package    Zend_Search_Lucene
28
 * @subpackage Search
29
 * @copyright  Copyright (c) 2005-2006 Zend Technologies USA Inc. (http://www.zend.com)
30
 * @license    http://www.zend.com/license/framework/1_0.txt Zend Framework License version 1.0
31
 */
32
class Zend_Search_Lucene_Search_QueryToken
33
{
34
    /**
35
     * Token type Word.
36
     */
37
    const TOKTYPE_WORD = 0;
38
 
39
    /**
40
     * Token type Field.
41
     * Field indicator in 'field:word' pair
42
     */
43
    const TOKTYPE_FIELD = 1;
44
 
45
    /**
46
     * Token type Sign.
47
     * '+' (required) or '-' (absentee) sign
48
     */
49
    const TOKTYPE_SIGN = 2;
50
 
51
    /**
52
     * Token type Bracket.
53
     * '(' or ')'
54
     */
55
    const TOKTYPE_BRACKET = 3;
56
 
57
 
58
    /**
59
     * Token type.
60
     *
61
     * @var integer
62
     */
63
    public $type;
64
 
65
    /**
66
     * Token text.
67
     *
68
     * @var integer
69
     */
70
    public $text;
71
 
72
 
73
    /**
74
     * IndexReader constructor needs token type and token text as a parameters.
75
     *
76
     * @param $tokType integer
77
     * @param $tokText string
78
     */
79
    public function __construct($tokType, $tokText)
80
    {
81
        switch ($tokType) {
82
            case self::TOKTYPE_BRACKET:
83
                // fall through to the next case
84
            case self::TOKTYPE_FIELD:
85
                // fall through to the next case
86
            case self::TOKTYPE_SIGN:
87
                // fall through to the next case
88
            case self::TOKTYPE_WORD:
89
                break;
90
            default:
91
                throw new Zend_Search_Lucene_Exception("Unrecognized token type \"$tokType\".");
92
        }
93
 
94
        if (!strlen($tokText)) {
95
            throw new Zend_Search_Lucene_Exception('Token text must be supplied.');
96
        }
97
 
98
        $this->type = $tokType;
99
        $this->text = $tokText;
100
    }
101
}
102