001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (C)  Alkacon Software (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.ade.configuration;
029
030import org.opencms.xml.content.CmsXmlContentProperty;
031
032/**
033 * This class represents the property configuration for a sitemap region.<p>
034 *
035 * (This is mostly a wrapper around CmsXmlContentProperty. We don't use that class directly because
036 *  we may want to put server-specific logic in here, and CmsXmlContentProperty is used as a bean for
037 *  RPC data transfer to the client.)
038 *
039 * @author Georg Westenberger
040 *
041 * @version $Revision: 1.0 $
042 *
043 * @since 8.0.1
044 */
045public class CmsPropertyConfig implements I_CmsConfigurationObject<CmsPropertyConfig>, Cloneable {
046
047    /** True if this property is disabled. */
048    private boolean m_disabled;
049
050    /** The order. **/
051    private int m_order;
052
053    /** The internal property data. */
054    private CmsXmlContentProperty m_propData;
055
056    /**
057     * Creates a new propery configuration bean.<p>
058     *
059     * @param propData the property data
060     * @param disabled true if this property is disabled
061     */
062    public CmsPropertyConfig(CmsXmlContentProperty propData, boolean disabled) {
063
064        this(propData, disabled, I_CmsConfigurationObject.DEFAULT_ORDER);
065    }
066
067    /**
068     * Creates a new property configuration bean.<p>
069     *
070     * @param propData the property data
071     * @param disabled true if this property is disabled
072     * @param order the number used for sorting the property configurations
073     */
074    public CmsPropertyConfig(CmsXmlContentProperty propData, boolean disabled, int order) {
075
076        m_propData = propData;
077        m_disabled = disabled;
078        m_order = order;
079    }
080
081    /**
082     * @see java.lang.Object#clone()
083     */
084    @Override
085    public CmsPropertyConfig clone() {
086
087        return new CmsPropertyConfig(m_propData, m_disabled, m_order);
088    }
089
090    /**
091     * @see org.opencms.ade.configuration.I_CmsConfigurationObject#getKey()
092     */
093    public String getKey() {
094
095        return getName();
096    }
097
098    /**
099     * Gets the name of the property.<p>
100     *
101     * @return the name of the property
102     */
103    public String getName() {
104
105        return m_propData.getName();
106    }
107
108    /**
109     * Gets the order.<p>
110     *
111     * @return the order
112     */
113    public int getOrder() {
114
115        return m_order;
116    }
117
118    /**
119     * Returns the property configuration data.<p>
120     *
121     * @return the property configuration data
122     */
123    public CmsXmlContentProperty getPropertyData() {
124
125        return m_propData;
126    }
127
128    /**
129     * Returns true if the entry disables a property, rather than adding it.<p>
130     *
131     * @return true if the property should be disabled
132     */
133    public boolean isDisabled() {
134
135        return m_disabled;
136    }
137
138    /**
139     * @see org.opencms.ade.configuration.I_CmsConfigurationObject#merge(org.opencms.ade.configuration.I_CmsConfigurationObject)
140     */
141    public CmsPropertyConfig merge(CmsPropertyConfig child) {
142
143        return child.clone();
144    }
145}