View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2007 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-medaka Project
18  //
19  // KeywordSearchResult.java
20  // Since: Jun 18, 2008
21  //
22  // $URL: http://svn.utgenome.org/utgb/trunk/utgb/utgb-keyword/src/main/java/org/utgenome/keyword/app/KeywordSearchResult.java $ 
23  // $Author: leo $
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.bio;
26  
27  import java.io.Serializable;
28  import java.util.ArrayList;
29  import java.util.List;
30  
31  /**
32   * keyword search result
33   * 
34   * @author leo
35   * 
36   */
37  public class KeywordSearchResult implements Serializable {
38  
39  	private static final long serialVersionUID = 1L;
40  
41  	public int page;
42  	public int count;
43  	public int maxPage;
44  	public List<Entry> result = new ArrayList<Entry>();
45  
46  	public static class Entry implements Serializable {
47  		private static final long serialVersionUID = 1L;
48  
49  		public String name = "";
50  		public String chr = "";
51  		public int start;
52  		public int end;
53  		public String ref = "";
54  		public String offsets = null;
55  		public int id;
56  		public int rowid;
57  
58  		public String getHit() {
59  			if (offsets != null) {
60  				String[] offsetData = offsets.split(" ");
61  				if (offsetData == null || offsetData.length < 4)
62  					return name;
63  
64  				StringBuilder nameBuf = new StringBuilder();
65  				for (int i = 0; i < offsetData.length; i += 4) {
66  					if (i > 0)
67  						nameBuf.append(" ");
68  
69  					int startIndex = Integer.parseInt(offsetData[i + 2]);
70  					int byteLength = Integer.parseInt(offsetData[i + 3]);
71  					nameBuf.append(name.substring(startIndex, startIndex + byteLength));
72  				}
73  				return nameBuf.toString();
74  			}
75  
76  			return name;
77  		}
78  	}
79  
80  }