1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * ResultItemDocument.java -- a result in the Phind applet
|
---|
4 | *
|
---|
5 | * Copyright 2000 Gordon W. Paynter
|
---|
6 | * Copyright 2000 The New Zealand Digital Library Project
|
---|
7 | *
|
---|
8 | * A component of the Greenstone digital library software
|
---|
9 | * from the New Zealand Digital Library Project at the
|
---|
10 | * University of Waikato, New Zealand.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or modify
|
---|
13 | * it under the terms of the GNU General Public License as published by
|
---|
14 | * the Free Software Foundation; either version 2 of the License, or
|
---|
15 | * (at your option) any later version.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful,
|
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | * GNU General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, write to the Free Software
|
---|
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 | /*********************************************************************
|
---|
29 |
|
---|
30 | This class is used in the Phind java applet (Phind.java).
|
---|
31 |
|
---|
32 | A result item holds the data describing a single line returned from a phind
|
---|
33 | query. The complex functionality of phrase and URL items is implemented in
|
---|
34 | subclasses; the base class handles simpler cases like the "get more phrases"
|
---|
35 | marker.
|
---|
36 |
|
---|
37 | **********************************************************************/
|
---|
38 | package org.greenstone.applet.phind;
|
---|
39 | //package org.nzdl.gsdl.Phind;
|
---|
40 |
|
---|
41 | public class ResultItem {
|
---|
42 |
|
---|
43 | // A text string describing the item
|
---|
44 | String text = "Generic ResultItem";
|
---|
45 |
|
---|
46 | // There are several kinds of ResultItem, identified by their
|
---|
47 | // "kind" field, which has an integer value from the list below.
|
---|
48 | final static int message = 8;
|
---|
49 | final static int linkItem = 7;
|
---|
50 | final static int moreLinks = 6;
|
---|
51 | final static int phraseItem = 5;
|
---|
52 | final static int morePhrases = 4;
|
---|
53 | final static int documentItem = 3;
|
---|
54 | final static int moreDocuments = 2;
|
---|
55 | final static int unknownResultItem = 1;
|
---|
56 |
|
---|
57 | // The kind of the item
|
---|
58 | int kind = unknownResultItem;
|
---|
59 |
|
---|
60 | // When results are displayed, they are loosely sorted by their
|
---|
61 | // kind. The user can change the sort order numbers with the
|
---|
62 | // ResultOrder parameter in Phind.java.
|
---|
63 | static int sortMessage = 8;
|
---|
64 | static int sortLinkItem = 7;
|
---|
65 | static int sortMoreLinks = 6;
|
---|
66 | static int sortPhraseItem = 5;
|
---|
67 | static int sortMorePhrases = 4;
|
---|
68 | static int sortDocumentItem = 3;
|
---|
69 | static int sortMoreDocuments = 2;
|
---|
70 | static int sortUnknownResultItem = 1;
|
---|
71 |
|
---|
72 | // the primary sort key
|
---|
73 | int sort = 0;
|
---|
74 |
|
---|
75 | // The frequency of the item (secondary sort key)
|
---|
76 | int frequency = 0;
|
---|
77 |
|
---|
78 |
|
---|
79 | // Create a blank ResultItem
|
---|
80 | ResultItem() {
|
---|
81 | text = "Unknown result type";
|
---|
82 | kind = unknownResultItem;
|
---|
83 | frequency = 0;
|
---|
84 | }
|
---|
85 |
|
---|
86 | // Create a new ResultItem of some given kind
|
---|
87 | ResultItem(int newKind) {
|
---|
88 | kind = newKind;
|
---|
89 | frequency = 0;
|
---|
90 |
|
---|
91 | if (kind == moreLinks) {
|
---|
92 | text = "get more thesaurus links";
|
---|
93 | sort = sortMoreLinks;
|
---|
94 | } else if (kind == morePhrases) {
|
---|
95 | text = "get more phrases";
|
---|
96 | sort = sortMorePhrases;
|
---|
97 | } else if (kind == moreDocuments) {
|
---|
98 | text = "get more documents";
|
---|
99 | sort = sortMoreDocuments;
|
---|
100 | } else {
|
---|
101 | text = "Unknown result type";
|
---|
102 | sort = sortUnknownResultItem;
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | // Test the type of a ResultItem
|
---|
107 | public boolean isLink() { return false; }
|
---|
108 | public boolean isMoreLinks() { return (kind == moreLinks); }
|
---|
109 | public boolean isPhrase() { return false; }
|
---|
110 | public boolean isMorePhrases() { return (kind == morePhrases); }
|
---|
111 | public boolean isDocument() { return false; }
|
---|
112 | public boolean isMoreDocuments() { return (kind == moreDocuments); }
|
---|
113 |
|
---|
114 | // Return the bare text of the item
|
---|
115 | public String toString() { return(text.trim()); }
|
---|
116 |
|
---|
117 | // Return the text of the item components
|
---|
118 | public String mainText() { return text; }
|
---|
119 | public String freqText() {
|
---|
120 | if (frequency > 0) { return Integer.toString(frequency); }
|
---|
121 | else { return ""; }
|
---|
122 | }
|
---|
123 | public String docsText() { return ""; }
|
---|
124 | public String prefixText() { return ""; }
|
---|
125 | public String suffixText() { return ""; }
|
---|
126 | public String hiddenText() { return ""; }
|
---|
127 | }
|
---|
128 |
|
---|