001    /**
002     * Copyright (c) 2000-present 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.trash.model.impl;
016    
017    import com.liferay.portal.kernel.util.UnicodeProperties;
018    import com.liferay.trash.kernel.model.TrashEntry;
019    
020    /**
021     * @author Zsolt Berentey
022     */
023    public class TrashEntryImpl extends TrashEntryBaseImpl {
024    
025            @Override
026            public TrashEntry getRootEntry() {
027                    return _rootEntry;
028            }
029    
030            @Override
031            public String getTypeSettings() {
032                    if (_typeSettingsProperties == null) {
033                            return super.getTypeSettings();
034                    }
035                    else {
036                            return _typeSettingsProperties.toString();
037                    }
038            }
039    
040            @Override
041            public UnicodeProperties getTypeSettingsProperties() {
042                    if (_typeSettingsProperties == null) {
043                            _typeSettingsProperties = new UnicodeProperties(true);
044    
045                            _typeSettingsProperties.fastLoad(super.getTypeSettings());
046                    }
047    
048                    return _typeSettingsProperties;
049            }
050    
051            @Override
052            public String getTypeSettingsProperty(String key) {
053                    UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();
054    
055                    return typeSettingsProperties.getProperty(key);
056            }
057    
058            @Override
059            public String getTypeSettingsProperty(String key, String defaultValue) {
060                    UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();
061    
062                    return typeSettingsProperties.getProperty(key, defaultValue);
063            }
064    
065            @Override
066            public boolean isTrashEntry(Class<?> clazz, long classPK) {
067                    if (clazz == null) {
068                            return false;
069                    }
070    
071                    return isTrashEntry(clazz.getName(), classPK);
072            }
073    
074            @Override
075            public boolean isTrashEntry(String className, long classPK) {
076                    if (className.equals(getClassName()) && (classPK == getClassPK())) {
077                            return true;
078                    }
079    
080                    return false;
081            }
082    
083            @Override
084            public void setRootEntry(TrashEntry rootEntry) {
085                    _rootEntry = rootEntry;
086            }
087    
088            @Override
089            public void setTypeSettings(String typeSettings) {
090                    _typeSettingsProperties = null;
091    
092                    super.setTypeSettings(typeSettings);
093            }
094    
095            @Override
096            public void setTypeSettingsProperties(
097                    UnicodeProperties typeSettingsProperties) {
098    
099                    _typeSettingsProperties = typeSettingsProperties;
100    
101                    super.setTypeSettings(_typeSettingsProperties.toString());
102            }
103    
104            private TrashEntry _rootEntry;
105            private UnicodeProperties _typeSettingsProperties;
106    
107    }