1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
29
30
31
32
33
34 public class SyndEntryImpl implements Serializable,SyndEntry {
35 private ObjectBean _objBean;
36 private String _uri;
37 private String _link;
38 private Date _updatedDate;
39 private SyndContent _title;
40 private SyndContent _description;
41 private List _links;
42 private List _contents;
43 private List _modules;
44 private List _enclosures;
45 private List _authors;
46 private List _contributors;
47 private List _foreignMarkup;
48
49
50 private List _categories = new ArrayList();
51
52 private static final Set IGNORE_PROPERTIES = new HashSet();
53
54
55
56
57
58
59
60 public static final Set CONVENIENCE_PROPERTIES = Collections.unmodifiableSet(IGNORE_PROPERTIES);
61
62 static {
63 IGNORE_PROPERTIES.add("publishedDate");
64 IGNORE_PROPERTIES.add("author");
65 }
66
67
68
69
70
71
72
73
74
75
76 protected SyndEntryImpl(Class beanClass,Set convenienceProperties) {
77 _objBean = new ObjectBean(beanClass,this,convenienceProperties);
78 }
79
80
81
82
83
84
85 public SyndEntryImpl() {
86 this(SyndEntry.class,IGNORE_PROPERTIES);
87 }
88
89
90
91
92
93
94
95
96 public Object clone() throws CloneNotSupportedException {
97 return _objBean.clone();
98 }
99
100
101
102
103
104
105
106
107 public boolean equals(Object other) {
108
109 Object fm = getForeignMarkup();
110 setForeignMarkup(((SyndEntryImpl)other).getForeignMarkup());
111 boolean ret = _objBean.equals(other);
112
113 setForeignMarkup(fm);
114 return ret;
115 }
116
117
118
119
120
121
122
123
124
125 public int hashCode() {
126 return _objBean.hashCode();
127 }
128
129
130
131
132
133
134
135 public String toString() {
136 return _objBean.toString();
137 }
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152 public String getUri() {
153 return _uri;
154 }
155
156
157
158
159
160
161
162
163
164
165
166 public void setUri(String uri) {
167 _uri = URINormalizer.normalize(uri);
168 }
169
170
171
172
173
174
175
176 public String getTitle() {
177 if (_title != null) return _title.getValue();
178 return null;
179 }
180
181
182
183
184
185
186
187 public void setTitle(String title) {
188 if (_title == null) _title = new SyndContentImpl();
189 _title.setValue(title);
190 }
191
192
193
194
195
196
197
198 public SyndContent getTitleEx() {
199 return _title;
200 }
201
202
203
204
205
206
207
208 public void setTitleEx(SyndContent title) {
209 _title = title;
210 }
211
212
213
214
215
216
217
218 public String getLink() {
219 return _link;
220 }
221
222
223
224
225
226
227
228 public void setLink(String link) {
229 _link = link;
230 }
231
232
233
234
235
236
237
238 public SyndContent getDescription() {
239 return _description;
240 }
241
242
243
244
245
246
247
248 public void setDescription(SyndContent description) {
249 _description = description;
250 }
251
252
253
254
255
256
257
258
259 public List getContents() {
260 return (_contents==null) ? (_contents=new ArrayList()) : _contents;
261 }
262
263
264
265
266
267
268
269
270 public void setContents(List contents) {
271 _contents = contents;
272 }
273
274
275
276
277
278
279
280
281 public List getEnclosures() {
282 return (_enclosures==null) ? (_enclosures=new ArrayList()) : _enclosures;
283 }
284
285
286
287
288
289
290
291
292 public void setEnclosures(List enclosures) {
293 _enclosures = enclosures;
294 }
295
296
297
298
299
300
301
302
303
304
305 public Date getPublishedDate() {
306 return getDCModule().getDate();
307 }
308
309
310
311
312
313
314
315
316
317 public void setPublishedDate(Date publishedDate) {
318 getDCModule().setDate(publishedDate);
319 }
320
321
322
323
324
325
326
327
328 public List getCategories() {
329 return _categories;
330 }
331
332
333
334
335
336
337
338
339
340
341 public void setCategories(List categories) {
342 _categories = categories;
343 }
344
345
346
347
348
349
350
351
352 public List getModules() {
353 if (_modules==null) {
354 _modules=new ArrayList();
355 }
356 if (ModuleUtils.getModule(_modules,DCModule.URI)==null) {
357 _modules.add(new DCModuleImpl());
358 }
359 return _modules;
360 }
361
362
363
364
365
366
367
368
369 public void setModules(List modules) {
370 _modules = modules;
371 }
372
373
374
375
376
377
378
379 public Module getModule(String uri) {
380 return ModuleUtils.getModule(getModules(),uri);
381 }
382
383
384
385
386
387
388 private DCModule getDCModule() {
389 return (DCModule) getModule(DCModule.URI);
390 }
391
392 public Class getInterface() {
393 return SyndEntry.class;
394 }
395
396 public void copyFrom(Object obj) {
397 COPY_FROM_HELPER.copy(this,obj);
398 }
399
400 private static final CopyFromHelper COPY_FROM_HELPER;
401
402 static {
403 Map basePropInterfaceMap = new HashMap();
404 basePropInterfaceMap.put("uri",String.class);
405 basePropInterfaceMap.put("title",String.class);
406 basePropInterfaceMap.put("link",String.class);
407 basePropInterfaceMap.put("uri",String.class);
408 basePropInterfaceMap.put("description",SyndContent.class);
409 basePropInterfaceMap.put("contents",SyndContent.class);
410 basePropInterfaceMap.put("enclosures",SyndEnclosure.class);
411 basePropInterfaceMap.put("modules",Module.class);
412
413 Map basePropClassImplMap = new HashMap();
414 basePropClassImplMap.put(SyndContent.class,SyndContentImpl.class);
415 basePropClassImplMap.put(SyndEnclosure.class,SyndEnclosureImpl.class);
416 basePropClassImplMap.put(DCModule.class,DCModuleImpl.class);
417 basePropClassImplMap.put(SyModule.class,SyModuleImpl.class);
418
419 COPY_FROM_HELPER = new CopyFromHelper(SyndEntry.class,basePropInterfaceMap,basePropClassImplMap);
420 }
421
422
423
424
425
426
427 public List getLinks() {
428 return (_links==null) ? (_links=new ArrayList()) : _links;
429 }
430
431
432
433
434
435
436 public void setLinks(List links) {
437 _links = links;
438 }
439
440
441
442
443
444
445 public Date getUpdatedDate() {
446 return _updatedDate;
447 }
448
449
450
451
452
453
454 public void setUpdatedDate(Date updatedDate) {
455 _updatedDate = updatedDate;
456 }
457
458 public List getAuthors() {
459 return _authors;
460 }
461
462
463
464
465 public void setAuthors(List authors) {
466 _authors = authors;
467 }
468
469
470
471
472
473
474
475
476
477 public String getAuthor() {
478 String author;
479
480
481
482 if ((_authors != null) && (_authors.size() > 0)) {
483 author = ((SyndPerson)_authors.get(0)).getName();
484 } else {
485 author = getDCModule().getCreator();
486 }
487 if (author == null) {
488 author = "";
489 }
490
491 return author;
492 }
493
494
495
496
497
498
499
500
501
502 public void setAuthor(String author) {
503
504
505 DCModule dcModule = getDCModule();
506 String currentValue = dcModule.getCreator();
507
508 if ((currentValue == null) || (currentValue.length() == 0)) {
509 getDCModule().setCreator(author);
510 }
511 }
512
513 public List getContributors() {
514 return _contributors;
515 }
516
517
518
519
520 public void setContributors(List contributors) {
521 _contributors = contributors;
522 }
523
524
525
526
527
528
529
530
531 public Object getForeignMarkup() {
532 return (_foreignMarkup==null) ? (_foreignMarkup=new ArrayList()) : _foreignMarkup;
533 }
534
535
536
537
538
539
540
541
542 public void setForeignMarkup(Object foreignMarkup) {
543 _foreignMarkup = (List)foreignMarkup;
544 }
545 }