From 8d0bcc4cfb85138b7455afae55174c8583a97bcf Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Tue, 16 Dec 2008 15:08:30 +0000
Subject: [PATCH] Fix for issue 3668 (Control Panel does not display correctly connection handlers' listen addresses) Use a comparator of InetAdress in the admin framework to sort the addresses.
---
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java | 61 ++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 1 deletions(-)
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java b/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
index 5d3fa2e..1bf445c 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
@@ -57,6 +57,8 @@
private String dn;
private Map<String, Set<Object>> attributes;
private SortedSet<String> attrNames;
+ private String toString;
+ private int hashCode;
/**
* Constructor of an empty search result. This constructor is used by the
@@ -69,6 +71,8 @@
this.dn = dn;
attributes = new HashMap<String, Set<Object>>();
attrNames = new TreeSet<String>();
+ toString = calculateToString();
+ hashCode = calculateHashCode();
}
/**
@@ -134,6 +138,8 @@
attributes.put(name.toLowerCase(), values);
}
}
+ toString = calculateToString();
+ hashCode = calculateHashCode();
}
/**
@@ -178,8 +184,49 @@
/**
* {@inheritDoc}
*/
+ public boolean equals(Object o)
+ {
+ boolean equals = false;
+ if (o != null)
+ {
+ equals = o == this;
+ if (!equals && (o instanceof CustomSearchResult))
+ {
+ CustomSearchResult sr = (CustomSearchResult)o;
+ equals = getDN().equals(sr.getDN());
+ if (equals)
+ {
+ equals = getAttributeNames().equals(sr.getAttributeNames());
+ if (equals)
+ {
+ for (String attrName : getAttributeNames())
+ {
+ equals = getAttributeValues(attrName).equals(
+ sr.getAttributeValues(attrName));
+ if (!equals)
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return equals;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public String toString() {
- return "dn: "+dn+"\nattributes: "+attributes;
+ return toString;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int hashCode() {
+ return hashCode;
}
/**
@@ -192,5 +239,17 @@
attrNames.add(attrName);
attrName = attrName.toLowerCase();
attributes.put(attrName, values);
+ toString = calculateToString();
+ hashCode = calculateHashCode();
+ }
+
+ private String calculateToString()
+ {
+ return "dn: "+dn+"\nattributes: "+attributes;
+ }
+
+ private int calculateHashCode()
+ {
+ return 23 + toString.hashCode();
}
}
--
Gitblit v1.10.0