private String author;
private String title;
private String date;
- private String content;
+ private List<String> lines;
private List<Comment> children;
public Comment(String id, String author, String title, String date,
- String content) {
+ List<String> lines) {
this.id = id;
this.author = author;
this.title = title;
this.date = date;
- this.content = content;
+ this.lines = lines;
this.children = new ArrayList<Comment>();
}
/**
* @return the content
*/
- public String getContent() {
- return content;
+ public List<String> 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).isEmpty();
}
@Override