1    /*
2    Copyright 2000 by Ralph Hartley
3    This software is licenced under the terms of the
4    Gnu Public Licence
5    */
6    
7    /**A layer that includes all members of a class. */
8    public class LayerClass extends Layer {
9    
10     private static final long serialVersionUID = Version.getSUID();
11   
12     /**The class that this layer includes. */
13     Class memberclass;
14   
15     /**Build a layer including a class. */
16     LayerClass(Class cla) {
17       memberclass = cla;
18       name = cla.toString();
19       int place = name.lastIndexOf('.');
20       if (place>=0) name = name.substring(place+1);
21     }
22   
23     /**Build a layer including the class by name. */
24     LayerClass(String str) {
25       super(str);
26       try {
27         memberclass = Class.forName(str);
28       } catch (Exception ex) {ErrorLog.exception(ex,"Carto bug creating LayerClass");}
29       int place = name.lastIndexOf('.');
30       if (place>=0) name = name.substring(place+1);
31     }
32   
33     /**Make a copy of this Layer. */
34     public Object clone() {
35       return((Object)new LayerClass(memberclass));
36     }
37   
38     /**Copy the value of another ClassLayer into this. */
39     public void copy(FileDefaultable thatitem) {
40       super.copy(thatitem);
41       memberclass = ((LayerClass)thatitem).memberclass;
42     }
43   
44     /**Accept the object if it is a member of the right class. */
45     public boolean isMember(Object target) {
46       return(memberclass.isInstance(target));
47     }
48   }
49   
50