273defa31f1f63f499568482af00f727fc98e1ac
[jalview.git] / src / org / biojava / dasobert / das2 / Das2CapabilityImpl.java
1 /*
2  *                  BioJava development code
3  *
4  * This code may be freely distributed and modified under the
5  * terms of the GNU Lesser General Public Licence.  This should
6  * be distributed with the code.  If you do not have a copy,
7  * see:
8  *
9  *      http://www.gnu.org/copyleft/lesser.html
10  *
11  * Copyright for this code is held jointly by the individual
12  * authors.  These should be listed in @author doc comments.
13  *
14  * For more information on the BioJava project and its aims,
15  * or to join the biojava-l mailing list, visit the home page
16  * at:
17  *
18  *      http://www.biojava.org/
19  * 
20  * Created on Feb 9, 2006
21  *
22  */
23 package org.biojava.dasobert.das2;
24
25 public class Das2CapabilityImpl 
26 implements Das2Capability{
27
28     String capability;
29     String[] formats;
30     String queryId;
31     
32     public static String DAS1_CAPABILITY_PREFIX = "das1:";
33     
34     public Das2CapabilityImpl() {
35         super();
36         capability = "undef";
37         queryId = "";
38         formats = new String[0];
39
40     }
41     
42     public boolean isDas1Style(){
43         
44         if ( capability == null)
45             return false;
46         if ( capability.length() < DAS1_CAPABILITY_PREFIX.length())
47             return false;
48         if ( capability.substring(0,DAS1_CAPABILITY_PREFIX.length()).equals(DAS1_CAPABILITY_PREFIX))
49             return true;
50         return false;
51     
52     }
53     
54     public boolean equals(Das2Capability other){
55         
56         boolean status = true;
57         
58         if (!  capability.equals(other.getCapability()))
59             status = false;
60         if ( ! queryId.equals(other.getQueryUri()))
61             status = false;
62         
63         return status;
64     }
65     
66     public int hashCode(){
67         int h = 7;
68         h = 31 * h + ( null == capability ? 0 : capability.hashCode()) ;
69         h = 31 * h + ( null == queryId    ? 0 : queryId.hashCode()) ;
70         
71         return h;
72     }
73     
74     public String toString(){
75         String txt ="capability " + capability + " queryId " + queryId;
76         return txt;
77     }
78
79     public String getCapability() {
80         
81         return capability;
82     }
83
84     public String[] getFormats() {      
85         return formats;
86     }
87
88     public String getQueryUri() {      
89         return queryId;
90     }
91
92     public void setCapability(String type) {
93        capability = type;
94         
95     }
96
97     public void setFormats(String[] formats) {
98        
99         this.formats = formats; 
100     }
101
102     public void setQueryUri(String id) {
103        queryId = id;
104         
105     }
106     
107     
108
109 }