001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.search;
029
030import java.util.ArrayList;
031import java.util.Map;
032
033/**
034 * A search result object returned as result of a search in
035 * <code>{@link org.opencms.search.CmsSearchIndex}</code>.<p>
036 *
037 * @since 6.0.0
038 */
039public class CmsSearchResultList extends ArrayList<CmsSearchResult> {
040
041    /** Serial version UID required for safe serialization. */
042    private static final long serialVersionUID = 606716301025993114L;
043
044    /** The (optional) categories found in the last the search. */
045    private Map<String, Integer> m_categories;
046
047    /** The total size of all results found in the last search. */
048    private int m_hitCount;
049
050    /**
051     * Creates a new result list with a default initial capacity of 100.<p>
052     */
053    public CmsSearchResultList() {
054
055        this(100);
056    }
057
058    /**
059     * Creates a new result list with the specified initial capacity.<p>
060     *
061     * @param initialCapacity the initial capacity
062     */
063    public CmsSearchResultList(int initialCapacity) {
064
065        super(initialCapacity);
066    }
067
068    /**
069     * Returns the (otional) categories found in the last the search, or <code>null</code>
070     * if the category list was not requested in the search.<p>
071     *
072     * @return the (otional) categories found in the last the search
073     *
074     * @see CmsSearch#getCalculateCategories()
075     */
076    public Map<String, Integer> getCategories() {
077
078        return m_categories;
079    }
080
081    /**
082     * Returns the hit count of all results found in the last search.<p>
083     *
084     * Since this list will only contain the result objects for the current display page,
085     * the size of the list is usually much less then the hit count of all results found.<p>
086     *
087     * @return the hit count of all results found in the last search
088     */
089    public int getHitCount() {
090
091        return m_hitCount;
092    }
093
094    /**
095     * Sets the categories found in the last the search.<p>
096     *
097     * @param categories the categories to set
098     *
099     * @see CmsSearch#setCalculateCategories(boolean)
100     */
101    public void setCategories(Map<String, Integer> categories) {
102
103        m_categories = categories;
104    }
105
106    /**
107     * Sets the hit count of all results found in the last search.<p>
108     *
109     * Since this list will only contain the result objects for the current display page,
110     * the size of the list is usually much less then the hit count of all results found.<p>
111     *
112     *  @param hitCount the hit count to set
113     */
114    public void setHitCount(int hitCount) {
115
116        m_hitCount = hitCount;
117    }
118}