View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2008 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // utgb-core Project
18  //
19  // SequenceInfo.java
20  // Since: May 11, 2008
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.track.bean;
26  
27  import java.util.ArrayList;
28  import java.util.Iterator;
29  
30  /**
31   * Information of the genoem sequence (species name and sequence revision)
32   * 
33   * @author leo
34   * 
35   */
36  public class SequenceInfo {
37  
38  	private String species = "";
39  	private ArrayList<String> revisionList = new ArrayList<String>();
40  
41  	public SequenceInfo() {
42  	}
43  
44  	public SequenceInfo(String species) {
45  		this.species = species;
46  	}
47  
48  	public void addRevision(String revision) {
49  		this.revisionList.add(revision);
50  
51  	}
52  
53  	public String getSpecies() {
54  		return species;
55  	}
56  
57  	public void setSpecies(String species) {
58  		this.species = species;
59  	}
60  
61  	public ArrayList<String> getRevisionList() {
62  		return revisionList;
63  	}
64  
65  	public String toJSON() {
66  		StringBuffer buf = new StringBuffer();
67  		buf.append("{\"species\":\"");
68  		buf.append(species);
69  		buf.append("\", \"revision\":[");
70  		int count = 0;
71  		for (Iterator<String> it = revisionList.iterator(); it.hasNext(); count++) {
72  			if (count > 0)
73  				buf.append(",");
74  			String revision = it.next();
75  			buf.append("\"");
76  			buf.append(revision);
77  			buf.append("\"");
78  		}
79  		buf.append("]}");
80  		return buf.toString();
81  	}
82  
83  }