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, 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.gwt.shared;
029
030import org.opencms.util.CmsUUID;
031
032import java.util.ArrayList;
033import java.util.LinkedHashMap;
034import java.util.List;
035import java.util.Map;
036
037import com.google.gwt.user.client.rpc.IsSerializable;
038
039/**
040 * A bean which represents either the source or the target of a broken link.<p>
041 *
042 * @since 8.0.0
043 */
044public class CmsBrokenLinkBean implements IsSerializable {
045
046    /** The child beans (usually represent link targets). */
047    private List<CmsBrokenLinkBean> m_children = new ArrayList<CmsBrokenLinkBean>();
048
049    /** The icon CSS classes. */
050    private String m_icon;
051
052    /** The broken link info. */
053    private Map<String, String> m_info = new LinkedHashMap<String, String>();
054
055    /** The structure id. */
056    private CmsUUID m_structureId;
057
058    /** The title. */
059    private String m_subtitle;
060
061    /** The subtitle. */
062    private String m_title;
063
064    /** The resource type. */
065    private String m_type;
066
067    /**
068     * Constructor.<p>
069     *
070     * @param structureId the structure id
071     * @param title the title
072     * @param subtitle the subtitle
073     * @param type the resource type
074     * @param icon the
075     */
076    public CmsBrokenLinkBean(CmsUUID structureId, String title, String subtitle, String type, String icon) {
077
078        m_title = title;
079        m_subtitle = subtitle;
080        m_type = type;
081        m_structureId = structureId;
082        m_icon = icon;
083    }
084
085    /**
086     * Hidden default constructor.<p>
087     */
088    protected CmsBrokenLinkBean() {
089
090        // do nothing
091    }
092
093    /**
094     * Adds a child bean to this bean.<p>
095     *
096     * The child usually represents a link target.<p>
097     *
098     * @param bean the bean to add as a sub-bean
099     */
100    public void addChild(CmsBrokenLinkBean bean) {
101
102        getChildren().add(bean);
103    }
104
105    /**
106     * Adds optional page information to the broken link bean.<p>
107     *
108     * @param name the info name
109     * @param value the info
110     */
111    public void addInfo(String name, String value) {
112
113        m_info.put(name, value);
114    }
115
116    /**
117     * @see java.lang.Object#equals(java.lang.Object)
118     */
119    @Override
120    public boolean equals(Object obj) {
121
122        return (obj instanceof CmsBrokenLinkBean) && ((CmsBrokenLinkBean)obj).m_structureId.equals(m_structureId);
123    }
124
125    /**
126     * Returns the child beans of this bean.<p>
127     *
128     * @return the list of child beans
129     */
130    public List<CmsBrokenLinkBean> getChildren() {
131
132        return m_children;
133    }
134
135    /**
136     * Gets the icon CSS classes.
137     *
138     * @return the icon CSS classes
139     */
140    public String getIcon() {
141
142        return m_icon;
143    }
144
145    /**
146     * Returns the additional link info.<p>
147     *
148     * @return the broken link info
149     */
150    public Map<String, String> getInfo() {
151
152        return m_info;
153    }
154
155    /**
156     * Gets the structure id.
157     *
158     * @return the structure id
159     */
160    public CmsUUID getStructureId() {
161
162        return m_structureId;
163    }
164
165    /**
166     * Returns the sub-title of the bean.<p>
167     *
168     * @return the sub-title
169     */
170    public String getSubTitle() {
171
172        return m_subtitle;
173
174    }
175
176    /**
177     * Returns the title of the bean.<p>
178     *
179     * @return the title of the bean
180     */
181    public String getTitle() {
182
183        return m_title;
184    }
185
186    /**
187     * Returns the resource type.<p>
188     *
189     * @return the resource type
190     */
191    public String getType() {
192
193        return m_type;
194    }
195
196    /**
197     * @see java.lang.Object#hashCode()
198     */
199    @Override
200    public int hashCode() {
201
202        return m_structureId.hashCode();
203    }
204
205}