package edu.neu.ccs.demeter; /** A terminal class for parsing a block of arbitrary text. Put Text in a class dictionary to represent a block of text in an input sentence, surrounded by {@link #begin} and {@link #end}. */ final public class Text implements java.io.Serializable { private String str; /** Construct an empty text block. */ public Text() { str = ""; } /** Construct a Text from a String. */ public Text(String s) { str = s; } /** Construct a Text from an Object by converting it to a String with {@link Object#toString()}. */ public Text(Object obj) { str = obj.toString(); } /** The body of the text block, not including the {@link #begin} and {@link #end} markers. */ public String toString() { return str; } public int hashCode() { return str.hashCode(); } public boolean equals(Object text) { return (text instanceof Text) && str.equals(((Text) text).str); } /** The beginning marker for the text block in an input sentence. */ public static final String begin = "{{"; /** The end marker for the text block in an input sentence. */ public static final String end = "}}"; /** Java code for the end marker for the text block in an input sentence. */ public static final String quoted_end = "\"}\" + \"}\""; }