source: trunk/gli/src/org/greenstone/gatherer/cdm/ElementWrapper.java@ 6540

Last change on this file since 6540 was 5590, checked in by mdewsnip, 21 years ago

Could it be I've finished adding tooltips?? Why yes, very nearly... and a big "hallelulah" for that.

  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1package org.greenstone.gatherer.cdm;
2
3import org.greenstone.gatherer.msm.MSMUtils;
4import org.w3c.dom.*;
5/** For even more confusion this class provides a convience wrapper around an element, to allow it to appear in the <strong>JList</strong> with both name and description. However this class has nothing to do with its namesake.
6 * @see org.greenstone.gatherer.msm.ElementWrapper
7 */
8public class ElementWrapper
9 implements Comparable {
10 /** The element as the data from this object. */
11 private Node element = null;
12 /** Constructor.
13 * @param element The <strong>Node</strong> this object is wrapped around.
14 */
15 public ElementWrapper(Node element) {
16 this.element = element;
17 }
18 /** Compare two objects for ordering.
19 * @param object The other <strong>Object</strong> to compare to.
20 * @return An <i>int</i> indicating the ordering as is String.compareTo
21 */
22 public int compareTo(Object object) {
23 if(object == null) {
24 return 1;
25 }
26 return toString().compareTo(object.toString());
27 }
28 /** Compare two objects for equality.
29 * @param object The <strong>Object</strong> to compare to.
30 * @return <i>true</i> if the objects are equal, <i>false</i> otherwise.
31 */
32 public boolean equals(Object object) {
33 if(compareTo(object) == 0) {
34 return true;
35 }
36 return false;
37 }
38 /** Retrieve the name of the element.
39 * @return The fully qualified name as a <strong>String</strong>.
40 * @see org.greenstone.gatherer.msm.MSMUtils
41 */
42 public String name() {
43 return MSMUtils.getFullName((Element)element);
44 }
45 /** Retrieve a textual representation of this object.
46 * @return A <strong>String</strong>.
47 * @see org.greenstone.gatherer.msm.MSMUtils
48 */
49 public String toString() {
50 return MSMUtils.getIdentifier(element) + ": " + MSMUtils.getDescription(element);
51 }
52}
Note: See TracBrowser for help on using the repository browser.