1 16 package org.roller.pojos; 17 18 import java.io.Serializable ; 19 import java.util.ArrayList ; 20 import java.util.Collection ; 21 import java.util.Iterator ; 22 import java.util.List ; 23 import java.util.Set ; 24 import java.util.StringTokenizer ; 25 import java.util.TreeSet ; 26 27 28 33 public class PlanetGroupData extends PersistentObject implements Serializable 34 { 35 transient private String [] catArray = null; 36 37 38 protected String id; 39 40 41 protected String handle; 42 43 44 protected String title; 45 46 47 protected String description; 48 49 50 protected String categoryRestriction; 51 52 53 protected int maxPageEntries = 45; 54 55 56 protected int maxFeedEntries = 45; 57 58 59 protected List subscriptionAssocs = new ArrayList (); 60 61 63 68 public String getId() 69 { 70 return id; 71 } 72 public void setId(String id) 73 { 74 this.id = id; 75 } 76 82 public List getGroupSubscriptionAssocs() 83 { 84 return subscriptionAssocs; 85 } 86 public void setGroupSubscriptionAssocs(List subscriptionAssocs) 87 { 88 this.subscriptionAssocs = subscriptionAssocs; 89 } 90 93 public String getCategoryRestriction() 94 { 95 return categoryRestriction; 96 } 97 public void setCategoryRestriction(String categoryRestriction) 98 { 99 this.categoryRestriction = categoryRestriction; 100 catArray = null; 101 } 102 105 public String getDescription() 106 { 107 return description; 108 } 109 public void setDescription(String description) 110 { 111 this.description = description; 112 } 113 116 public String getHandle() 117 { 118 return handle; 119 } 120 public void setHandle(String handle) 121 { 122 this.handle = handle; 123 } 124 127 public int getMaxFeedEntries() 128 { 129 return maxFeedEntries; 130 } 131 public void setMaxFeedEntries(int maxFeedEntries) 132 { 133 this.maxFeedEntries = maxFeedEntries; 134 } 135 138 public int getMaxPageEntries() 139 { 140 return maxPageEntries; 141 } 142 public void setMaxPageEntries(int maxPageEntries) 143 { 144 this.maxPageEntries = maxPageEntries; 145 } 146 149 public String getTitle() 150 { 151 return title; 152 } 153 public void setTitle(String title) 154 { 155 this.title = title; 156 } 157 158 160 163 public boolean qualified(PlanetEntryData entry) 164 { 165 String [] cats = getCategoryRestructionAsArray(); 166 if (cats == null || cats.length == 0) return true; 167 for (int i=0; i<cats.length; i++) 168 { 169 if (entry.inCategory(cats[i])) return true; 170 } 171 return false; 172 } 173 174 176 private String [] getCategoryRestructionAsArray() 177 { 178 if (catArray == null && categoryRestriction != null) 179 { 180 StringTokenizer toker = new StringTokenizer (categoryRestriction,","); 181 catArray = new String [toker.countTokens()]; 182 int i = 0; 183 184 while (toker.hasMoreTokens()) 185 { 186 catArray[i++] = toker.nextToken(); 187 } 188 } 189 return catArray; 190 } 191 192 private void setCategoryRestructionAsArray(String [] ignored) 193 { 194 } 195 196 198 public void removeSubscription(PlanetSubscriptionData sub) 199 { 200 Set set = new TreeSet (); 201 Iterator assocs = getGroupSubscriptionAssocs().iterator(); 202 PlanetGroupSubscriptionAssoc target = null; 203 while (assocs.hasNext()) 204 { 205 PlanetGroupSubscriptionAssoc assoc = 206 (PlanetGroupSubscriptionAssoc)assocs.next(); 207 if (assoc.getSubscription().getFeedUrl().equals(sub.getFeedUrl())) 208 { 209 target = assoc; 210 break; 211 } 212 } 213 subscriptionAssocs.remove(target); 214 } 215 public void addSubscription(PlanetSubscriptionData sub) 216 { 217 PlanetGroupSubscriptionAssoc assoc = 218 new PlanetGroupSubscriptionAssoc(); 219 assoc.setGroup(this); 220 assoc.setSubscription(sub); 221 subscriptionAssocs.add(assoc); 222 } 223 public void addSubscriptions(Collection subsList) 224 { 225 Iterator subs = subsList.iterator(); 226 while (subs.hasNext()) 227 { 228 PlanetSubscriptionData sub = (PlanetSubscriptionData)subs.next(); 229 addSubscription(sub); 230 } 231 } 232 public Set getSubscriptions() 233 { 234 Set set = new TreeSet (); 235 Iterator assocs = getGroupSubscriptionAssocs().iterator(); 236 while (assocs.hasNext()) 237 { 238 PlanetGroupSubscriptionAssoc assoc = 239 (PlanetGroupSubscriptionAssoc)assocs.next(); 240 set.add(assoc.getSubscription()); 241 } 242 return set; 243 } 244 public void setData(PersistentObject vo) 245 { 246 } 248 } 249 | Popular Tags |