Mercurial Hosting > nabble
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/nabble/naml/compiler/StringChunk.java Thu Mar 21 19:15:52 2019 -0600 @@ -0,0 +1,41 @@ +package nabble.naml.compiler; + + +final class StringChunk implements Chunk { + final String s; + + StringChunk(String s) { + if( s.length() == 0 ) + throw new RuntimeException("empty StringChunk"); + this.s = s; + } + + public void run(IPrintWriter out,RunState runState) { + out.print(s); + } + + public boolean hasOutput() { + return true; + } + + public String toString() { + return "{String: \""+s+"\"}"; + } + + @Override public boolean equals(Object obj) { + if( this==obj ) + return true; + if( !(obj instanceof StringChunk) ) + return false; + StringChunk sc = (StringChunk)obj; + return sc.s.equals(s); + } + + @Override public int hashCode() { + return s.hashCode() + getClass().hashCode(); + } + + @Override public Chunk intern() { + return interner.intern(this); + } +}