X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fgofetch%2Fdata%2FStory.java;h=c0719d2d6b43bcd6812984fa7a59f8b2a8ea8306;hb=6a4d14166b93ceb49db09053b9a4cb09703fdea2;hp=9fd4c1495b882ccf8591489cb901137b01271418;hpb=5c056aade2e020276e039f81acba7bcb2b12e87f;p=gofetch.git diff --git a/src/be/nikiroo/gofetch/data/Story.java b/src/be/nikiroo/gofetch/data/Story.java index 9fd4c14..c0719d2 100644 --- a/src/be/nikiroo/gofetch/data/Story.java +++ b/src/be/nikiroo/gofetch/data/Story.java @@ -15,6 +15,9 @@ public class Story { private Type type; private String id; private String title; + private String author; + private String date; + private String category; private String details; private String urlInternal; private String urlExternal; @@ -32,8 +35,15 @@ public class Story { * the news ID * @param title * the news title + * @param author + * the author name for the details + * @param date + * the post date for the details + * @param category + * the category for the details * @param details - * some details to add to the title + * some details to add to the title (author, date and category + * will be added in the getter if available) * @param urlInternal * the {@link URL} to get this news on the associated news site * @param urlExternal @@ -41,11 +51,15 @@ public class Story { * @param content * the story content */ - public Story(Type type, String id, String title, String details, - String urlInternal, String urlExternal, String content) { + public Story(Type type, String id, String title, String author, + String date, String category, String details, String urlInternal, + String urlExternal, String content) { this.type = type; this.id = id; this.title = title; + this.author = author; + this.date = date; + this.category = category; this.details = details; this.urlInternal = urlInternal; this.urlExternal = urlExternal; @@ -77,7 +91,18 @@ public class Story { * @return the details */ public String getDetails() { - return details; + String details = ""; + + if (category != null && !category.trim().isEmpty()) + details += "[" + category + "] "; + if (date != null && !date.trim().isEmpty()) + details += date + " "; + if (author != null && !author.trim().isEmpty()) + details += "(" + this.author + ") "; + if (this.details != null && !this.details.trim().isEmpty()) + details += "\n" + this.details; + + return details.trim(); } /** @@ -130,4 +155,25 @@ public class Story { public void setComments(List comments) { this.comments = comments; } + + /** + * Find a comment or sub-comment by its id. + * + * @param id + * the id to look for F + * @return this if it has the given id, or a child of this if the child have + * the given id, or NULL if not + */ + public Comment getCommentById(String id) { + if (id != null && comments != null) { + for (Comment comment : comments) { + Comment found = comment.getById(id); + if (found != null) { + return found; + } + } + } + + return null; + } } \ No newline at end of file