[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Wed Nov 2 06:39:06 UTC 2005


senger
Wed Nov  2 01:39:06 EST 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared
In directory pub.open-bio.org:/tmp/cvs-serv12193/src/main/org/biomoby/shared

Modified Files:
	MobyPrimaryDataSet.java MobyService.java 
Log Message:


moby-live/Java/src/main/org/biomoby/shared MobyPrimaryDataSet.java,1.3,1.4 MobyService.java,1.7,1.8
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSet.java	2005/09/22 16:07:09	1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrimaryDataSet.java	2005/11/02 06:39:06	1.4
@@ -78,6 +78,15 @@
 	return true;
     }
 
+    public MobyDataType getDataType() {
+	synchronized (elements) {
+	    if (elements.size() > 0)
+		return ((MobyPrimaryDataSimple)elements.firstElement()).getDataType();
+	    else
+		return null;
+	}
+    }
+
     /**************************************************************************
      * Convert this instance to the XML.
      * The XML will look like this:

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java	2005/09/22 16:07:09	1.7
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyService.java	2005/11/02 06:39:06	1.8
@@ -9,6 +9,7 @@
 
 import org.tulsoft.shared.UUtils;
 
+import java.util.Comparator;
 import java.util.Enumeration;
 import java.util.Vector;
 
@@ -24,7 +25,8 @@
  * @version $Id$
  */
 
-public class MobyService {
+public class MobyService
+    implements Comparable {
 
     /**
      * A dummy name used for MobyService instances that do not have
@@ -57,6 +59,18 @@
     protected Vector primaryOutputs = new Vector();
 
     /**************************************************************************
+     * Implementing Comparable interface.
+     *************************************************************************/
+    public int compareTo (Object obj) {
+	return getUniqueName().compareToIgnoreCase ( ((MobyService)obj).getUniqueName() );
+    }
+
+    public boolean equals (Object obj) {
+	if (obj == null) return false;
+	return getUniqueName().equals ( ((MobyService)obj).getUniqueName() );
+    }
+
+    /**************************************************************************
      * Default constructor.
      *************************************************************************/
     public MobyService() {
@@ -299,9 +313,10 @@
 	}
     }
 
+    // some historical reasons for this method...
     public boolean equals (MobyService anotherOne) {
-	if (anotherOne == null) return false;
-	return this.name.equals (anotherOne.getName());
+ 	if (anotherOne == null) return false;
+	return equals ((Object)anotherOne);
     }
 
     public String toString() {
@@ -336,8 +351,32 @@
 	return new String (buf);
     }
 
+    /**************************************************************************
+     * It combines this service name and its authority name. It is
+     * used also in {@link #equals} and {@link #compareTo} methods. <p>
+     *
+     * TBD: The authority should be checked that it does not contain
+     * character sequence 'space followed by a left parenthesis'.
+     *************************************************************************/
     public String toShortString() {
 	return name + " (" + authority + ")";
     }
 
+    /**************************************************************************
+     * Create a comparator for case-insensitive sorting of services by
+     * their authorities.
+     *************************************************************************/
+    public static Comparator getAuthorityComparator() {
+	return new Comparator() {
+		public int compare (Object o1, Object o2) {
+		    String a1 = ((MobyService)o1).getAuthority();
+		    String a2 = ((MobyService)o2).getAuthority();
+		    int compared = (a1).compareToIgnoreCase ((String)a2);
+		    if (compared == 0)
+			return ( ((MobyService)o1).getName().compareToIgnoreCase ( ((MobyService)o2).getName() ) );
+		    else
+			return compared;
+		}
+	    };
+    }
 }




More information about the MOBY-guts mailing list