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.util.portlet;
016    
017    import com.liferay.portal.kernel.configuration.Configuration;
018    import com.liferay.portal.kernel.configuration.ConfigurationFactoryUtil;
019    import com.liferay.portal.kernel.configuration.Filter;
020    import com.liferay.portal.kernel.portlet.PortletClassLoaderUtil;
021    
022    import java.util.Properties;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class PortletProps {
028    
029            public static void addProperties(Properties properties) {
030                    _instance._configuration.addProperties(properties);
031            }
032    
033            public static boolean contains(String key) {
034                    return _instance._configuration.contains(key);
035            }
036    
037            public static String get(String key) {
038                    return _instance._configuration.get(key);
039            }
040    
041            public static String get(String key, Filter filter) {
042                    return _instance._configuration.get(key, filter);
043            }
044    
045            public static String[] getArray(String key) {
046                    return _instance._configuration.getArray(key);
047            }
048    
049            public static String[] getArray(String key, Filter filter) {
050                    return _instance._configuration.getArray(key, filter);
051            }
052    
053            public static Properties getProperties() {
054                    return _instance._configuration.getProperties();
055            }
056    
057            public static void removeProperties(Properties properties) {
058                    _instance._configuration.removeProperties(properties);
059            }
060    
061            public static void set(String key, String value) {
062                    _instance._configuration.set(key, value);
063            }
064    
065            private PortletProps() {
066                    _configuration = ConfigurationFactoryUtil.getConfiguration(
067                            PortletClassLoaderUtil.getClassLoader(), "portlet");
068            }
069    
070            private static PortletProps _instance = new PortletProps();
071    
072            private Configuration _configuration;
073    
074    }