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.social.model.impl;
016    
017    import com.liferay.portal.theme.ThemeDisplay;
018    import com.liferay.portlet.social.model.SocialActivity;
019    import com.liferay.portlet.social.model.SocialActivityFeedEntry;
020    import com.liferay.portlet.social.model.SocialActivityInterpreter;
021    
022    import java.util.HashSet;
023    import java.util.Set;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class SocialActivityInterpreterImpl
029            implements SocialActivityInterpreter {
030    
031            public SocialActivityInterpreterImpl(
032                    String portletId, SocialActivityInterpreter activityInterpreter) {
033    
034                    _portletId = portletId;
035                    _activityInterpreter = activityInterpreter;
036    
037                    String[] classNames = _activityInterpreter.getClassNames();
038    
039                    for (String className : classNames) {
040                            _classNames.add(className);
041                    }
042            }
043    
044            @Override
045            public String[] getClassNames() {
046                    return _activityInterpreter.getClassNames();
047            }
048    
049            public String getPortletId() {
050                    return _portletId;
051            }
052    
053            public boolean hasClassName(String className) {
054                    if (_classNames.contains(className)) {
055                            return true;
056                    }
057                    else {
058                            return false;
059                    }
060            }
061    
062            @Override
063            public SocialActivityFeedEntry interpret(
064                    SocialActivity activity, ThemeDisplay themeDisplay) {
065    
066                    return _activityInterpreter.interpret(activity, themeDisplay);
067            }
068    
069            private SocialActivityInterpreter _activityInterpreter;
070            private Set<String> _classNames = new HashSet<String>();
071            private String _portletId;
072    
073    }