1 14 package org.wings.template; 15 16 import java.io.ByteArrayInputStream ; 17 import java.io.IOException ; 18 import java.io.InputStream ; 19 20 21 27 public class StringTemplateSource implements TemplateSource { 28 29 private static long COUNTER = 0; 30 31 private static final synchronized long getNextId() { 32 return COUNTER++; 33 } 34 35 38 private final String canonicalName = getClass().getName() + "_" + getNextId(); 39 40 private String template; 41 42 private long lastModified; 43 44 45 public StringTemplateSource() { 46 } 47 48 49 public StringTemplateSource(String template) { 50 setTemplate(template); 51 } 52 53 public final void setTemplate(String t) { 54 this.template = t; 55 lastModified = System.currentTimeMillis(); 56 } 57 58 60 public long lastModified() { 61 return lastModified; 62 } 63 64 public InputStream getInputStream() throws IOException { 65 return new ByteArrayInputStream (template.getBytes()); 66 } 67 68 public final String getCanonicalName() { 69 return canonicalName; 70 } 71 72 } 74 | Popular Tags |