KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > blojsom > blog > database > DatabaseCategory


1 /**
2  * Copyright (c) 2003-2006, David A. Czarnecki
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and the
9  * following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
11  * following disclaimer in the documentation and/or other materials provided with the distribution.
12  * Neither the name of "David A. Czarnecki" and "blojsom" nor the names of its contributors may be used to
13  * endorse or promote products derived from this software without specific prior written permission.
14  * Products derived from this software may not be called "blojsom", nor may "blojsom" appear in their name,
15  * without prior written permission of David A. Czarnecki.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
18  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
19  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
21  * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */

31 package org.blojsom.blog.database;
32
33 import org.blojsom.blog.Category;
34 import org.blojsom.util.BlojsomUtils;
35
36 import java.io.Serializable JavaDoc;
37 import java.util.Map JavaDoc;
38 import java.util.HashMap JavaDoc;
39
40 /**
41  * DatabaseCategory
42  *
43  * @author David Czarnecki
44  * @since blojsom 3.0
45  * @version $Id: DatabaseCategory.java,v 1.4 2006/09/26 02:55:21 czarneckid Exp $
46  */

47 public class DatabaseCategory implements Category, Serializable JavaDoc {
48
49     private Integer JavaDoc _id;
50     private Integer JavaDoc _parentCategoryId;
51     private Integer JavaDoc _blogId;
52     private Category _parentCategory;
53
54     protected String JavaDoc _name;
55     protected Map JavaDoc _metaData = null;
56     protected String JavaDoc _description = null;
57
58     /**
59      * Create a new instance of the database category
60      */

61     public DatabaseCategory() {
62     }
63
64     /**
65      * Get the category ID
66      *
67      * @return Category ID
68      */

69     public Integer JavaDoc getId() {
70         return _id;
71     }
72
73     /**
74      * Set the category ID
75      *
76      * @param id Category ID
77      */

78     public void setId(Integer JavaDoc id) {
79         _id = id;
80     }
81
82     /**
83      * Get the blog parent category ID
84      *
85      * @return Parent category ID
86      */

87     public Integer JavaDoc getParentCategoryId() {
88         return _parentCategoryId;
89     }
90
91     /**
92      * Se the parent category ID
93      *
94      * @param parentCategoryId Parent category ID
95      */

96     public void setParentCategoryId(Integer JavaDoc parentCategoryId) {
97         _parentCategoryId = parentCategoryId;
98     }
99
100     /**
101      * Get the blog ID
102      *
103      * @return Blog ID
104      */

105     public Integer JavaDoc getBlogId() {
106         return _blogId;
107     }
108
109     /**
110      * Set the blog ID
111      *
112      * @param blogId Blog ID
113      */

114     public void setBlogId(Integer JavaDoc blogId) {
115         _blogId = blogId;
116     }
117
118     /**
119      * Set a new name for this category
120      *
121      * @param name Category name
122      */

123     public void setName(String JavaDoc name) {
124         _name = name;
125     }
126
127     /**
128      * Return the category name
129      *
130      * @return Category name
131      */

132     public String JavaDoc getName() {
133         return _name;
134     }
135
136     /**
137      * Return the category name encoded for a link
138      *
139      * @return Category name encoded as UTF-8 with preserved "/" and "+" characters
140      */

141     public String JavaDoc getEncodedName() {
142         return BlojsomUtils.urlEncodeForLink(_name);
143     }
144
145     /**
146      * Sets the description of this category
147      *
148      * @param desc The new description of the category
149      */

150     public void setDescription(String JavaDoc description) {
151         _description = description;
152     }
153
154     /**
155      * Retrieves the description of this category
156      *
157      * @return The description of the category
158      */

159     public String JavaDoc getDescription() {
160         return _description;
161     }
162
163     /**
164      * Set the meta-data associated with this category
165      *
166      * @param metaData The map to be associated with the category as meta-data
167      */

168     public void setMetaData(Map JavaDoc metaData) {
169         _metaData = metaData;
170     }
171
172     /**
173      * Retrieves the meta-data associated with this category
174      *
175      * @return The properties associated with the category as meta-data, or null if no metadata exists
176      */

177     public Map JavaDoc getMetaData() {
178         if (_metaData == null) {
179             return new HashMap JavaDoc();
180         }
181
182         return _metaData;
183     }
184
185     /**
186      * Returns the parent category of this category. Defaults to "/"
187      *
188      * @return {@link Category} containing the parent category
189      */

190     public Category getParentCategory() {
191         return _parentCategory;
192     }
193
194     /**
195      * Sets the parent category of this category
196      *
197      * @param cateogry {@link Category} that represents the parent category
198      */

199     public void setParentCategory(Category parentCategory) {
200         _parentCategory = parentCategory;
201     }
202 }
203
Popular Tags