1 17 package com.sun.syndication.feed.synd; 18 19 import com.sun.syndication.feed.impl.ObjectBean; 20 import com.sun.syndication.feed.module.*; 21 import com.sun.syndication.feed.module.impl.ModuleUtils; 22 import com.sun.syndication.feed.synd.impl.URINormalizer; 23 import com.sun.syndication.feed.impl.CopyFromHelper; 24 25 import java.util.*; 26 import java.io.Serializable ; 27 28 34 public class SyndEntryImpl implements Serializable ,SyndEntry { 35 private ObjectBean _objBean; 36 private String _uri; 37 private String _title; 38 private String _link; 39 private SyndContent _description; 40 private List _contents; 41 private List _modules; 42 43 private static final Set IGNORE_PROPERTIES = new HashSet(); 44 45 51 public static final Set CONVENIENCE_PROPERTIES = Collections.unmodifiableSet(IGNORE_PROPERTIES); 52 53 static { 54 IGNORE_PROPERTIES.add("publishedDate"); 55 IGNORE_PROPERTIES.add("author"); 56 IGNORE_PROPERTIES.add("categories"); 57 } 58 59 68 protected SyndEntryImpl(Class beanClass,Set convenienceProperties) { 69 _objBean = new ObjectBean(beanClass,this,convenienceProperties); 70 } 71 72 77 public SyndEntryImpl() { 78 this(SyndEntry.class,IGNORE_PROPERTIES); 79 } 80 81 88 public Object clone() throws CloneNotSupportedException { 89 return _objBean.clone(); 90 } 91 92 99 public boolean equals(Object other) { 100 return _objBean.equals(other); 101 } 102 103 111 public int hashCode() { 112 return _objBean.hashCode(); 113 } 114 115 121 public String toString() { 122 return _objBean.toString(); 123 } 124 125 126 138 public String getUri() { 139 return _uri; 140 } 141 142 152 public void setUri(String uri) { 153 _uri = URINormalizer.normalize(uri); 154 } 155 156 162 public String getTitle() { 163 return _title; 164 } 165 166 172 public void setTitle(String title) { 173 _title = title; 174 } 175 176 182 public String getLink() { 183 return _link; 184 } 185 186 192 public void setLink(String link) { 193 _link = link; 194 } 195 196 202 public SyndContent getDescription() { 203 return _description; 204 } 205 206 212 public void setDescription(SyndContent description) { 213 _description = description; 214 } 215 216 223 public List getContents() { 224 return (_contents==null) ? (_contents=new ArrayList()) : _contents; 225 } 226 227 234 public void setContents(List contents) { 235 _contents = contents; 236 } 237 238 239 247 public Date getPublishedDate() { 248 return getDCModule().getDate(); 249 } 250 251 259 public void setPublishedDate(Date publishedDate) { 260 getDCModule().setDate(publishedDate); 261 } 262 263 271 public String getAuthor() { 272 return getDCModule().getCreator(); 273 } 274 275 283 public void setAuthor(String author) { 284 getDCModule().setCreator(author); 285 } 286 287 296 public List getCategories() { 297 return new SyndCategoryListFacade(getDCModule().getSubjects()); 298 } 299 300 309 public void setCategories(List categories) { 310 getDCModule().setSubjects(SyndCategoryListFacade.convertElementsSyndCategoryToSubject(categories)); 311 } 312 313 320 public List getModules() { 321 if (_modules==null) { 322 _modules=new ArrayList(); 323 } 324 if (ModuleUtils.getModule(_modules,DCModule.URI)==null) { 325 _modules.add(new DCModuleImpl()); 326 } 327 return _modules; 328 } 329 330 337 public void setModules(List modules) { 338 _modules = modules; 339 } 340 341 347 public Module getModule(String uri) { 348 return ModuleUtils.getModule(getModules(),uri); 349 } 350 351 356 private DCModule getDCModule() { 357 return (DCModule) getModule(DCModule.URI); 358 } 359 360 public Class getInterface() { 361 return SyndEntry.class; 362 } 363 364 public void copyFrom(Object obj) { 365 COPY_FROM_HELPER.copy(this,obj); 366 } 367 368 private static final CopyFromHelper COPY_FROM_HELPER; 369 370 static { 371 Map basePropInterfaceMap = new HashMap(); 372 basePropInterfaceMap.put("uri",String .class); 373 basePropInterfaceMap.put("title",String .class); 374 basePropInterfaceMap.put("link",String .class); 375 basePropInterfaceMap.put("description",SyndContent.class); 376 basePropInterfaceMap.put("contents",SyndContent.class); 377 basePropInterfaceMap.put("modules",Module.class); 378 379 Map basePropClassImplMap = new HashMap(); 380 basePropClassImplMap.put(SyndContent.class,SyndContentImpl.class); 381 basePropClassImplMap.put(DCModule.class,DCModuleImpl.class); 382 basePropClassImplMap.put(SyModule.class,SyModuleImpl.class); 383 384 COPY_FROM_HELPER = new CopyFromHelper(SyndEntry.class,basePropInterfaceMap,basePropClassImplMap); 385 } 386 387 } 388 | Popular Tags |