1 31 32 package org.opencms.site; 33 34 import org.opencms.util.CmsUUID; 35 36 import java.util.ArrayList ; 37 import java.util.List ; 38 39 49 public final class CmsSite implements Cloneable { 50 51 52 private List m_aliases; 53 54 55 private boolean m_exclusiveError; 56 57 58 private boolean m_exclusiveUrl; 59 60 61 private CmsSiteMatcher m_secureServer; 62 63 64 private CmsSiteMatcher m_siteMatcher; 65 66 67 private String m_siteRoot; 68 69 70 private CmsUUID m_siteRootUUID; 71 72 73 private String m_title; 74 75 82 public CmsSite(String siteRoot, CmsSiteMatcher siteMatcher) { 83 84 this(siteRoot, CmsUUID.getNullUUID(), siteRoot, siteMatcher); 85 } 86 87 95 public CmsSite(String siteRoot, CmsUUID siteRootUUID, String title) { 96 97 this(siteRoot, siteRootUUID, title, CmsSiteMatcher.DEFAULT_MATCHER); 98 } 99 100 108 public CmsSite(String siteRoot, CmsUUID siteRootUUID, String title, CmsSiteMatcher siteMatcher) { 109 110 setSiteRoot(siteRoot); 111 setSiteRootUUID(siteRootUUID); 112 setTitle(title); 113 setSiteMatcher(siteMatcher); 114 m_aliases = new ArrayList (); 115 } 116 117 120 private CmsSite() { 121 122 } 124 125 130 public Object clone() { 131 132 return new CmsSite( 133 getSiteRoot(), 134 (CmsUUID)getSiteRootUUID().clone(), 135 getTitle(), 136 (CmsSiteMatcher)getSiteMatcher().clone()); 137 } 138 139 142 public boolean equals(Object obj) { 143 144 if (obj == this) { 145 return true; 146 } 147 if (obj instanceof CmsSite) { 148 ((CmsSite)obj).m_siteMatcher.equals(m_siteMatcher); 149 } 150 return false; 151 } 152 153 158 public List getAliases() { 159 160 return m_aliases; 161 } 162 163 168 public String getSecureUrl() { 169 170 return m_secureServer.getUrl(); 171 } 172 173 178 public CmsSiteMatcher getSiteMatcher() { 179 180 return m_siteMatcher; 181 } 182 183 188 public String getSiteRoot() { 189 190 return m_siteRoot; 191 } 192 193 198 public CmsUUID getSiteRootUUID() { 199 200 return m_siteRootUUID; 201 } 202 203 208 public String getTitle() { 209 210 return m_title; 211 } 212 213 218 public String getUrl() { 219 220 return m_siteMatcher.getUrl(); 221 } 222 223 226 public int hashCode() { 227 228 return m_siteRootUUID.hashCode(); 229 } 230 231 236 public boolean hasSecureServer() { 237 238 return m_secureServer != null; 239 } 240 241 247 public boolean isExclusiveError() { 248 249 return m_exclusiveError; 250 } 251 252 258 public boolean isExclusiveUrl() { 259 260 return m_exclusiveUrl; 261 } 262 263 268 public void setExclusiveError(boolean error) { 269 270 m_exclusiveError = error; 271 } 272 273 278 public void setExclusiveUrl(boolean exclusive) { 279 280 m_exclusiveUrl = exclusive; 281 } 282 283 286 public String toString() { 287 288 StringBuffer result = new StringBuffer (128); 289 result.append("server: "); 290 result.append(m_siteMatcher != null ? m_siteMatcher.toString() : "null"); 291 result.append(" uri: "); 292 result.append(m_siteRoot); 293 result.append(" title: "); 294 result.append(m_title); 295 return result.toString(); 296 } 297 298 303 protected void addAlias(CmsSiteMatcher aliasServer) { 304 305 m_aliases.add(aliasServer); 306 } 307 308 313 protected void setAliases(List aliases) { 314 315 m_aliases = aliases; 316 } 317 318 323 protected void setSecureServer(CmsSiteMatcher secureServer) { 324 325 m_secureServer = secureServer; 326 } 327 328 333 protected void setSiteMatcher(CmsSiteMatcher siteMatcher) { 334 335 m_siteMatcher = siteMatcher; 336 } 337 338 343 protected void setSiteRoot(String siteRoot) { 344 345 if (siteRoot.endsWith("/")) { 347 m_siteRoot = siteRoot.substring(0, siteRoot.length() - 1); 348 } else { 349 m_siteRoot = siteRoot; 350 } 351 } 352 353 358 protected void setSiteRootUUID(CmsUUID siteRootUUID) { 359 360 m_siteRootUUID = siteRootUUID; 361 } 362 363 368 protected void setTitle(String name) { 369 370 m_title = name; 371 } 372 } | Popular Tags |