root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.core / src / main / java / es / unex / sextante / core / ObjectAndDescription.java @ 315
History | View | Annotate | Download (2.25 KB)
1 |
package es.unex.sextante.core; |
---|---|
2 |
|
3 |
import javax.swing.Icon; |
4 |
|
5 |
public class ObjectAndDescription |
6 |
implements
|
7 |
Comparable {
|
8 |
|
9 |
private String m_sDescription; |
10 |
private Object m_Object; |
11 |
private Icon m_ObjectIcon; |
12 |
|
13 |
|
14 |
public ObjectAndDescription(final String sDescription, |
15 |
final Object object) { |
16 |
|
17 |
m_sDescription = sDescription; |
18 |
m_Object = object; |
19 |
m_ObjectIcon = null;
|
20 |
|
21 |
} |
22 |
|
23 |
public ObjectAndDescription(final String sDescription, |
24 |
final Object object, |
25 |
final Icon objectIcon) { |
26 |
|
27 |
m_sDescription = sDescription; |
28 |
m_Object = object; |
29 |
m_ObjectIcon = objectIcon; |
30 |
|
31 |
} |
32 |
|
33 |
public Object getObject() { |
34 |
|
35 |
return m_Object;
|
36 |
|
37 |
} |
38 |
|
39 |
|
40 |
public void setObject(final Object object) { |
41 |
|
42 |
m_Object = object; |
43 |
|
44 |
} |
45 |
|
46 |
|
47 |
public String getDescription() { |
48 |
|
49 |
return m_sDescription;
|
50 |
|
51 |
} |
52 |
|
53 |
|
54 |
public void setDescription(final String sDescription) { |
55 |
|
56 |
m_sDescription = sDescription; |
57 |
|
58 |
} |
59 |
|
60 |
public Icon getIcon() { |
61 |
|
62 |
return m_ObjectIcon;
|
63 |
|
64 |
} |
65 |
|
66 |
|
67 |
public void setIcon(final Icon objectIcon) { |
68 |
|
69 |
m_ObjectIcon = objectIcon; |
70 |
|
71 |
} |
72 |
|
73 |
@Override
|
74 |
public String toString() { |
75 |
|
76 |
return getDescription();
|
77 |
|
78 |
} |
79 |
|
80 |
|
81 |
public int compareTo(final Object arg0) { |
82 |
|
83 |
return getDescription().compareTo(((ObjectAndDescription) arg0).getDescription());
|
84 |
|
85 |
} |
86 |
|
87 |
|
88 |
@Override
|
89 |
public boolean equals(final Object ob) { |
90 |
|
91 |
if (ob == null) { |
92 |
return false; |
93 |
} |
94 |
|
95 |
try {
|
96 |
final ObjectAndDescription oad = (ObjectAndDescription) ob;
|
97 |
boolean bObjsEqual;
|
98 |
boolean bDescsEqual;
|
99 |
if (oad.getObject() == null) { |
100 |
bObjsEqual = m_Object == null;
|
101 |
} |
102 |
else {
|
103 |
bObjsEqual = oad.getObject().equals(m_Object); |
104 |
} |
105 |
if (oad.getDescription() == null) { |
106 |
bDescsEqual = m_sDescription == null;
|
107 |
} |
108 |
else {
|
109 |
bDescsEqual = oad.getDescription().equals(m_sDescription); |
110 |
} |
111 |
return bObjsEqual && bDescsEqual;
|
112 |
} |
113 |
catch (final Exception e) { |
114 |
return false; |
115 |
} |
116 |
|
117 |
} |
118 |
|
119 |
|
120 |
} |