Source code: com/opencms/template/cache/CmsElementDescriptor.java
1 /*
2 * File : $Source: /usr/local/cvs/opencms/src/com/opencms/template/cache/CmsElementDescriptor.java,v $
3 * Date : $Date: 2003/01/20 23:59:21 $
4 * Version: $Revision: 1.7 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * For further information about OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */
28
29 package com.opencms.template.cache;
30
31
32 /**
33 * This descriptor is used to locate CmsElement-Objects with the
34 * CmsElementLocator. It is the key for a CmsElement.
35 *
36 * @author Andreas Schouten
37 */
38 public class CmsElementDescriptor {
39
40 /**
41 * The name of the class for this descriptor.
42 */
43 private String m_className;
44
45 /**
46 * The name of the template-file for this descriptor.
47 */
48 private String m_templateName;
49
50 /**
51 * The constructor to create a new CmsElementDescriptor.
52 *
53 * @param className the name of the class for this descriptor.
54 * @param templateName the name of the template for this descriptor.
55 */
56 public CmsElementDescriptor(String className, String templateName) {
57 m_className = className;
58 m_templateName = templateName;
59 }
60
61 /**
62 * Returns the key of this descriptor.
63 *
64 * @return the key of this descriptor.
65 */
66 public String getKey() {
67 return m_className + "|" + m_templateName;
68 }
69
70 /**
71 * Get the class name for the element defined.
72 * @return Class name for the element.
73 */
74 public String getClassName() {
75 return m_className;
76 }
77
78 /**
79 * Get the template name for the element defined.
80 * @return Template name for the element.
81 */
82 public String getTemplateName() {
83 return m_templateName;
84 }
85
86 /**
87 * We have to return a hashcode for the hashtable. We can use the hashcode
88 * from the Strings m_className and m_templatename.
89 * @return The hashCode.
90 */
91 public int hashCode(){
92 return (m_className + m_templateName).hashCode();
93 }
94
95 /**
96 * Compares the overgiven object with this object.
97 *
98 * @return true, if the object is identically else it returns false.
99 */
100 public boolean equals(Object obj) {
101 // check if the object is a CmsElementDescriptor object
102 if (obj instanceof CmsElementDescriptor) {
103 // same key ?
104 if (((CmsElementDescriptor)obj).getKey().equals(getKey()) ){
105 return true;
106 }
107 }
108 return false;
109 }
110
111 /**
112 * toString methode
113 */
114 public String toString(){
115 return m_className + " | " + m_templateName;
116 }
117 }