private void collectBugs() { // Sort bugs by priority Collections.sort(mBugs, Bug.getComparator()); // Create error report String chapterName = "Errors"; int count = mBugs.size(); if (count > 0) { chapterName += " (" + count + ")"; } Chapter bugs = new Chapter(this, chapterName); if (count == 0) { bugs.add(new SimpleText("No errors were detected by ChkBugReport :-(")); } else { for (Bug bug : mBugs) { Chapter ch = new Chapter(this, bug.getName(), bug.getIcon()); ch.add(bug); bugs.addChapter(ch); } } // Insert error report as first chapter mDoc.insertChapter(1, bugs); // pos#0 = Header }