Mercurial Hosting > nabble
comparison src/nabble/naml/compiler/TemplatePrintWriter.java @ 0:7ecd1a4ef557
add content
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 Mar 2019 19:15:52 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:7ecd1a4ef557 |
---|---|
1 package nabble.naml.compiler; | |
2 | |
3 import java.io.Writer; | |
4 | |
5 | |
6 public class TemplatePrintWriter extends PrintWriter { | |
7 | |
8 public static final TemplatePrintWriter NULL = new TemplatePrintWriter( new Writer() { | |
9 public void write(char[] cbuf,int off,int len) {} | |
10 public void flush() {} | |
11 public void close() {} | |
12 } ); | |
13 | |
14 public TemplatePrintWriter(Writer out) { | |
15 super(out); | |
16 } | |
17 | |
18 public void print(Object obj) { | |
19 if( obj == null ) | |
20 throw new NamlNullPointerException("null written to stream"); | |
21 if( obj instanceof BlockWrapper ) { | |
22 ((BlockWrapper)obj).printTo(this); | |
23 } else { | |
24 super.print(obj); | |
25 } | |
26 } | |
27 | |
28 public void print(String s) { | |
29 if( s == null ) | |
30 throw new NamlNullPointerException("null written to stream"); | |
31 super.print(s); | |
32 } | |
33 | |
34 public void print(Boolean b) { | |
35 throw new RuntimeException("no Booleans allowed, use boolean instead"); | |
36 } | |
37 | |
38 } |