/** * Returns a string representing the raw template * text in canonical form. */ @Override public String toString() { StringWriter sw = new StringWriter(); try { dump(sw); } catch (IOException ioe) { throw new RuntimeException(ioe.getMessage()); } return sw.toString(); }
static void convertFile(File f) throws IOException { File fullPath = f.getAbsoluteFile(); File dir = fullPath.getParentFile(); String filename = fullPath.getName(); File convertedFile = new File(dir, filename + ".canonical"); config.setDirectoryForTemplateLoading(dir); Template template = config.getTemplate(filename); FileWriter output = new FileWriter(convertedFile); try { template.dump(output); } finally { output.close(); } }
protected String content() throws IOException { final StringWriter writer = new StringWriter(); freemarkerTemplate.dump(writer); return writer.toString(); }
protected String content() throws IOException { final StringWriter writer = new StringWriter(); freemarkerTemplate.dump(writer); return writer.toString(); }
/** * Returns a string representing the raw template * text in canonical form. */ public String toString() { StringWriter sw = new StringWriter(); try { dump(sw); } catch (IOException ioe) { throw new RuntimeException(ioe.getMessage()); } return sw.toString(); }
/** * Returns a string representing the raw template * text in canonical form. */ @Override public String toString() { StringWriter sw = new StringWriter(); try { dump(sw); } catch (IOException ioe) { throw new RuntimeException(ioe.getMessage()); } return sw.toString(); }
/** * Returns a string representing the raw template * text in canonical form. */ @Override public String toString() { StringWriter sw = new StringWriter(); try { dump(sw); } catch (IOException ioe) { throw new RuntimeException(ioe.getMessage()); } return sw.toString(); }
static void convertFile(File f) throws IOException { File fullPath = f.getAbsoluteFile(); File dir = fullPath.getParentFile(); String filename = fullPath.getName(); File convertedFile = new File(dir, filename + ".canonical"); config.setDirectoryForTemplateLoading(dir); Template template = config.getTemplate(filename); FileWriter output = new FileWriter(convertedFile); try { template.dump(output); } finally { output.close(); } }
static void convertFile(File f) throws IOException { File fullPath = f.getAbsoluteFile(); File dir = fullPath.getParentFile(); String filename = fullPath.getName(); File convertedFile = new File(dir, filename + ".canonical"); config.setDirectoryForTemplateLoading(dir); Template template = config.getTemplate(filename); FileWriter output = new FileWriter(convertedFile); try { template.dump(output); } finally { output.close(); } }
static void convertFile(File f) throws IOException { File fullPath = f.getAbsoluteFile(); File dir = fullPath.getParentFile(); String filename = fullPath.getName(); File convertedFile = new File(dir, filename + ".canonical"); config.setDirectoryForTemplateLoading(dir); Template template = config.getTemplate(filename); FileWriter output = new FileWriter(convertedFile); try { template.dump(output); } finally { output.close(); } }
/** * Returns true if the required template is empty or has its default content * * @param featureType * @param template * @param lookup * @throws IOException */ public boolean isTemplateEmpty( SimpleFeatureType featureType, String template, Class<FeatureTemplate> lookup, String defaultContent) throws IOException { Template t = lookupTemplate(featureType, template, lookup); if (t == null) { return true; } // check if the template is empty StringWriter sw = new StringWriter(); t.dump(sw); // an empty template canonical form is "0\n".. weird! String templateText = sw.toString(); return "".equals(templateText) || (defaultContent != null && defaultContent.equals(templateText)); }