]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - jcr/org.argeo.cms.ui/src/org/argeo/eclipse/ui/jcr/util/NodeViewerComparer.java
1 package org
.argeo
.eclipse
.ui
.jcr
.util
;
4 import javax
.jcr
.RepositoryException
;
6 import org
.argeo
.eclipse
.ui
.EclipseUiException
;
7 import org
.eclipse
.jface
.viewers
.IElementComparer
;
9 /** Compare JCR nodes based on their JCR identifiers, for use in JFace viewers. */
10 public class NodeViewerComparer
implements IElementComparer
{
12 // force comparison on Node IDs only.
13 public boolean equals(Object elementA
, Object elementB
) {
14 if (!(elementA
instanceof Node
) || !(elementB
instanceof Node
)) {
15 return elementA
== null ? elementB
== null : elementA
19 boolean result
= false;
21 String idA
= ((Node
) elementA
).getIdentifier();
22 String idB
= ((Node
) elementB
).getIdentifier();
23 result
= idA
== null ? idB
== null : idA
.equals(idB
);
24 } catch (RepositoryException re
) {
25 throw new EclipseUiException("cannot compare nodes", re
);
32 public int hashCode(Object element
) {
33 // TODO enhanced this method.
34 return element
.getClass().toString().hashCode();