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.portlet;
016    
017    import java.util.Collections;
018    import java.util.Enumeration;
019    import java.util.Map;
020    
021    import javax.portlet.PortletContext;
022    import javax.portlet.filter.FilterConfig;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class FilterConfigImpl implements FilterConfig {
028    
029            public FilterConfigImpl(
030                    String filterName, PortletContext portletContext,
031                    Map<String, String> params) {
032    
033                    _filterName = filterName;
034                    _portletContext = portletContext;
035                    _params = params;
036            }
037    
038            @Override
039            public String getFilterName() {
040                    return _filterName;
041            }
042    
043            @Override
044            public String getInitParameter(String name) {
045                    if (name == null) {
046                            throw new IllegalArgumentException();
047                    }
048    
049                    return _params.get(name);
050            }
051    
052            @Override
053            public Enumeration<String> getInitParameterNames() {
054                    return Collections.enumeration(_params.keySet());
055            }
056    
057            @Override
058            public PortletContext getPortletContext() {
059                    return _portletContext;
060            }
061    
062            private String _filterName;
063            private Map<String, String> _params;
064            private PortletContext _portletContext;
065    
066    }