package org.greenstone.gatherer.cdm; import org.greenstone.gatherer.msm.MSMUtils; import org.w3c.dom.*; /** For even more confusion this class provides a convience wrapper around an element, to allow it to appear in the JList with both name and description. However this class has nothing to do with its namesake. */ public class ElementWrapper implements Comparable { /** The element as the data from this object. */ private Element element = null; /** Constructor. * @param node the Node this object is wrapped around */ public ElementWrapper(Node node) { this.element = (Element) node; } /** Compare two objects for ordering. * @param object The other Object to compare to. * @return An int indicating the ordering as is String.compareTo */ public int compareTo(Object object) { if(object == null) { return 1; } return toString().compareTo(object.toString()); } /** Compare two objects for equality. * @param object The Object to compare to. * @return true if the objects are equal, false otherwise. */ public boolean equals(Object object) { if(compareTo(object) == 0) { return true; } return false; } /** Retrieve the name of the element. * @return The fully qualified name as a String. */ public String name() { return MSMUtils.getFullName(element); } /** Retrieve a textual representation of this object. * @return A String. */ public String toString() { return MSMUtils.getIdentifier(element) + ": " + MSMUtils.getDescription(element); } }