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