Formatting
[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
29   String capability;
30   String[] formats;
31   String queryId;
32
33   public static String DAS1_CAPABILITY_PREFIX = "das1:";
34
35   public Das2CapabilityImpl()
36   {
37     super();
38     capability = "undef";
39     queryId = "";
40     formats = new String[0];
41
42   }
43
44   public boolean isDas1Style()
45   {
46
47     if (capability == null)
48     {
49       return false;
50     }
51     if (capability.length() < DAS1_CAPABILITY_PREFIX.length())
52     {
53       return false;
54     }
55     if (capability.substring(0,
56         DAS1_CAPABILITY_PREFIX.length()).equals(DAS1_CAPABILITY_PREFIX))
57     {
58       return true;
59     }
60     return false;
61
62   }
63
64   public boolean equals(Das2Capability other)
65   {
66
67     boolean status = true;
68
69     if (!capability.equals(other.getCapability()))
70     {
71       status = false;
72     }
73     if (!queryId.equals(other.getQueryUri()))
74     {
75       status = false;
76     }
77
78     return status;
79   }
80
81   public int hashCode()
82   {
83     int h = 7;
84     h = 31 * h + (null == capability ? 0 : capability.hashCode());
85     h = 31 * h + (null == queryId ? 0 : queryId.hashCode());
86
87     return h;
88   }
89
90   public String toString()
91   {
92     String txt = "capability " + capability + " queryId " + queryId;
93     return txt;
94   }
95
96   public String getCapability()
97   {
98
99     return capability;
100   }
101
102   public String[] getFormats()
103   {
104     return formats;
105   }
106
107   public String getQueryUri()
108   {
109     return queryId;
110   }
111
112   public void setCapability(String type)
113   {
114     capability = type;
115
116   }
117
118   public void setFormats(String[] formats)
119   {
120
121     this.formats = formats;
122   }
123
124   public void setQueryUri(String id)
125   {
126     queryId = id;
127
128   }
129
130 }