001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/relations/CmsCategory.java,v $
003: * Date : $Date: 2008-02-27 12:05:42 $
004: * Version: $Revision: 1.4 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.relations;
033:
034: import org.opencms.file.CmsResource;
035: import org.opencms.util.CmsUUID;
036:
037: /**
038: * Represents a category, that is just a folder under /system/categories/.<p>
039: *
040: * @author Michael Moossen
041: *
042: * @version $Revision: 1.4 $
043: *
044: * @since 6.9.2
045: */
046: public class CmsCategory {
047:
048: /** The description of the category. */
049: private String m_description;
050:
051: /** The path of the category. */
052: private String m_path;
053:
054: /** The structure id of the resource that this category represents. */
055: private CmsUUID m_structureId;
056:
057: /** The title of the category. */
058: private String m_title;
059:
060: /**
061: * Deafult constructor.<p>
062: *
063: * @param structureId the structure id of the resource that this category represents
064: * @param path the path of the category
065: * @param title the title of the category
066: * @param description the description of the category
067: */
068: public CmsCategory(CmsUUID structureId, String path, String title,
069: String description) {
070:
071: m_structureId = structureId;
072: m_path = path;
073: m_title = title;
074: m_description = description;
075: }
076:
077: /**
078: * @see java.lang.Object#equals(java.lang.Object)
079: */
080: public boolean equals(Object obj) {
081:
082: if (!(obj instanceof CmsCategory)) {
083: return false;
084: }
085: CmsCategory compareCategory = (CmsCategory) obj;
086: if (!compareCategory.getId().equals(m_structureId)) {
087: return false;
088: }
089: return true;
090: }
091:
092: /**
093: * Returns the description.<p>
094: *
095: * @return the description
096: */
097: public String getDescription() {
098:
099: return m_description;
100: }
101:
102: /**
103: * Returns the id.<p>
104: *
105: * @return the id
106: */
107: public CmsUUID getId() {
108:
109: return m_structureId;
110: }
111:
112: /**
113: * Returns the mere category name without it's complete path and without the trailing folder - slash.<p>
114: *
115: * @return the mere category name without it's complete path and without the trailing folder - slash
116: */
117: public String getName() {
118:
119: String result = CmsResource.getName(m_path);
120: // Kill trailing slash as categories are not displayed like folders
121: if (CmsResource.isFolder(result)) {
122: result = result.substring(0, result.length() - 1);
123: }
124: return result;
125: }
126:
127: /**
128: * Returns the path.<p>
129: *
130: * @return the path
131: */
132: public String getPath() {
133:
134: return m_path;
135: }
136:
137: /**
138: * Returns the title.<p>
139: *
140: * @return the title
141: */
142: public String getTitle() {
143:
144: return m_title;
145: }
146:
147: /**
148: * @see java.lang.Object#hashCode()
149: */
150: public int hashCode() {
151:
152: return m_structureId.hashCode();
153: }
154: }
|