Coverage Report - com.sun.javafx.runtime.location.Locations
 
Classes in this File Line Coverage Branch Coverage Complexity
Locations
38%
9/24
100%
2/2
0
Locations$1
N/A
N/A
0
Locations$DoubleIntLocation
0%
0/22
N/A
0
Locations$DoubleIntLocation$1
0%
0/3
N/A
0
Locations$DoubleIntLocation$2
0%
0/3
N/A
0
Locations$IntDoubleLocation
32%
7/22
N/A
0
Locations$IntDoubleLocation$1
0%
0/3
N/A
0
Locations$IntDoubleLocation$2
0%
0/3
N/A
0
Locations$LocationWrapper
29%
6/21
N/A
0
Locations$ObjectBooleanLocation
0%
0/19
0%
0/2
0
Locations$ObjectBooleanLocation$1
0%
0/3
N/A
0
Locations$ObjectDoubleLocation
0%
0/21
0%
0/2
0
Locations$ObjectDoubleLocation$1
0%
0/3
N/A
0
Locations$ObjectDoubleLocation$2
0%
0/3
N/A
0
Locations$ObjectIntLocation
47%
9/19
100%
2/2
0
Locations$ObjectIntLocation$1
0%
0/3
N/A
0
Locations$UnmodifiableBooleanLocation
0%
0/18
N/A
0
Locations$UnmodifiableDoubleLocation
0%
0/18
N/A
0
Locations$UnmodifiableIntLocation
0%
0/18
N/A
0
Locations$UnmodifiableObjectLocation
0%
0/13
N/A
0
Locations$UnmodifiableSequenceLocation
0%
0/42
N/A
0
Locations$UpcastLocation
50%
6/12
N/A
0
Locations$UpcastLocation$1
0%
0/3
N/A
0
 
 1  
 package com.sun.javafx.runtime.location;
 2  
 
 3  
 import java.lang.ref.WeakReference;
 4  
 import java.util.Collection;
 5  
 import java.util.Iterator;
 6  
 
 7  
 import com.sun.javafx.runtime.sequence.Sequence;
 8  
 import com.sun.javafx.runtime.sequence.SequencePredicate;
 9  
 
 10  
 /**
 11  
  * Factory methods for wrapping Locations: unmodifiable locations, ObjectLocation-typed views of primitive locations, etc
 12  
  *
 13  
  * @author Brian Goetz
 14  
  */
 15  
 public class Locations {
 16  
     // non-instantiable
 17  0
     private Locations() {
 18  0
     }
 19  
 
 20  
     public static Location getUnderlyingLocation(Location loc) {
 21  106
         while (loc instanceof DynamicViewLocation)
 22  6
             loc = ((DynamicViewLocation) loc).getUnderlyingLocation();
 23  100
         return loc;
 24  
     }
 25  
 
 26  
     public static IntLocation constant(int value) {
 27  0
         return IntConstant.make(value);
 28  
     }
 29  
 
 30  
     public static DoubleLocation constant(double value) {
 31  0
         return DoubleConstant.make(value);
 32  
     }
 33  
 
 34  
     public static BooleanLocation constant(boolean value) {
 35  0
         return BooleanConstant.make(value);
 36  
     }
 37  
 
 38  
     public static<T> ObjectLocation<T> constant(T value) {
 39  0
         return ObjectConstant.make(value);
 40  
     }
 41  
 
 42  
     public static<T> SequenceLocation<T> constant(Sequence<T> value) {
 43  0
         return SequenceConstant.make(value);
 44  
     }
 45  
 
 46  
 
 47  
     public static ObjectLocation<Integer> asObjectLocation(IntLocation loc) {
 48  4
         return loc;
 49  
     }
 50  
 
 51  
     public static ObjectLocation<Double> asObjectLocation(DoubleLocation loc) {
 52  2
         return loc;
 53  
     }
 54  
 
 55  
     public static ObjectLocation<Boolean> asObjectLocation(BooleanLocation loc) {
 56  2
         return loc;
 57  
     }
 58  
 
 59  
     public static BooleanLocation asBooleanLocation(ObjectLocation<Boolean> loc) {
 60  0
         return new ObjectBooleanLocation(loc);
 61  
     }
 62  
 
 63  
     public static <T extends Number> DoubleLocation asDoubleLocation(ObjectLocation<T> loc) {
 64  0
         return new ObjectDoubleLocation<T>(loc);
 65  
     }
 66  
 
 67  
     public static DoubleLocation asDoubleLocation(IntLocation loc) {
 68  207
         return new IntDoubleLocation(loc);
 69  
     }
 70  
 
 71  
     public static IntLocation asIntLocation(DoubleLocation loc) {
 72  0
         return new DoubleIntLocation(loc);
 73  
     }
 74  
 
 75  
     public static IntLocation asIntLocation(ObjectLocation<Integer> loc) {
 76  10
         return new ObjectIntLocation(loc);
 77  
     }
 78  
 
 79  
     public static IntLocation unmodifiableLocation(IntLocation loc) {
 80  0
         return new UnmodifiableIntLocation(loc);
 81  
     }
 82  
 
 83  
     public static DoubleLocation unmodifiableLocation(DoubleLocation loc) {
 84  0
         return new UnmodifiableDoubleLocation(loc);
 85  
     }
 86  
 
 87  
     public static BooleanLocation unmodifiableLocation(BooleanLocation loc) {
 88  0
         return new UnmodifiableBooleanLocation(loc);
 89  
     }
 90  
 
 91  
     public static <T> ObjectLocation<T> unmodifiableLocation(ObjectLocation<T> loc) {
 92  0
         return new UnmodifiableObjectLocation<T>(loc);
 93  
     }
 94  
 
 95  
     public static <T> SequenceLocation<T> unmodifiableLocation(SequenceLocation<T> loc) {
 96  0
         return new UnmodifiableSequenceLocation<T>(loc);
 97  
     }
 98  
 
 99  
     /**
 100  
      * Return a wrapping location that mirrors the underlying Location but upcasts its type
 101  
      * @param clazz  Really Class<V> but because of generics limitations this cannot be declared
 102  
      * @param loc Location to wrap
 103  
      * @return
 104  
      */
 105  
     public static<T, V extends T> ObjectLocation<T> upcast(Class clazz, ObjectLocation<V> loc) {
 106  43
         return new UpcastLocation<T, V>((Class<V>)clazz, loc);
 107  
     }
 108  
 
 109  520
     private static abstract class LocationWrapper implements Location {
 110  
         protected abstract Location getLocation();
 111  
 
 112  
         public boolean isValid() {
 113  2
             return getLocation().isValid();
 114  
         }
 115  
 
 116  
         public boolean isNull() {
 117  0
             return getLocation().isNull();
 118  
         }
 119  
 
 120  
         public boolean isMutable() {
 121  0
             return getLocation().isMutable();
 122  
         }
 123  
 
 124  
         public void invalidate() {
 125  0
             getLocation().invalidate();
 126  0
         }
 127  
 
 128  
         public void update() {
 129  0
             getLocation().update();
 130  0
         }
 131  
 
 132  
         public void addChangeListener(ChangeListener listener) {
 133  1
             getLocation().addChangeListener(listener);
 134  1
         }
 135  
 
 136  
         public void addWeakListener(ChangeListener listener) {
 137  0
             getLocation().addWeakListener(listener);
 138  0
         }
 139  
 
 140  
         public Collection<ChangeListener> getListeners() {
 141  0
             return getLocation().getListeners();
 142  
         }
 143  
 
 144  
         public void addDependencies(Location... location) {
 145  0
             getLocation().addDependencies(location);
 146  0
         }
 147  
 
 148  
         public void addDynamicDependency(Location location) {
 149  0
             getLocation().addDynamicDependency(location);
 150  0
         }
 151  
 
 152  
         public void clearDynamicDependencies() {
 153  0
             getLocation().clearDynamicDependencies();
 154  0
         }
 155  
 
 156  
         public void addDependentLocation(WeakReference<Location> location) {
 157  256
             getLocation().addDependentLocation(location);
 158  256
         }
 159  
     }
 160  
 
 161  
     /**
 162  
      * Wrapper class that creates a DoubleLocation view of an IntLocation
 163  
      */
 164  206
     private static class IntDoubleLocation extends LocationWrapper implements DoubleLocation, StaticViewLocation {
 165  
         private final IntLocation location;
 166  
 
 167  
         protected IntLocation getLocation() {
 168  206
             return location;
 169  
         }
 170  
 
 171  207
         public IntDoubleLocation(IntLocation location) {
 172  207
             this.location = location;
 173  207
         }
 174  
 
 175  
         public double getAsDouble() {
 176  221
             return location.getAsInt();
 177  
         }
 178  
 
 179  
         public void addChangeListener(IntChangeListener listener) {
 180  0
             location.addChangeListener(listener);
 181  0
         }
 182  
 
 183  
         public Double get() {
 184  0
             return getAsDouble();
 185  
         }
 186  
 
 187  
         public double setAsDouble(double value) {
 188  0
             throw new UnsupportedOperationException();
 189  
         }
 190  
 
 191  
         public double setAsDoubleFromLiteral(double value) {
 192  0
             throw new UnsupportedOperationException();
 193  
         }
 194  
 
 195  
         public void setDefault() {
 196  0
             throw new UnsupportedOperationException();
 197  
         }
 198  
 
 199  
         public Double set(Double value) {
 200  0
             throw new UnsupportedOperationException();
 201  
         }
 202  
 
 203  
         public Double setFromLiteral(Double value) {
 204  0
             throw new UnsupportedOperationException();
 205  
         }
 206  
 
 207  
         public Location getUnderlyingLocation() {
 208  2
             return location;
 209  
         }
 210  
 
 211  
         public void addChangeListener(final DoubleChangeListener listener) {
 212  0
             location.addChangeListener(new IntChangeListener() {
 213  
                 public void onChange(int oldValue, int newValue) {
 214  0
                     listener.onChange(oldValue, newValue);
 215  0
                 }
 216  
             });
 217  0
         }
 218  
 
 219  
         public void addChangeListener(final ObjectChangeListener<Double> listener) {
 220  0
             location.addChangeListener(new IntChangeListener() {
 221  
                 public void onChange(int oldValue, int newValue) {
 222  0
                     listener.onChange((double) oldValue, (double) newValue);
 223  0
                 }
 224  
             });
 225  0
         }
 226  
 
 227  
         public int getAsInt() {
 228  0
             return location.getAsInt();
 229  
         }
 230  
 
 231  
         public int setAsInt(int value) {
 232  0
             return location.setAsInt(value);
 233  
         }
 234  
 
 235  
         public int setAsIntFromDefault(int value) {
 236  0
             return location.setAsIntFromLiteral(value);
 237  
         }
 238  
     }
 239  
 
 240  
 
 241  17
     private static class ObjectIntLocation extends LocationWrapper implements IntLocation, StaticViewLocation {
 242  
         private final ObjectLocation<Integer> location;
 243  
 
 244  10
         private ObjectIntLocation(ObjectLocation<Integer> location) {
 245  10
             this.location = location;
 246  10
         }
 247  
 
 248  
         protected Location getLocation() {
 249  11
             return location;
 250  
         }
 251  
 
 252  
         public int getAsInt() {
 253  30
             Integer val = location.get();
 254  30
             return val==null? 0 : val;
 255  
         }
 256  
 
 257  
         public int setAsInt(int value) {
 258  1
             return location.set(value);
 259  
         }
 260  
 
 261  
         public int setAsIntFromLiteral(int value) {
 262  0
             return location.setFromLiteral(value);
 263  
         }
 264  
 
 265  
         public void setDefault() {
 266  0
             location.setDefault();
 267  0
         }
 268  
 
 269  
         public void addChangeListener(final IntChangeListener listener) {
 270  0
             location.addChangeListener(new ObjectChangeListener<Integer>() {
 271  
                 public void onChange(Integer oldValue, Integer newValue) {
 272  0
                     listener.onChange(oldValue, newValue);
 273  0
                 }
 274  
             });
 275  0
         }
 276  
 
 277  
         public Integer get() {
 278  7
             return location.get();
 279  
         }
 280  
 
 281  
         public Integer set(Integer value) {
 282  0
             return location.set(value);
 283  
         }
 284  
 
 285  
         public Integer setFromLiteral(Integer value) {
 286  0
             return location.setFromLiteral(value);
 287  
         }
 288  
 
 289  
         public void addChangeListener(ObjectChangeListener<Integer> listener) {
 290  0
             location.addChangeListener(listener);
 291  0
         }
 292  
 
 293  
         public Location getUnderlyingLocation() {
 294  0
             return location;
 295  
         }
 296  
     }
 297  
 
 298  0
     private static class ObjectDoubleLocation<T extends Number> extends LocationWrapper implements DoubleLocation, StaticViewLocation {
 299  
         private final ObjectLocation<T> location;
 300  
 
 301  0
         private ObjectDoubleLocation(ObjectLocation<T> location) {
 302  0
             this.location = location;
 303  0
         }
 304  
 
 305  
         protected Location getLocation() {
 306  0
             return location;
 307  
         }
 308  
 
 309  
         public double getAsDouble() {
 310  0
             T val = location.get();
 311  0
             return val==null? 0.0 : val.doubleValue();
 312  
         }
 313  
 
 314  
         public double setAsDouble(double value) {
 315  
             // return location.set(value);
 316  0
             throw new UnsupportedOperationException();
 317  
         }
 318  
 
 319  
         public double setAsDoubleFromLiteral(double value) {
 320  
             // return location.setFromLiteral(value);
 321  0
             throw new UnsupportedOperationException();
 322  
         }
 323  
 
 324  
         public void setDefault() {
 325  0
             location.setDefault();
 326  0
         }
 327  
 
 328  
         public void addChangeListener(final DoubleChangeListener listener) {
 329  0
             location.addChangeListener(new ObjectChangeListener<T>() {
 330  
                 public void onChange(T oldValue, T newValue) {
 331  0
                     listener.onChange(oldValue.doubleValue(), newValue.doubleValue());
 332  0
                 }
 333  
             });
 334  0
         }
 335  
 
 336  
         public Double get() {
 337  0
             return getAsDouble();
 338  
         }
 339  
 
 340  
         public T set(T value) {
 341  0
             return location.set(value);
 342  
         }
 343  
 
 344  
         public T setFromLiteral(T value) {
 345  0
             return location.setFromLiteral(value);
 346  
         }
 347  
 
 348  
         public Double set(Double value) {
 349  
             // return location.set(value);
 350  0
             throw new UnsupportedOperationException();
 351  
         }
 352  
 
 353  
         public Double setFromLiteral(Double value) {
 354  
             // return location.setFromLiteral(value);
 355  0
             throw new UnsupportedOperationException();
 356  
         }
 357  
 
 358  
         public void addChangeListener(final ObjectChangeListener<Double> listener) {
 359  0
             location.addChangeListener(new ObjectChangeListener<T>() {
 360  
                 public void onChange(T oldValue, T newValue) {
 361  0
                     listener.onChange(oldValue.doubleValue(), newValue.doubleValue());
 362  0
                 }
 363  
             });
 364  0
         }
 365  
 
 366  
         public Location getUnderlyingLocation() {
 367  0
             return location;
 368  
         }
 369  
     }
 370  
 
 371  0
     private static class ObjectBooleanLocation extends LocationWrapper implements BooleanLocation, StaticViewLocation {
 372  
         private final ObjectLocation<Boolean> location;
 373  
 
 374  0
         private ObjectBooleanLocation(ObjectLocation<Boolean> location) {
 375  0
             this.location = location;
 376  0
         }
 377  
 
 378  
         protected Location getLocation() {
 379  0
             return location;
 380  
         }
 381  
 
 382  
         public boolean getAsBoolean() {
 383  0
             Boolean val = location.get();
 384  0
             return val==null? false : val;
 385  
         }
 386  
 
 387  
         public boolean setAsBoolean(boolean value) {
 388  0
             return location.set(value);
 389  
         }
 390  
 
 391  
         public boolean setAsBooleanFromLiteral(boolean value) {
 392  0
             return location.setFromLiteral(value);
 393  
         }
 394  
 
 395  
         public void setDefault() {
 396  0
             location.setDefault();
 397  0
         }
 398  
 
 399  
         public void addChangeListener(final BooleanChangeListener listener) {
 400  0
             location.addChangeListener(new ObjectChangeListener<Boolean>() {
 401  
                 public void onChange(Boolean oldValue, Boolean newValue) {
 402  0
                     listener.onChange(oldValue, newValue);
 403  0
                 }
 404  
             });
 405  0
         }
 406  
 
 407  
         public Boolean get() {
 408  0
             return location.get();
 409  
         }
 410  
 
 411  
         public Boolean set(Boolean value) {
 412  0
             return location.set(value);
 413  
         }
 414  
 
 415  
         public Boolean setFromLiteral(Boolean value) {
 416  0
             return location.setFromLiteral(value);
 417  
         }
 418  
 
 419  
         public void addChangeListener(ObjectChangeListener<Boolean> listener) {
 420  0
             location.addChangeListener(listener);
 421  0
         }
 422  
 
 423  
         public Location getUnderlyingLocation() {
 424  0
             return location;
 425  
         }
 426  
     }
 427  
 
 428  
 
 429  
     /**
 430  
      * Wrapper class that creates an IntLocation view of a DoubleLocation
 431  
      */
 432  0
     private static class DoubleIntLocation extends LocationWrapper implements IntLocation, StaticViewLocation {
 433  
         private final DoubleLocation location;
 434  
 
 435  
         protected DoubleLocation getLocation() {
 436  0
             return location;
 437  
         }
 438  
 
 439  0
         public DoubleIntLocation(DoubleLocation location) {
 440  0
             this.location = location;
 441  0
         }
 442  
 
 443  
         public int getAsInt() {
 444  0
             return (int)location.getAsDouble();
 445  
         }
 446  
 
 447  
         public void addChangeListener(DoubleChangeListener listener) {
 448  0
             location.addChangeListener(listener);
 449  0
         }
 450  
 
 451  
         public Integer get() {
 452  0
             return getAsInt();
 453  
         }
 454  
 
 455  
         public int setAsInt(int value) {
 456  0
             throw new UnsupportedOperationException();
 457  
         }
 458  
 
 459  
         public int setAsIntFromLiteral(int value) {
 460  0
             throw new UnsupportedOperationException();
 461  
         }
 462  
 
 463  
         public void setDefault() {
 464  0
             throw new UnsupportedOperationException();
 465  
         }
 466  
 
 467  
         public Integer set(Integer value) {
 468  0
             throw new UnsupportedOperationException();
 469  
         }
 470  
 
 471  
         public Integer setFromLiteral(Integer value) {
 472  0
             throw new UnsupportedOperationException();
 473  
         }
 474  
 
 475  
         public Location getUnderlyingLocation() {
 476  0
             return location;
 477  
         }
 478  
 
 479  
         public void addChangeListener(final IntChangeListener listener) {
 480  0
             location.addChangeListener(new DoubleChangeListener() {
 481  
                 public void onChange(double oldValue, double newValue) {
 482  0
                     listener.onChange((int)oldValue, (int)newValue);
 483  0
                 }
 484  
             });
 485  0
         }
 486  
 
 487  
         public void addChangeListener(final ObjectChangeListener<Integer> listener) {
 488  0
             location.addChangeListener(new DoubleChangeListener() {
 489  
                 public void onChange(double oldValue, double newValue) {
 490  0
                     listener.onChange((int) oldValue, (int) newValue);
 491  0
                 }
 492  
             });
 493  0
         }
 494  
 
 495  
         public double getAsDouble() {
 496  0
             return location.getAsDouble();
 497  
         }
 498  
 
 499  
         public double setAsDouble(double value) {
 500  0
             return location.setAsDouble(value);
 501  
         }
 502  
 
 503  
         public double setAsDoubleFromDefault(double value) {
 504  0
             return location.setAsDoubleFromLiteral(value);
 505  
         }
 506  
     }
 507  
 
 508  
     /**
 509  
      * Wrapper class that wraps an IntLocation so it cannot be modified
 510  
      */
 511  0
     private static class UnmodifiableIntLocation extends LocationWrapper implements IntLocation {
 512  
         private final IntLocation location;
 513  
 
 514  
         protected Location getLocation() {
 515  0
             return location;
 516  
         }
 517  
 
 518  0
         public UnmodifiableIntLocation(IntLocation location) {
 519  0
             this.location = location;
 520  0
         }
 521  
 
 522  
         public boolean isMutable() {
 523  0
             return false;
 524  
         }
 525  
 
 526  
         public int getAsInt() {
 527  0
             return location.getAsInt();
 528  
         }
 529  
 
 530  
         public Integer get() {
 531  0
             return getAsInt();
 532  
         }
 533  
 
 534  
         public void addChangeListener(IntChangeListener listener) {
 535  0
             location.addChangeListener(listener);
 536  0
         }
 537  
 
 538  
         public void addChangeListener(ObjectChangeListener<Integer> listener) {
 539  0
             location.addChangeListener(listener);
 540  0
         }
 541  
 
 542  
         public int setAsInt(int value) {
 543  0
             throw new UnsupportedOperationException();
 544  
         }
 545  
 
 546  
         public int setAsIntFromLiteral(int value) {
 547  0
             throw new UnsupportedOperationException();
 548  
         }
 549  
 
 550  
         public void setDefault() {
 551  0
             throw new UnsupportedOperationException();
 552  
         }
 553  
 
 554  
         public Integer set(Integer value) {
 555  0
             throw new UnsupportedOperationException();
 556  
         }
 557  
 
 558  
         public Integer setFromLiteral(Integer value) {
 559  0
             throw new UnsupportedOperationException();
 560  
         }
 561  
 
 562  
         public void invalidate() {
 563  0
             throw new UnsupportedOperationException();
 564  
         }
 565  
     }
 566  
 
 567  
 
 568  
     /**
 569  
      * Wrapper class that wraps a DoubleLocation so it cannot be modified
 570  
      */
 571  0
     private static class UnmodifiableDoubleLocation extends LocationWrapper implements DoubleLocation {
 572  
         private final DoubleLocation location;
 573  
 
 574  
         protected Location getLocation() {
 575  0
             return location;
 576  
         }
 577  
 
 578  0
         public UnmodifiableDoubleLocation(DoubleLocation location) {
 579  0
             this.location = location;
 580  0
         }
 581  
 
 582  
         public boolean isMutable() {
 583  0
             return false;
 584  
         }
 585  
 
 586  
         public double getAsDouble() {
 587  0
             return location.getAsDouble();
 588  
         }
 589  
 
 590  
         public Double get() {
 591  0
             return getAsDouble();
 592  
         }
 593  
 
 594  
         public void addChangeListener(DoubleChangeListener listener) {
 595  0
             location.addChangeListener(listener);
 596  0
         }
 597  
 
 598  
         public void addChangeListener(ObjectChangeListener<Double> listener) {
 599  0
             location.addChangeListener(listener);
 600  0
         }
 601  
 
 602  
         public double setAsDouble(double value) {
 603  0
             throw new UnsupportedOperationException();
 604  
         }
 605  
 
 606  
         public double setAsDoubleFromLiteral(double value) {
 607  0
             throw new UnsupportedOperationException();
 608  
         }
 609  
 
 610  
         public void setDefault() {
 611  0
             throw new UnsupportedOperationException();
 612  
         }
 613  
 
 614  
         public Double set(Double value) {
 615  0
             throw new UnsupportedOperationException();
 616  
         }
 617  
 
 618  
         public Double setFromLiteral(Double value) {
 619  0
             throw new UnsupportedOperationException();
 620  
         }
 621  
 
 622  
         public void invalidate() {
 623  0
             throw new UnsupportedOperationException();
 624  
         }
 625  
     }
 626  
 
 627  
 
 628  
     /**
 629  
      * Wrapper class that wraps a BooleanLocation so it cannot be modified
 630  
      */
 631  0
     private static class UnmodifiableBooleanLocation extends LocationWrapper implements BooleanLocation {
 632  
         private final BooleanLocation location;
 633  
 
 634  
         protected Location getLocation() {
 635  0
             return location;
 636  
         }
 637  
 
 638  0
         public UnmodifiableBooleanLocation(BooleanLocation location) {
 639  0
             this.location = location;
 640  0
         }
 641  
 
 642  
         public boolean isMutable() {
 643  0
             return false;
 644  
         }
 645  
 
 646  
         public boolean getAsBoolean() {
 647  0
             return location.getAsBoolean();
 648  
         }
 649  
 
 650  
         public Boolean get() {
 651  0
             return getAsBoolean();
 652  
         }
 653  
 
 654  
         public void addChangeListener(BooleanChangeListener listener) {
 655  0
             location.addChangeListener(listener);
 656  0
         }
 657  
 
 658  
         public void addChangeListener(ObjectChangeListener<Boolean> listener) {
 659  0
             location.addChangeListener(listener);
 660  0
         }
 661  
 
 662  
         public boolean setAsBoolean(boolean value) {
 663  0
             throw new UnsupportedOperationException();
 664  
         }
 665  
 
 666  
         public boolean setAsBooleanFromLiteral(boolean value) {
 667  0
             throw new UnsupportedOperationException();
 668  
         }
 669  
 
 670  
         public void setDefault() {
 671  0
             throw new UnsupportedOperationException();
 672  
         }
 673  
 
 674  
         public Boolean set(Boolean value) {
 675  0
             throw new UnsupportedOperationException();
 676  
         }
 677  
 
 678  
         public Boolean setFromLiteral(Boolean value) {
 679  0
             throw new UnsupportedOperationException();
 680  
         }
 681  
 
 682  
         public void invalidate() {
 683  0
             throw new UnsupportedOperationException();
 684  
         }
 685  
     }
 686  
 
 687  
     /**
 688  
      * Wrapper class that wraps an ObjectLocation so it cannot be modified
 689  
      */
 690  0
     private static class UnmodifiableObjectLocation<T> extends LocationWrapper implements ObjectLocation<T> {
 691  
         private final ObjectLocation<T> location;
 692  
 
 693  0
         public UnmodifiableObjectLocation(ObjectLocation<T> location) {
 694  0
             this.location = location;
 695  0
         }
 696  
 
 697  
         public ObjectLocation<T> getLocation() {
 698  0
             return location;
 699  
         }
 700  
 
 701  
         public boolean isMutable() {
 702  0
             return false;
 703  
         }
 704  
 
 705  
         public T get() {
 706  0
             return location.get();
 707  
         }
 708  
 
 709  
         public T set(T value) {
 710  0
             throw new UnsupportedOperationException();
 711  
         }
 712  
 
 713  
         public T setFromLiteral(T value) {
 714  0
             throw new UnsupportedOperationException();
 715  
         }
 716  
 
 717  
         public void setDefault() {
 718  0
             throw new UnsupportedOperationException();
 719  
         }
 720  
 
 721  
         public void addChangeListener(ObjectChangeListener<T> listener) {
 722  0
             location.addChangeListener(listener);
 723  0
         }
 724  
 
 725  
         public void invalidate() {
 726  0
             throw new UnsupportedOperationException();
 727  
         }
 728  
     }
 729  
 
 730  
     private static class UpcastLocation<T, V extends T> extends LocationWrapper implements ObjectLocation<T> {
 731  
         private final ObjectLocation<V> location;
 732  
         private final Class<V> clazz;
 733  
 
 734  43
         public UpcastLocation(Class<V> clazz, ObjectLocation<V> location) {
 735  43
             this.location = location;
 736  43
             this.clazz = clazz;
 737  43
         }
 738  
 
 739  
         protected Location getLocation() {
 740  42
             return location;
 741  
         }
 742  
 
 743  
         public V get() {
 744  52
             return location.get();
 745  
         }
 746  
 
 747  
         public V set(T value) {
 748  0
             return location.set(clazz.cast(value));
 749  
         }
 750  
 
 751  
         public T setFromLiteral(T value) {
 752  0
             return location.setFromLiteral(clazz.cast(value));
 753  
         }
 754  
 
 755  
         public void setDefault() {
 756  0
             location.setDefault();
 757  0
         }
 758  
 
 759  
         public void addChangeListener(final ObjectChangeListener<T> listener) {
 760  0
             location.addChangeListener(new ObjectChangeListener<V>() {
 761  
                 public void onChange(V oldValue, V newValue) {
 762  0
                     listener.onChange(oldValue, newValue);
 763  0
                 }
 764  
             });
 765  0
         }
 766  
     }
 767  
 
 768  
     /**
 769  
      * Wrapper class that wraps a SequenceLocation so it cannot be modified
 770  
      */
 771  0
     private static class UnmodifiableSequenceLocation<T> extends LocationWrapper implements SequenceLocation<T> {
 772  
         private final SequenceLocation<T> location;
 773  
 
 774  0
         public UnmodifiableSequenceLocation(SequenceLocation<T> location) {
 775  0
             this.location = location;
 776  0
         }
 777  
 
 778  
         public SequenceLocation<T> getLocation() {
 779  0
             return location;
 780  
         }
 781  
 
 782  
         public void invalidate() {
 783  0
             throw new UnsupportedOperationException();
 784  
         }
 785  
 
 786  
         public boolean isMutable() {
 787  0
             return false;
 788  
         }
 789  
 
 790  
         public T get(int position) {
 791  0
             return location.get(position);
 792  
         }
 793  
 
 794  
         public Sequence<T> getAsSequence() {
 795  0
             return location.getAsSequence();
 796  
         }
 797  
 
 798  
         public Sequence<T> get() {
 799  0
             return location.get();
 800  
         }
 801  
 
 802  
         public Sequence<T> set(Sequence<T> value) {
 803  0
             throw new UnsupportedOperationException();
 804  
         }
 805  
 
 806  
         public Sequence<T> setFromLiteral(Sequence<T> value) {
 807  0
             throw new UnsupportedOperationException();
 808  
         }
 809  
 
 810  
         public void setDefault() {
 811  0
             throw new UnsupportedOperationException();
 812  
         }
 813  
 
 814  
         public Iterator<T> iterator() {
 815  
             // @@@ Wrap iterator with unmodifiable iterator
 816  0
             return location.iterator();
 817  
         }
 818  
 
 819  
         public Sequence<T> setAsSequence(Sequence<? extends T> value) {
 820  0
             throw new UnsupportedOperationException();
 821  
         }
 822  
 
 823  
         public Sequence<T> setAsSequenceFromLiteral(Sequence<? extends T> value) {
 824  0
             throw new UnsupportedOperationException();
 825  
         }
 826  
 
 827  
         public void addChangeListener(ObjectChangeListener<Sequence<T>> listener) {
 828  0
             location.addChangeListener(listener);
 829  0
         }
 830  
 
 831  
         public void addChangeListener(SequenceChangeListener<T> sequenceChangeListener) {
 832  0
             location.addChangeListener(sequenceChangeListener);
 833  0
         }
 834  
 
 835  
         public void removeChangeListener(SequenceChangeListener<T> sequenceChangeListener) {
 836  0
             location.removeChangeListener(sequenceChangeListener);
 837  0
         }
 838  
 
 839  
         public T set(int position, T value) {
 840  0
             throw new UnsupportedOperationException();
 841  
         }
 842  
 
 843  
         @Override
 844  
         public Sequence<T> getSlice(int startPos, int endPos) {
 845  0
             return getAsSequence().getSlice(startPos, endPos);
 846  
         }
 847  
 
 848  
         public Sequence<? extends T> replaceSlice(int startPos, int endPos, Sequence<? extends T> newValues) {
 849  0
             throw new UnsupportedOperationException();
 850  
         }
 851  
 
 852  
         public void delete(int position) {
 853  0
             throw new UnsupportedOperationException();
 854  
         }
 855  
 
 856  
         public void deleteSlice(int startPos, int endPos) {
 857  0
             throw new UnsupportedOperationException();
 858  
         }
 859  
 
 860  
         public void deleteAll() {
 861  0
             throw new UnsupportedOperationException();
 862  
         }
 863  
 
 864  
         public void deleteValue(T value) {
 865  0
             throw new UnsupportedOperationException();
 866  
         }
 867  
 
 868  
         public void delete(SequencePredicate<T> sequencePredicate) {
 869  0
             throw new UnsupportedOperationException();
 870  
         }
 871  
 
 872  
         public void insert(T value) {
 873  0
             throw new UnsupportedOperationException();
 874  
         }
 875  
 
 876  
         public void insert(Sequence<? extends T> values) {
 877  0
             throw new UnsupportedOperationException();
 878  
         }
 879  
 
 880  
         public void insertFirst(T value) {
 881  0
             throw new UnsupportedOperationException();
 882  
         }
 883  
 
 884  
         public void insertFirst(Sequence<? extends T> values) {
 885  0
             throw new UnsupportedOperationException();
 886  
         }
 887  
 
 888  
         public void insertBefore(T value, int position) {
 889  0
             throw new UnsupportedOperationException();
 890  
         }
 891  
 
 892  
         public void insertBefore(T value, SequencePredicate<T> sequencePredicate) {
 893  0
             throw new UnsupportedOperationException();
 894  
         }
 895  
 
 896  
         public void insertBefore(Sequence<? extends T> values, int position) {
 897  0
             throw new UnsupportedOperationException();
 898  
         }
 899  
 
 900  
         public void insertBefore(Sequence<? extends T> values, SequencePredicate<T> sequencePredicate) {
 901  0
             throw new UnsupportedOperationException();
 902  
         }
 903  
 
 904  
         public void insertAfter(T value, int position) {
 905  0
             throw new UnsupportedOperationException();
 906  
         }
 907  
 
 908  
         public void insertAfter(T value, SequencePredicate<T> sequencePredicate) {
 909  0
             throw new UnsupportedOperationException();
 910  
         }
 911  
 
 912  
         public void insertAfter(Sequence<? extends T> values, int position) {
 913  0
             throw new UnsupportedOperationException();
 914  
         }
 915  
 
 916  
         public void insertAfter(Sequence<? extends T> values, SequencePredicate<T> sequencePredicate) {
 917  0
             throw new UnsupportedOperationException();
 918  
         }
 919  
     }
 920  
 }