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.
16 * @package Zend_Search_Lucene
17 * @subpackage Analysis
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: LowerCaseUtf8.php 16971 2009-07-22 18:05:45Z mikaelkael $
24 /** Zend_Search_Lucene_Analysis_TokenFilter */
25 require_once 'Zend/Search/Lucene/Analysis/TokenFilter.php';
29 * Lower case Token filter.
32 * @package Zend_Search_Lucene
33 * @subpackage Analysis
34 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
35 * @license http://framework.zend.com/license/new-bsd New BSD License
38 class Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8 extends Zend_Search_Lucene_Analysis_TokenFilter
43 public function __construct()
45 if (!function_exists('mb_strtolower')) {
46 // mbstring extension is disabled
47 require_once 'Zend/Search/Lucene/Exception.php';
48 throw new Zend_Search_Lucene_Exception('Utf8 compatible lower case filter needs mbstring extension to be enabled.');
53 * Normalize Token or remove it (if null is returned)
55 * @param Zend_Search_Lucene_Analysis_Token $srcToken
56 * @return Zend_Search_Lucene_Analysis_Token
58 public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
60 $newToken = new Zend_Search_Lucene_Analysis_Token(
61 mb_strtolower($srcToken->getTermText(), 'UTF-8'),
62 $srcToken->getStartOffset(),
63 $srcToken->getEndOffset());
65 $newToken->setPositionIncrement($srcToken->getPositionIncrement());