001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }