1 package gnu.expr; 2 import gnu.text.Printable; 3 import java.io.*; 4 import gnu.lists.Consumer; 5 6 7 8 public class Special extends Object implements Printable, Externalizable 9 { 10 private String name; 11 12 public static final Special undefined = new Special("undefined"); 13 public static final Special optional = new Special("optional"); 14 public static final Special rest = new Special("rest"); 15 public static final Special key = new Special("key"); 16 public static final Special dfault = new Special("default"); 17 public static final Object eof = gnu.lists.Sequence.eofValue; 18 22 public Special () 23 { 24 } 25 26 private Special (String n) 27 { 28 name = new String (n); 29 } 30 31 public static Special make (String name) 32 { 33 if (name == "optional") return optional; 34 if (name == "rest") return rest; 35 if (name == "key") return key; 36 if (name == "default") return dfault; 37 return new Special(name); 38 } 39 40 public int hashCode () { return name.hashCode (); } 41 42 public final String toString() 43 { 44 return "#!" + name; 45 } 46 47 public void print (Consumer out) 48 { 49 out.write("#!"); 50 out.write(name); 51 } 52 53 56 57 public void writeExternal(ObjectOutput out) throws IOException 58 { 59 out.writeUTF(name); 60 } 61 62 public void readExternal(ObjectInput in) 63 throws IOException, ClassNotFoundException 64 { 65 name = in.readUTF(); 66 } 67 68 public Object readResolve() throws ObjectStreamException 69 { 70 return make(name); 71 } 72 } 73 | Popular Tags |