1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * ResultItemLink.java -- a thesaurus link 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 | It contains information describing a thesaurus link.
|
---|
33 |
|
---|
34 | **********************************************************************/
|
---|
35 | package org.greenstone.applet.phind;
|
---|
36 | //package org.nzdl.gsdl.Phind;
|
---|
37 |
|
---|
38 | public class ResultItemLink extends ResultItem {
|
---|
39 |
|
---|
40 | // The phrase number, stored as a string and as a number
|
---|
41 | String id;
|
---|
42 | int symbol;
|
---|
43 |
|
---|
44 | // The text of the link is stored in the inherited text field.
|
---|
45 |
|
---|
46 | // The type of thesaurus link
|
---|
47 | String linkType;
|
---|
48 |
|
---|
49 | // The total frequency is stored in the inherited frequency field.
|
---|
50 |
|
---|
51 | // The document frequency of the thesaurus item
|
---|
52 | int documentFrequency;
|
---|
53 |
|
---|
54 | // Create a ResultItem for a thesaurus link
|
---|
55 | ResultItemLink(String newId, String newText, String newLinkType,
|
---|
56 | String tf, String df) {
|
---|
57 |
|
---|
58 | kind = linkItem;
|
---|
59 | id = newId;
|
---|
60 | symbol = Integer.valueOf(newId).intValue();
|
---|
61 | text = newText.trim();
|
---|
62 | sort = sortLinkItem;
|
---|
63 | linkType = newLinkType;
|
---|
64 | frequency = Integer.valueOf(tf).intValue();
|
---|
65 | documentFrequency = Integer.valueOf(df).intValue();
|
---|
66 | }
|
---|
67 |
|
---|
68 | // Is this item a phrase?
|
---|
69 | public boolean isLink() { return true; }
|
---|
70 |
|
---|
71 | // Return the text of the item components
|
---|
72 | public String hiddenText() { return id; }
|
---|
73 | public String docsText() {
|
---|
74 | if (documentFrequency <= 0) { return ""; }
|
---|
75 | else { return Integer.toString(documentFrequency); }
|
---|
76 | }
|
---|
77 | public String prefixText() {
|
---|
78 | if (linkType.equals("RT")) { return "Related term"; }
|
---|
79 | else if (linkType.equals("BT")) { return "Broader term"; }
|
---|
80 | else if (linkType.equals("NT")) { return "Narrower term"; }
|
---|
81 | else if (linkType.equals("USE")) { return "Use"; }
|
---|
82 | else if (linkType.startsWith("UF")) { return "Used for"; }
|
---|
83 | else { return linkType; }
|
---|
84 | }
|
---|
85 | }
|
---|
86 |
|
---|
87 |
|
---|
88 |
|
---|