X-Git-Url: http://git.nikiroo.be/?p=gofetch.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fgofetch%2Fdata%2FComment.java;h=bbd648a36a81be826af4b574b87f4a8db9137f53;hp=963d6aa6d6dffe427d5bab979fc20cd1790550e7;hb=72f39832a7b425003c1d717afcfb5a9cf7d3405b;hpb=90942239ab229fb01f757b22f494f0d95a4c0a69 diff --git a/src/be/nikiroo/gofetch/data/Comment.java b/src/be/nikiroo/gofetch/data/Comment.java index 963d6aa..bbd648a 100644 --- a/src/be/nikiroo/gofetch/data/Comment.java +++ b/src/be/nikiroo/gofetch/data/Comment.java @@ -65,6 +65,30 @@ public class Comment implements Iterable { 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() && lines.isEmpty() && ("" + author + title).trim().isEmpty();