Mercurial Hosting > nabble
comparison src/nabble/naml/compiler/StringChunk.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 | |
4 final class StringChunk implements Chunk { | |
5 final String s; | |
6 | |
7 StringChunk(String s) { | |
8 if( s.length() == 0 ) | |
9 throw new RuntimeException("empty StringChunk"); | |
10 this.s = s; | |
11 } | |
12 | |
13 public void run(IPrintWriter out,RunState runState) { | |
14 out.print(s); | |
15 } | |
16 | |
17 public boolean hasOutput() { | |
18 return true; | |
19 } | |
20 | |
21 public String toString() { | |
22 return "{String: \""+s+"\"}"; | |
23 } | |
24 | |
25 @Override public boolean equals(Object obj) { | |
26 if( this==obj ) | |
27 return true; | |
28 if( !(obj instanceof StringChunk) ) | |
29 return false; | |
30 StringChunk sc = (StringChunk)obj; | |
31 return sc.s.equals(s); | |
32 } | |
33 | |
34 @Override public int hashCode() { | |
35 return s.hashCode() + getClass().hashCode(); | |
36 } | |
37 | |
38 @Override public Chunk intern() { | |
39 return interner.intern(this); | |
40 } | |
41 } |