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

Last change on this file since 7995 was 7995, checked in by mdewsnip, 20 years ago

Removed a whole lot of references to the msm package, which is on its way out.

  • Property svn:keywords set to Author Date Id Revision
File size: 1.7 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 */
7public class ElementWrapper
8 implements Comparable {
9 /** The element as the data from this object. */
10 private Element element = null;
11 /** Constructor.
12 * @param node the Node this object is wrapped around
13 */
14 public ElementWrapper(Node node) {
15 this.element = (Element) node;
16 }
17 /** Compare two objects for ordering.
18 * @param object The other <strong>Object</strong> to compare to.
19 * @return An <i>int</i> indicating the ordering as is String.compareTo
20 */
21 public int compareTo(Object object) {
22 if(object == null) {
23 return 1;
24 }
25 return toString().compareTo(object.toString());
26 }
27 /** Compare two objects for equality.
28 * @param object The <strong>Object</strong> to compare to.
29 * @return <i>true</i> if the objects are equal, <i>false</i> otherwise.
30 */
31 public boolean equals(Object object) {
32 if(compareTo(object) == 0) {
33 return true;
34 }
35 return false;
36 }
37 /** Retrieve the name of the element.
38 * @return The fully qualified name as a <strong>String</strong>.
39 */
40 public String name() {
41 return MSMUtils.getFullName(element);
42 }
43 /** Retrieve a textual representation of this object.
44 * @return A <strong>String</strong>.
45 */
46 public String toString() {
47 return MSMUtils.getIdentifier(element) + ": " + MSMUtils.getDescription(element);
48 }
49}
Note: See TracBrowser for help on using the repository browser.