Formatting
[jalview.git] / src / org / biojava / dasobert / das2 / Das2SourceImpl.java
index aca49b2..efdf40d 100755 (executable)
  * at:
  *
  *      http://www.biojava.org/
- * 
+ *
  * Created on Feb 9, 2006
  *
  */
 package org.biojava.dasobert.das2;
 
-import org.biojava.dasobert.dasregistry.Das1Source;
-import org.biojava.dasobert.dasregistry.DasSource;
+import org.biojava.dasobert.dasregistry.*;
 
-public class Das2SourceImpl 
-extends Das1Source
-implements Das2Source 
+public class Das2SourceImpl
+    extends Das1Source implements Das2Source
 
 {
 
-    Das2Capability[] capabilities;
-    
-    public Das2SourceImpl() {
-        super();
+  Das2Capability[] capabilities;
+
+  public Das2SourceImpl()
+  {
+    super();
+
+    capabilities = new Das2Capability[0];
+  }
+
+  /**  compare if two DasSources are identical
+   *
+   */
+  public boolean equals(DasSource other)
+  {
 
-        capabilities = new Das2Capability[0];
+    if (this == other)
+    {
+      return true;
     }
-    
-    
-    /**  compare if two DasSources are identical
-     * 
-     */
-    public boolean equals(DasSource other){
-        
-        if ( this == other)
-            return true;
-        
-        if ( ( other == null) || (other.getClass() != this.getClass()))    
-            return false;
-       
-        // to compare if two Das2Sources are identical we do the following:
-        //  we check the capabilities
-        
-        Das2SourceImpl d2o = (Das2SourceImpl)other;
-        
-        if ( nickname.equals(d2o.getNickname()))
-            return true;
-        
-        Das2Capability[] othercaps = d2o.getDas2Capabilities();
-        
-        if ( ! (capabilities.length == othercaps.length))
-            return false;
-        
-        for ( int x=0;x<capabilities.length;x++){
-            Das2Capability tmpcap = capabilities[x];
-            boolean foundCap = false;
-            for (int y=0; y< othercaps.length;y++){
-                Das2Capability tmpcapo = othercaps[y];
-                if ( tmpcap.equals(tmpcapo))
-                    foundCap = true;
-            }
-            if ( ! foundCap)
-                return false;
-        }
-        
-        
-        //TODO?
-        // should we add a check for coordinate systems?
-        // but we already check for the endpoints, that should be enough...
-        
-        return true;
-        
+
+    if ( (other == null) || (other.getClass() != this.getClass()))
+    {
+      return false;
     }
-    
-    public int hashCode(){
-        int h = 7 ;
-        
-        h = 31 * h + (null == nickname ? 0 :  nickname.hashCode());
-        
-        for ( int x=0;x<capabilities.length;x++){
-            Das2Capability cap = capabilities[x];
-            h = 31 * h + cap.hashCode();
-        }
-        
-        return h;
+
+    // to compare if two Das2Sources are identical we do the following:
+    //  we check the capabilities
+
+    Das2SourceImpl d2o = (Das2SourceImpl) other;
+
+    if (nickname.equals(d2o.getNickname()))
+    {
+      return true;
+    }
+
+    Das2Capability[] othercaps = d2o.getDas2Capabilities();
+
+    if (! (capabilities.length == othercaps.length))
+    {
+      return false;
     }
-    
-    
-    public boolean hasDas1Capabilities(){
-        
-        // test if any of the capabilities is a das1 capabilitiy
-        
-        for (int i = 0 ; i < capabilities.length; i++) {
-            Das2Capability cap = capabilities[i];
-            if ( cap.isDas1Style())
-                return true;            
+
+    for (int x = 0; x < capabilities.length; x++)
+    {
+      Das2Capability tmpcap = capabilities[x];
+      boolean foundCap = false;
+      for (int y = 0; y < othercaps.length; y++)
+      {
+        Das2Capability tmpcapo = othercaps[y];
+        if (tmpcap.equals(tmpcapo))
+        {
+          foundCap = true;
         }
+      }
+      if (!foundCap)
+      {
         return false;
-        
-        
-    }
-    
-    public String[] getCapabilities() {
-        //todo mark as not needed / not appropriate ...
-        return super.getCapabilities();
+      }
     }
 
+    //TODO?
+    // should we add a check for coordinate systems?
+    // but we already check for the endpoints, that should be enough...
 
+    return true;
 
-    public void setCapabilities(String[] u) {
-        // TODO Auto-generated method stub
-        super.setCapabilities(u);
-    }
+  }
 
+  public int hashCode()
+  {
+    int h = 7;
 
+    h = 31 * h + (null == nickname ? 0 : nickname.hashCode());
 
-    public Das2Capability[] getDas2Capabilities() {
-        // TODO Auto-generated method stub
-        return capabilities;
+    for (int x = 0; x < capabilities.length; x++)
+    {
+      Das2Capability cap = capabilities[x];
+      h = 31 * h + cap.hashCode();
     }
 
-    public void setDas2Capabilities(Das2Capability[] capabilities) {
-        // TODO Auto-generated method stub
-        this.capabilities = capabilities;
-        
+    return h;
+  }
+
+  public boolean hasDas1Capabilities()
+  {
+
+    // test if any of the capabilities is a das1 capabilitiy
+
+    for (int i = 0; i < capabilities.length; i++)
+    {
+      Das2Capability cap = capabilities[i];
+      if (cap.isDas1Style())
+      {
+        return true;
+      }
     }
-    
-    
-    
+    return false;
+
+  }
+
+  public String[] getCapabilities()
+  {
+    //todo mark as not needed / not appropriate ...
+    return super.getCapabilities();
+  }
+
+  public void setCapabilities(String[] u)
+  {
+    // TODO Auto-generated method stub
+    super.setCapabilities(u);
+  }
+
+  public Das2Capability[] getDas2Capabilities()
+  {
+    // TODO Auto-generated method stub
+    return capabilities;
+  }
+
+  public void setDas2Capabilities(Das2Capability[] capabilities)
+  {
+    // TODO Auto-generated method stub
+    this.capabilities = capabilities;
+
+  }
 
 }