01: // Copyright (c) 2005 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.mapping;
05:
06: public class ReadOnlyLocation extends ConstrainedLocation {
07: public static ReadOnlyLocation make(Location base) {
08: ReadOnlyLocation rloc = new ReadOnlyLocation();
09: rloc.base = base;
10: return rloc;
11: }
12:
13: public boolean isConstant() {
14: return true;
15: }
16:
17: protected Object coerce(Object newValue) {
18: StringBuffer sbuf = new StringBuffer(
19: "attempt to modify read-only location");
20: Symbol name = getKeySymbol();
21: if (name != null) {
22: sbuf.append(": ");
23: sbuf.append(name);
24: }
25: throw new IllegalStateException(sbuf.toString());
26: }
27:
28: }
|