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 broken link info. */ 050 private Map<String, String> m_info = new LinkedHashMap<String, String>(); 051 052 /** The structure id. */ 053 private CmsUUID m_structureId; 054 055 /** The title. */ 056 private String m_subtitle; 057 058 /** The subtitle. */ 059 private String m_title; 060 061 /** The resource type. */ 062 private String m_type; 063 064 /** 065 * Constructor without a type parameter.<p> 066 * @param structureId the structure id 067 * @param title the title 068 * @param subtitle the subtitle 069 */ 070 public CmsBrokenLinkBean(CmsUUID structureId, String title, String subtitle) { 071 072 this(structureId, title, subtitle, null); 073 074 } 075 076 /** 077 * Constructor.<p> 078 * 079 * @param structureId the structure id 080 * @param title the title 081 * @param subtitle the subtitle 082 * @param type the resource type 083 */ 084 public CmsBrokenLinkBean(CmsUUID structureId, String title, String subtitle, String type) { 085 086 m_title = title; 087 m_subtitle = subtitle; 088 m_type = type; 089 m_structureId = structureId; 090 } 091 092 /** 093 * Hidden default constructor.<p> 094 */ 095 protected CmsBrokenLinkBean() { 096 097 // do nothing 098 } 099 100 /** 101 * Adds a child bean to this bean.<p> 102 * 103 * The child usually represents a link target.<p> 104 * 105 * @param bean the bean to add as a sub-bean 106 */ 107 public void addChild(CmsBrokenLinkBean bean) { 108 109 getChildren().add(bean); 110 } 111 112 /** 113 * Adds optional page information to the broken link bean.<p> 114 * 115 * @param name the info name 116 * @param value the info 117 */ 118 public void addInfo(String name, String value) { 119 120 m_info.put(name, value); 121 } 122 123 /** 124 * @see java.lang.Object#equals(java.lang.Object) 125 */ 126 @Override 127 public boolean equals(Object obj) { 128 129 return (obj instanceof CmsBrokenLinkBean) && ((CmsBrokenLinkBean)obj).m_structureId.equals(m_structureId); 130 } 131 132 /** 133 * Returns the child beans of this bean.<p> 134 * 135 * @return the list of child beans 136 */ 137 public List<CmsBrokenLinkBean> getChildren() { 138 139 return m_children; 140 } 141 142 /** 143 * Returns the additional link info.<p> 144 * 145 * @return the broken link info 146 */ 147 public Map<String, String> getInfo() { 148 149 return m_info; 150 } 151 152 /** 153 * Returns the sub-title of the bean.<p> 154 * 155 * @return the sub-title 156 */ 157 public String getSubTitle() { 158 159 return m_subtitle; 160 161 } 162 163 /** 164 * Returns the title of the bean.<p> 165 * 166 * @return the title of the bean 167 */ 168 public String getTitle() { 169 170 return m_title; 171 } 172 173 /** 174 * Returns the resource type.<p> 175 * 176 * @return the resource type 177 */ 178 public String getType() { 179 180 return m_type; 181 } 182 183 /** 184 * @see java.lang.Object#hashCode() 185 */ 186 @Override 187 public int hashCode() { 188 189 return m_structureId.hashCode(); 190 } 191 192}