1 package be
.nikiroo
.gofetch
.data
;
6 import be
.nikiroo
.gofetch
.support
.BasicSupport
;
7 import be
.nikiroo
.gofetch
.support
.Type
;
18 private String author
;
20 private String category
;
21 private String details
;
22 private String urlInternal
;
23 private String urlExternal
;
24 private String content
;
26 private String fullContent
;
27 private List
<Comment
> comments
;
30 * Create a news story.
33 * the source {@link Type}
39 * the author name for the details
41 * the post date for the details
43 * the category for the details
45 * some details to add to the title (author, date and category
46 * will be added in the getter if available)
48 * the {@link URL} to get this news on the associated news site
50 * an external {@link URL} that serve as the news' source, if any
54 public Story(Type type
, String id
, String title
, String author
,
55 String date
, String category
, String details
, String urlInternal
,
56 String urlExternal
, String content
) {
62 this.category
= category
;
63 this.details
= details
;
64 this.urlInternal
= urlInternal
;
65 this.urlExternal
= urlExternal
;
66 this.content
= content
;
68 // Defaults fullContent to content
69 this.fullContent
= content
;
72 public String
getSelector() {
73 return BasicSupport
.getSelector(type
) + id
;
79 public String
getId() {
86 public String
getTitle() {
93 public String
getDetails() {
96 if (category
!= null && !category
.trim().isEmpty())
97 details
+= "[" + category
+ "] ";
98 if (date
!= null && !date
.trim().isEmpty())
99 details
+= date
+ " ";
100 if (author
!= null && !author
.trim().isEmpty())
101 details
+= "(" + this.author
+ ") ";
102 if (this.details
!= null && !this.details
.trim().isEmpty())
103 details
+= "\n" + this.details
;
105 return details
.trim();
111 public String
getUrlInternal() {
116 * @return the urlExternal
118 public String
getUrlExternal() {
125 public String
getContent() {
130 * @return the fullContent
132 public String
getFullContent() {
138 * the fullContent to set
140 public void setFullContent(String fullContent
) {
141 this.fullContent
= fullContent
;
145 * @return the comments
147 public List
<Comment
> getComments() {
153 * the comments to set
155 public void setComments(List
<Comment
> comments
) {
156 this.comments
= comments
;
160 * Find a comment or sub-comment by its id.
163 * the id to look for F
164 * @return this if it has the given id, or a child of this if the child have
165 * the given id, or NULL if not
167 public Comment
getCommentById(String id
) {
168 if (id
!= null && comments
!= null) {
169 for (Comment comment
: comments
) {
170 Comment found
= comment
.getById(id
);