/** * 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())); }