public class GenericItemParser implements ItemParser {
public Item parse(String line) {
//The content of the todo, e.g. "Refactor" in TODO Refactor
String content = "";
Item item = new Item();
//TODO: this was a "simplest implementation" quick hack; make this more scalable and elegant
// It allowed me to unit test and prove it was possible, but it's not brilliant!
//We do tests on the upper-case lines, so we include lower case TODOs or FIXMEs;
//The substrings, however, are performed on the original line so the comments case is preserved
String upperCaseLine = line.toUpperCase();
if (upperCaseLine.contains("TODO")) {
item.setType(Item.ItemType.TODO);
content = line.substring(upperCaseLine.indexOf("TODO") + 4);
} else if (upperCaseLine.contains("FIXME")) {
item.setType(Item.ItemType.FIXME);
content = line.substring(upperCaseLine.indexOf("FIXME") + 5);
}
item.setContent(content);
return item;
}