001    /**
002     * Copyright (c) 2000-2012 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    import com.liferay.portlet.social.model.SocialActivitySet;
022    
023    import java.util.HashSet;
024    import java.util.Set;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class SocialActivityInterpreterImpl
030            implements SocialActivityInterpreter {
031    
032            public SocialActivityInterpreterImpl(
033                    String portletId, SocialActivityInterpreter activityInterpreter) {
034    
035                    _portletId = portletId;
036                    _activityInterpreter = activityInterpreter;
037    
038                    String[] classNames = _activityInterpreter.getClassNames();
039    
040                    for (String className : classNames) {
041                            _classNames.add(className);
042                    }
043            }
044    
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            public SocialActivityFeedEntry interpret(
063                    SocialActivity activity, ThemeDisplay themeDisplay) {
064    
065                    return _activityInterpreter.interpret(activity, themeDisplay);
066            }
067    
068            public SocialActivityFeedEntry interpret(
069                    SocialActivitySet activitySet, ThemeDisplay themeDisplay) {
070    
071                    return _activityInterpreter.interpret(activitySet, themeDisplay);
072            }
073    
074            private SocialActivityInterpreter _activityInterpreter;
075            private Set<String> _classNames = new HashSet<String>();
076            private String _portletId;
077    
078    }