1 package free.util;
2 
3 
4 
5 /**
6  * Allows one to attach a name to an object. The name is also returned by the
7  * <code>toString</code> method, making this class useful for objects put into
8  * Swing container classes (<code>JTables</code> and such).
9  */
10 
11 public class NamedObject{
12 
13 
14 
15   /**
16    * The object.
17    */
18 
19   private final Object target;
20 
21 
22 
23   /**
24    * The name.
25    */
26 
27   private final String name;
28 
29 
30 
31   /**
32    * Creates a new <code>NamedObject</code> with the specified target and name.
33    */
34 
NamedObject(Object target, String name)35   public NamedObject(Object target, String name){
36     this.target = target;
37     this.name = name;
38   }
39 
40 
41 
42   /**
43    * Returns the target.
44    */
45 
getTarget()46   public Object getTarget(){
47     return target;
48   }
49 
50 
51 
52   /**
53    * Returns the name.
54    */
55 
getName()56   public String getName(){
57     return name;
58   }
59 
60 
61 
62   /**
63    * Returns the name.
64    */
65 
toString()66   public String toString(){
67     return getName();
68   }
69 
70 
71 
72 }
73