001 /*
002 *
003 * $Revision: 15330 $ $Date: 2009-06-08 15:47:06 +0200 (Mon, 08 Jun 2009) $
004 *
005 * This file is part of *** M y C o R e ***
006 * See http://www.mycore.de/ for details.
007 *
008 * This program is free software; you can use it, redistribute it
009 * and / or modify it under the terms of the GNU General Public License
010 * (GPL) as published by the Free Software Foundation; either version 2
011 * of the License or (at your option) any later version.
012 *
013 * This program is distributed in the hope that it will be useful, but
014 * WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program, in a file called gpl.txt or license.txt.
020 * If not, write to the Free Software Foundation Inc.,
021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
022 */
023
024 package org.mycore.frontend.indexbrowser.sql;
025
026 import java.util.StringTokenizer;
027
028 import org.mycore.common.MCRConfiguration;
029
030 /**
031 * @author Frank Lützenkirchen
032 */
033 class MCRIndexConfiguration {
034 String table;
035
036 boolean distinct;
037
038 String browseField;
039
040 String fields;
041
042 String[] extraFields;
043
044 String order;
045
046 String filter;
047
048 String style;
049
050 int maxPerPage;
051
052 boolean normalizeSearch;
053
054 MCRIndexConfiguration(String ID) {
055 MCRConfiguration config = MCRConfiguration.instance();
056 String prefix = "MCR.IndexBrowser." + ID + ".";
057
058 table = config.getString(prefix + "Table");
059 distinct = config.getBoolean(prefix + "Distinct", true);
060 browseField = config.getString(prefix + "FieldToBrowse");
061 filter = config.getString(prefix + "FilterCondition", null);
062 maxPerPage = config.getInt(prefix + "MaxPerPage");
063 style = config.getString(prefix + "Style");
064 fields = config.getString(prefix + "ExtraOutputFields", null);
065 order = config.getString(prefix + "Order", "asc");
066 normalizeSearch = config.getBoolean(prefix + "NormalizeSearch", false);
067 buildFieldList(fields);
068 }
069
070 void buildFieldList(String fields) {
071 if ((fields == null) || (fields.trim().length() == 0)) {
072 extraFields = new String[0];
073 }
074
075 StringTokenizer st = new StringTokenizer(fields, " ,");
076 extraFields = new String[st.countTokens()];
077
078 for (int i = 0; i < extraFields.length; i++)
079 extraFields[i] = st.nextToken();
080 }
081 }