| 1 25 26 package com.j2biz.blogunity.pojo; 27 28 import java.io.Serializable ; 29 import java.util.Iterator ; 30 import java.util.Set ; 31 import java.util.TreeSet ; 32 33 import com.j2biz.blogunity.util.EntryComparator; 34 35 45 public class Category implements Serializable { 46 47 50 private static final long serialVersionUID = 3546084648699312176L; 51 52 public static final int GLOBAL = 0; 53 54 public static final int LOCAL = 1; 55 56 private Long id; 57 58 private String name; 59 60 private String description; 61 62 private int type = GLOBAL; 63 64 66 private Set blogs = new TreeSet ( 67 new EntryComparator()); 68 69 private Set entries = new TreeSet ( 70 new EntryComparator()); 71 72 75 public Category() { 76 super(); 77 } 78 79 public Category(String name, int type) { 80 this.name = name; 81 this.type = type; 82 } 83 84 public Category(String name, String description, int type) { 85 this.name = name; 86 this.description = description; 87 this.type = type; 88 } 89 90 96 public String getDescription() { 97 return description; 98 } 99 100 104 public void setDescription(String description) { 105 this.description = description; 106 } 107 108 119 public Set getBlogs() { 120 return blogs; 121 } 122 123 127 public void setBlogs(Set blogs) { 128 this.blogs = blogs; 129 } 130 131 public void addBlog(Blog blog) { 132 blogs.add(blog); 133 } 134 135 146 public Set getEntries() { 147 return entries; 148 } 149 150 154 public void setEntries(Set entries) { 155 this.entries = entries; 156 } 157 158 public void addEntry(Entry entry) { 159 entries.add(entry); 160 } 161 162 168 public Long getId() { 169 return id; 170 } 171 172 176 public void setId(Long id) { 177 this.id = id; 178 } 179 180 186 public String getName() { 187 return name; 188 } 189 190 194 public void setName(String name) { 195 this.name = name; 196 } 197 198 204 public int getType() { 205 return type; 206 } 207 208 212 public void setType(int type) { 213 this.type = type; 214 } 215 216 public boolean containsBlog(Blog b) { 217 218 Iterator it = getBlogs().iterator(); 219 while (it.hasNext()) { 220 Blog bl = (Blog) it.next(); 221 if (bl.getId().longValue() == b.getId().longValue()) 222 return true; 223 224 } 225 226 return false; 227 } 228 } | Popular Tags |