001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.search.generic;
016    
017    import com.liferay.portal.kernel.search.BooleanClause;
018    import com.liferay.portal.kernel.search.BooleanClauseFactory;
019    import com.liferay.portal.kernel.search.BooleanClauseOccur;
020    import com.liferay.portal.kernel.search.BooleanClauseOccurImpl;
021    import com.liferay.portal.kernel.search.Query;
022    import com.liferay.portal.kernel.search.TermQueryFactory;
023    
024    /**
025     * @author Bruno Farache
026     */
027    public class BooleanClauseFactoryImpl implements BooleanClauseFactory {
028    
029            public BooleanClause create(Query query, String occur) {
030                    BooleanClauseOccur booleanClauseOccur = new BooleanClauseOccurImpl(
031                            occur);
032    
033                    return new BooleanClauseImpl(query, booleanClauseOccur);
034            }
035    
036            public BooleanClause create(String field, String value, String occur) {
037                    Query query = _termQueryFactory.create(field, value);
038    
039                    BooleanClauseOccur booleanClauseOccur = new BooleanClauseOccurImpl(
040                            occur);
041    
042                    return new BooleanClauseImpl(query, booleanClauseOccur);
043            }
044    
045            private TermQueryFactory _termQueryFactory = new TermQueryFactoryImpl();
046    
047    }