New getComentById() method
[gofetch.git] / src / be / nikiroo / gofetch / data / Story.java
CommitLineData
73785268
NR
1package be.nikiroo.gofetch.data;
2
3import java.net.URL;
5c056aad 4import java.util.List;
73785268
NR
5
6import be.nikiroo.gofetch.support.BasicSupport;
7import be.nikiroo.gofetch.support.BasicSupport.Type;
8
9/**
10 * A news story.
11 *
12 * @author niki
13 */
14public class Story {
15 private Type type;
16 private String id;
17 private String title;
18 private String details;
19 private String urlInternal;
20 private String urlExternal;
21 private String content;
22
5c056aad
NR
23 private String fullContent;
24 private List<Comment> comments;
25
73785268
NR
26 /**
27 * Create a news story.
28 *
29 * @param type
30 * the source {@link Type}
31 * @param id
32 * the news ID
33 * @param title
34 * the news title
35 * @param details
36 * some details to add to the title
37 * @param urlInternal
38 * the {@link URL} to get this news on the associated news site
39 * @param urlExternal
40 * an external {@link URL} that serve as the news' source, if any
41 * @param content
42 * the story content
43 */
44 public Story(Type type, String id, String title, String details,
45 String urlInternal, String urlExternal, String content) {
46 this.type = type;
47 this.id = id;
48 this.title = title;
49 this.details = details;
50 this.urlInternal = urlInternal;
51 this.urlExternal = urlExternal;
52 this.content = content;
5c056aad
NR
53
54 // Defaults fullContent to content
55 this.fullContent = content;
73785268
NR
56 }
57
58 public String getSelector() {
59 return BasicSupport.getSelector(type) + id;
60 }
61
62 /**
63 * @return the id
64 */
65 public String getId() {
66 return id;
67 }
68
69 /**
70 * @return the title
71 */
72 public String getTitle() {
73 return title;
74 }
75
76 /**
77 * @return the details
78 */
79 public String getDetails() {
80 return details;
81 }
82
83 /**
84 * @return the url
85 */
86 public String getUrlInternal() {
87 return urlInternal;
88 }
89
90 /**
91 * @return the urlExternal
92 */
93 public String getUrlExternal() {
94 return urlExternal;
95 }
96
97 /**
98 * @return the body
99 */
100 public String getContent() {
101 return content;
102 }
5c056aad
NR
103
104 /**
105 * @return the fullContent
106 */
107 public String getFullContent() {
108 return fullContent;
109 }
110
111 /**
112 * @param fullContent
113 * the fullContent to set
114 */
115 public void setFullContent(String fullContent) {
116 this.fullContent = fullContent;
117 }
118
119 /**
120 * @return the comments
121 */
122 public List<Comment> getComments() {
123 return comments;
124 }
125
126 /**
127 * @param comments
128 * the comments to set
129 */
130 public void setComments(List<Comment> comments) {
131 this.comments = comments;
132 }
72f39832
NR
133
134 /**
135 * Find a comment or sub-comment by its id.
136 *
137 * @param id
138 * the id to look for F
139 * @return this if it has the given id, or a child of this if the child have
140 * the given id, or NULL if not
141 */
142 public Comment getCommentById(String id) {
143 if (id != null && comments != null) {
144 for (Comment comment : comments) {
145 Comment found = comment.getById(id);
146 if (found != null) {
147 return found;
148 }
149 }
150 }
151
152 return null;
153 }
73785268 154}