source: gs3-extensions/audioDB/trunk/src/src/java/org/greenstone/gsdl3/util/AudioDBDocInfo.java@ 24398

Last change on this file since 24398 was 24398, checked in by davidb, 13 years ago

Latest round of changes to code, in preparing for demo to Goldsmiths

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1/*
2 * AudioDBDocInfo.java
3 * Copyright (C) 2011 New Zealand Digital Library, http://www.nzdl.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19package org.greenstone.gsdl3.util;
20
21import java.util.Vector;
22import java.lang.Comparable;
23
24public class AudioDBDocInfo implements Comparable<AudioDBDocInfo>
25{
26 public String oid_;
27 public Vector<Double> rankVector_;
28 public Vector<Integer> offsetVector_;
29
30 public AudioDBDocInfo(String doc_oid, double rank, int offset)
31 {
32 oid_ = doc_oid;
33
34 rankVector_ = new Vector<Double>();
35 rankVector_.add (rank);
36
37 offsetVector_ = new Vector<Integer>();
38 offsetVector_.add(offset);
39 }
40
41
42 public AudioDBDocInfo(String doc_oid, Vector<Double> rankVector, Vector<Integer> offsetVector)
43 {
44 oid_ = doc_oid;
45 rankVector_ = rankVector;
46 offsetVector_ = offsetVector;
47 }
48
49 public String getDocID()
50 {
51 return oid_;
52 }
53
54 public double getTopRank()
55 {
56 return rankVector_.get(0);
57 }
58
59
60 public String getOffsetList()
61 {
62 StringBuffer all_offsets = new StringBuffer();
63 boolean first = true;
64
65 for (int i=0; i<offsetVector_.size(); i++) {
66 int offset = offsetVector_.get(i);
67 String offsetStr = Integer.toString(offset);
68
69 if (first) {
70 first = false;
71 }
72 else {
73 all_offsets.append(",");
74 }
75
76 all_offsets.append(offsetStr);
77 }
78
79 return all_offsets.toString();
80 }
81
82 public int compareTo(AudioDBDocInfo di)
83 {
84 // based on first entry in rank Vector
85
86 // embodies a descending sort order
87 double lrank = rankVector_.get(0);
88 double rrank = di.rankVector_.get(0);
89
90 if (lrank<rrank) {
91 return 1;
92 }
93 else if (lrank>rrank) {
94 return -1;
95 }
96 else {
97 return 0;
98 }
99 }
100}
Note: See TracBrowser for help on using the repository browser.