X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fgofetch%2Fdata%2FComment.java;h=bbd648a36a81be826af4b574b87f4a8db9137f53;hb=72f39832a7b425003c1d717afcfb5a9cf7d3405b;hp=44c0de105eef25831286f57447261b82ee98b6ef;hpb=737852686d8897331706ed4b902dbd9d5038cb53;p=gofetch.git diff --git a/src/be/nikiroo/gofetch/data/Comment.java b/src/be/nikiroo/gofetch/data/Comment.java index 44c0de1..bbd648a 100644 --- a/src/be/nikiroo/gofetch/data/Comment.java +++ b/src/be/nikiroo/gofetch/data/Comment.java @@ -9,16 +9,16 @@ public class Comment implements Iterable { private String author; private String title; private String date; - private String content; + private List lines; private List children; public Comment(String id, String author, String title, String date, - String content) { + List lines) { this.id = id; this.author = author; this.title = title; this.date = date; - this.content = content; + this.lines = lines; this.children = new ArrayList(); } @@ -61,13 +61,37 @@ public class Comment implements Iterable { /** * @return the content */ - public String getContent() { - return content; + public List getContentLines() { + return lines; + } + + /** + * 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 getById(String id) { + if (id != null) { + if (id.equals(this.id)) { + return this; + } + + for (Comment subComment : this) { + if (id.equals(subComment.getId())) { + return subComment; + } + } + } + + return null; } public boolean isEmpty() { - return children.isEmpty() - && ("" + author + title + content).trim().isEmpty(); + return children.isEmpty() && lines.isEmpty() + && ("" + author + title).trim().isEmpty(); } @Override