aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/pluginmanager/BundleComparator.java
diff options
context:
space:
mode:
authorEmil Ivov <emcho@jitsi.org>2008-07-08 16:47:23 +0000
committerEmil Ivov <emcho@jitsi.org>2008-07-08 16:47:23 +0000
commit1e0a46ef695bd0b94b9e3b87c787a6eb78bf68b9 (patch)
treef60ab3146af0b9ebe0a6b13bdcd706bd8b8af80f /src/net/java/sip/communicator/plugin/pluginmanager/BundleComparator.java
parentd2dd9a9d8a2aba3816af86ed94840c431efc9d99 (diff)
downloadjitsi-1e0a46ef695bd0b94b9e3b87c787a6eb78bf68b9.zip
jitsi-1e0a46ef695bd0b94b9e3b87c787a6eb78bf68b9.tar.gz
jitsi-1e0a46ef695bd0b94b9e3b87c787a6eb78bf68b9.tar.bz2
Sort the list of plugins shown by the plugin manager (patch by Damien ROTH)
Diffstat (limited to 'src/net/java/sip/communicator/plugin/pluginmanager/BundleComparator.java')
-rw-r--r--src/net/java/sip/communicator/plugin/pluginmanager/BundleComparator.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/plugin/pluginmanager/BundleComparator.java b/src/net/java/sip/communicator/plugin/pluginmanager/BundleComparator.java
new file mode 100644
index 0000000..a6313bc
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/pluginmanager/BundleComparator.java
@@ -0,0 +1,43 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.plugin.pluginmanager;
+
+import java.util.*;
+import org.osgi.framework.*;
+
+/**
+ * Comparator for bundle array sort
+ *
+ * @author ROTH Damien
+ */
+public class BundleComparator implements Comparator<Bundle>
+{
+ /**
+ * Compares the bundles using their "Bundle-Name"s.
+ * @param arg0 the first bundle to compare
+ * @param arg1 the second bundle to compare
+ * @return the result of the string comparison between the names of the two
+ * bundles
+ */
+ public int compare(Bundle arg0, Bundle arg1)
+ {
+ String n1 = (String) arg0.getHeaders().get(Constants.BUNDLE_NAME);
+ String n2 = (String) arg1.getHeaders().get(Constants.BUNDLE_NAME);
+
+ if (n1 == null)
+ {
+ n1 = "unknown";
+ }
+ if (n2 == null)
+ {
+ n2 = "unknown";
+ }
+
+ return n1.compareTo(n2);
+ }
+
+}