1 4 package gnu.mapping; 5 6 7 8 public class ProcLocation extends Location 9 { 10 Procedure proc; 11 Object [] args; 12 13 public ProcLocation (Procedure proc, Object [] args) 14 { 15 this.proc = proc; 16 this.args = args; 17 } 18 19 public Object get (Object defaultValue) 20 { 21 try 22 { 23 return proc.applyN(args); 24 } 25 catch (RuntimeException ex) 26 { 27 throw ex; 28 } 29 catch (Error ex) 30 { 31 throw ex; 32 } 33 catch (Throwable ex) 34 { 35 throw new WrappedException(ex); 36 } 37 } 38 39 public void set (Object value) 40 { 41 int len = args.length; 42 Object [] xargs = new Object [len + 1]; 43 xargs[len] = value; 44 System.arraycopy(args, 0, xargs, 0, len); 45 try 46 { 47 proc.setN(xargs); 48 } 49 catch (RuntimeException ex) 50 { 51 throw ex; 52 } 53 catch (Error ex) 54 { 55 throw ex; 56 } 57 catch (Throwable ex) 58 { 59 throw new WrappedException(ex); 60 } 61 } 62 63 public boolean isBound () 64 { 65 return true; 66 } 67 } 68 69 | Popular Tags |