package edu.neu.ccs.demeter; /** A terminal class for parsing a full line. Put Line in a class dictionary to represent a full line in an input sentence, terminated by line.separator (which is not included in the Line object). */ final public class Line implements java.io.Serializable { private String str; /** Construct an empty line. */ public Line() { str = ""; } /** Construct a Line from a String. Note that a Line created outside of the parser is not constrained to be a single line. */ public Line(String s) { str = s; } /** Construct a Line from an Object by converting it to a String with {@link Object#toString()}. Note that a Line created outside of the parser is not constrained to be a single line. */ public Line(Object obj) { str = obj.toString(); } public String toString() { return str; } public int hashCode() { return str.hashCode(); } public boolean equals(Object line) { return (line instanceof Line) && str.equals(((Line) line).str); } /** The line separator of the current JVM. It is initialized from the line.separator system property. @see System#getProperty(String, String) */ public static final String nl; static { String newline = "\n"; try { newline = System.getProperty("line.separator", newline); } catch (SecurityException e) { System.err.println(e); } nl = newline; } }