001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (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 GmbH & Co. KG, 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.setup;
029
030import java.util.ArrayList;
031import java.util.List;
032import java.util.regex.Pattern;
033
034/**
035 * Module group data.<p>
036 *
037 * @since 7.0.4
038 */
039public class CmsSetupComponent {
040
041    /** The default check flag. */
042    private boolean m_checked;
043
044    /** The dependencies of the setup component. */
045    private List<String> m_dependencies;
046
047    /** The description for the setup component. */
048    private String m_description;
049
050    /** The ID of the setup component. */
051    private String m_id;
052
053    /** The module's regex. */
054    private Pattern m_modulesRegex;
055
056    /** The name of the setup component. */
057    private String m_name;
058
059    /** The position of the setup component. */
060    private int m_position;
061
062    /**
063     * Returns the dependencies.<p>
064     *
065     * @return the dependencies
066     */
067    public List<String> getDependencies() {
068
069        return m_dependencies;
070    }
071
072    /**
073     * Returns the description.<p>
074     *
075     * @return the description
076     */
077    public String getDescription() {
078
079        return m_description;
080    }
081
082    /**
083     * Returns the id.<p>
084     *
085     * @return the id
086     */
087    public String getId() {
088
089        return m_id;
090    }
091
092    /**
093     * Returns the modules regular expression.<p>
094     *
095     * @return the modules regular expression
096     */
097    public Pattern getModulesRegex() {
098
099        return m_modulesRegex;
100    }
101
102    /**
103     * Returns the name.<p>
104     *
105     * @return the name
106     */
107    public String getName() {
108
109        return m_name;
110    }
111
112    /**
113     * Returns the position.<p>
114     *
115     * @return the position
116     */
117    public int getPosition() {
118
119        return m_position;
120    }
121
122    /**
123     * Checks if checked by default.<p>
124     *
125     * @return if checked by default
126     */
127    public boolean isChecked() {
128
129        return m_checked;
130    }
131
132    /**
133     * Matches the module regular expression against the given module name.
134     *
135     * @param module the module name to match
136     *
137     * @return <code>true</code> if it matches
138     */
139    public boolean match(String module) {
140
141        return m_modulesRegex.matcher(module).matches();
142    }
143
144    /**
145     * Sets if checked by default.<p>
146     *
147     * @param checked the checked flag to set
148     */
149    public void setChecked(boolean checked) {
150
151        m_checked = checked;
152    }
153
154    /**
155     * Sets the dependencies.<p>
156     *
157     * @param dependencies the dependencies to set
158     */
159    public void setDependencies(List<String> dependencies) {
160
161        m_dependencies = new ArrayList<String>(dependencies);
162    }
163
164    /**
165     * Sets the description.<p>
166     *
167     * @param description the description to set
168     */
169    public void setDescription(String description) {
170
171        m_description = description;
172    }
173
174    /**
175     * Sets the id.<p>
176     *
177     * @param id the id to set
178     */
179    public void setId(String id) {
180
181        m_id = id;
182    }
183
184    /**
185     * Sets the modules regular expression.<p>
186     *
187     * @param regex the regular expression to set
188     */
189    public void setModulesRegex(String regex) {
190
191        m_modulesRegex = Pattern.compile(regex);
192    }
193
194    /**
195     * Sets the name.<p>
196     *
197     * @param name the name to set
198     */
199    public void setName(String name) {
200
201        m_name = name;
202    }
203
204    /**
205     * Sets the position.<p>
206     *
207     * @param position the position to set
208     */
209    public void setPosition(int position) {
210
211        m_position = position;
212    }
213
214    /**
215     * @see java.lang.Object#toString()
216     */
217    @Override
218    public String toString() {
219
220        StringBuffer ret = new StringBuffer();
221        ret.append("[CmsSetupGroupBean: ");
222        ret.append("id=").append(m_id).append(", ");
223        ret.append("name=").append(m_name).append(", ");
224        ret.append("description=").append(m_description).append(", ");
225        ret.append("dependencies=").append(m_dependencies).append(", ");
226        ret.append("moduleRegex=").append(m_modulesRegex.pattern()).append("]");
227        return ret.toString();
228    }
229}