001    /**
002     * Copyright (c) 2000-2013 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.kernel.search;
016    
017    import java.util.ArrayList;
018    import java.util.HashMap;
019    import java.util.List;
020    import java.util.Map;
021    
022    /**
023     * @author Michael C. Han
024     */
025    public class NGramHolder {
026    
027            public void addNGram(int number, String gram) {
028                    String key = "gram" + number;
029    
030                    List<String> grams = _nGrams.get(key);
031    
032                    if (grams == null) {
033                            grams = new ArrayList<String>();
034    
035                            _nGrams.put(key, grams);
036                    }
037    
038                    grams.add(gram);
039            }
040    
041            public void addNGramEnd(int number, String gram) {
042                    _nGramEnds.put("end" + number, gram);
043            }
044    
045            public void addNGramStart(int number, String gram) {
046                    _nGramStarts.put("start" + number, gram);
047            }
048    
049            public Map<String, String> getNGramEnds() {
050                    return _nGramEnds;
051            }
052    
053            public Map<String, List<String>> getNGrams() {
054                    return _nGrams;
055            }
056    
057            public Map<String, String> getNGramStarts() {
058                    return _nGramStarts;
059            }
060    
061            private Map<String, String> _nGramEnds = new HashMap<String, String>();
062            private Map<String, List<String>> _nGrams =
063                    new HashMap<String, List<String>>();
064            private Map<String, String> _nGramStarts = new HashMap<String, String>();
065    
066    }