1 package kawa.lang; 2 import gnu.mapping.*; 3 import java.io.*; 4 import gnu.text.*; 5 import gnu.lists.Consumer; 6 7 10 11 public class EqualPat extends Pattern implements Printable, Externalizable 12 { 13 14 Object value; 15 16 public EqualPat () { } 17 18 public EqualPat (Object obj) { value = obj; } 19 20 static public EqualPat make (Object obj) { return new EqualPat (obj); } 21 22 public boolean match (Object obj, Object [] vars, int start_vars) 23 { 24 if (value instanceof String && obj instanceof Symbol) 27 obj = ((Symbol) obj).getName(); 28 return value.equals (obj); 29 } 30 31 public int varCount () { return 0; } 32 33 public void print (Consumer out) 34 { 35 out.write("#<equals: "); 36 ReportFormat.print(value, out); 37 out.write('>'); 38 } 39 40 43 public void writeExternal(ObjectOutput out) throws IOException 44 { 45 out.writeObject(value); 46 } 47 48 public void readExternal(ObjectInput in) 49 throws IOException, ClassNotFoundException 50 { 51 value = in.readObject(); 52 } 53 } 54 | Popular Tags |