KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > mapping > ReadOnlyLocation


1 // Copyright (c) 2005 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.mapping;
5
6 public class ReadOnlyLocation extends ConstrainedLocation
7 {
8   public static ReadOnlyLocation make (Location base)
9   {
10     ReadOnlyLocation rloc = new ReadOnlyLocation();
11     rloc.base = base;
12     return rloc;
13   }
14
15   public boolean isConstant ()
16   {
17     return true;
18   }
19
20   protected Object JavaDoc coerce (Object JavaDoc newValue)
21   {
22     StringBuffer JavaDoc sbuf
23       = new StringBuffer JavaDoc("attempt to modify read-only location");
24     Symbol name = getKeySymbol();
25     if (name != null)
26       {
27     sbuf.append(": ");
28     sbuf.append(name);
29       }
30     throw new IllegalStateException JavaDoc(sbuf.toString());
31   }
32
33 }
34
Popular Tags