/**
   * Output the file model.
   *
   * @param w the output writer.
   * @throws IOException if there is a problem.
   */
  public void execute(PrintWriter w) throws IOException {
    this.w = w;
    w.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    w.println("<file");
    w.print(" ");
    w.println(XMLUtil.toAttribute("name", fileModel.getDisplayName()));
    w.print(" ");
    w.println(XMLUtil.toAttribute("last-modified", "" + fileModel.getLastModified()));
    if (fileModel.getSourceFile() != null) {
      w.print(" ");
      w.println(XMLUtil.toAttribute("file", fileModel.getSourceFile().getAbsolutePath()));
    }
    w.println(">");
    createLimited();
    if (fileModel.getSourceFile() != null && fileModel.getSourceFile().exists()) {
      try {
        outputContents();
      } finally {
        closeSourceFile();
      }
    }

    outputSummary();

    w.println("</file>");
  }
 private void printAttr(String name, Object value) throws IOException {
   if (value == null) {
     return;
   }
   w.print("   ");
   w.println(XMLUtil.toAttribute(name, value.toString()));
 }
 private void outputContents() throws IOException {
   sourceReader = new BufferedReader(open());
   int lineNumber = 1;
   while (true) {
     String line = sourceReader.readLine();
     if (line == null) {
       break;
     }
     if (!near(lineNumber)) {
       lineNumber++;
       continue;
     }
     w.print("  <line number='" + lineNumber + "'>");
     w.print(XMLUtil.escapeContent(line));
     w.println("</line>");
     lineNumber++;
   }
 }