1 4 package gnu.mapping; 5 6 10 public class LocationProc extends Procedure0or1 implements HasSetter 11 { 12 Location loc; 13 14 public LocationProc (Location loc) 15 { 16 this.loc = loc; 17 } 18 19 public static LocationProc makeNamed (Symbol name, Location loc) 20 { 21 LocationProc lproc = new LocationProc(loc); 22 lproc.setSymbol(name); 23 return lproc; 24 } 25 26 public LocationProc (Location loc, Procedure converter) 27 { 28 this.loc = loc; 29 if (converter != null) 30 pushConverter(converter); 31 } 32 33 public void pushConverter (Procedure converter) 34 { 35 loc = ConstrainedLocation.make(loc, converter); 36 } 37 38 public Object apply0 () throws Throwable 39 { 40 return loc.get(); 41 } 42 43 public Object apply1 (Object value) throws Throwable 44 { 45 set0(value); 46 return Values.empty; 47 } 48 49 public void set0 (Object value) throws Throwable 50 { 51 loc.set(value); 52 } 53 54 public Procedure getSetter() 55 { 56 return new Setter0(this); 57 } 58 59 public final Location getLocation () 60 { 61 return loc; 62 } 63 64 public String toString () 65 { 66 Object n = getSymbol(); 67 if (n != null) 68 return super.toString(); 69 return "#<location-proc "+loc+">"; 70 } 71 } 72 | Popular Tags |