source: gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/Classifier.java@ 18368

Last change on this file since 18368 was 13177, checked in by mdewsnip, 17 years ago

No longer tries to load the options for a plugin/classifier if it has already failed.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * Author: John Thompson, Greenstone Digital Library, University of Waikato
9 *
10 * Copyright (C) 1999 New Zealand Digital Library Project
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 */
27package org.greenstone.gatherer.cdm;
28
29import java.io.*;
30import java.util.*;
31import org.greenstone.gatherer.greenstone.Classifiers;
32import org.greenstone.gatherer.util.StaticStrings;
33import org.greenstone.gatherer.util.Utility;
34import org.w3c.dom.*;
35
36
37/** This class is responsible for storing information from a parsed classinfo.pl call in such a way that it allows easy access to parsed details for the purposes of user design and specification of classifiers.
38 * @author John Thompson, Greenstone Digital Library, University of Waikato
39 * @version 2.3
40 */
41public class Classifier
42 extends ArgumentContainer
43{
44 static final public String CLASSIFIER_PREFIX = "CL";
45
46 private boolean loading_options_failed = false;
47
48
49 /** Constructor used only in DOMProxyListModel initializations.
50 */
51 public Classifier() {
52 }
53
54
55 public Classifier(Element element, Classifier base_classifier) {
56 super(element, base_classifier);
57 }
58
59
60 /** The assigned classifier constructor.
61 * @param element the DOM Element this classifier is based upon
62 */
63 public DOMProxyListEntry create(Element element) {
64 String classifier_name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE);
65 // Determine the base classifier from the classifier name
66 Classifier base_classifier = Classifiers.getClassifier(classifier_name, true);
67 Classifier classifier = new Classifier(element, base_classifier);
68 if (base_classifier == null) {
69 // this is kind of a place holder classifier for one which is invalid. It won't get written out to the config file when its next saved.
70 classifier.setAssigned(false);
71 }
72 base_classifier = null;
73 classifier_name = null;
74 return classifier;
75 }
76
77
78 public boolean didLoadingOptionsFail()
79 {
80 return loading_options_failed;
81 }
82
83
84 /** Generate the string showing this classifiers position. */
85 public String getPositionString() {
86 String position_string = CLASSIFIER_PREFIX;
87 if(element != null) {
88 // Determine our place in the collect.cfg file
89 int position_int = CollectionDesignManager.classifier_manager.indexOf(this) + 1;
90 if(position_int != -1) {
91 position_string = position_string + position_int;
92 }
93 }
94 return position_string;
95 }
96
97
98 public void setLoadingOptionsFailed()
99 {
100 this.loading_options_failed = true;
101 }
102}
Note: See TracBrowser for help on using the repository browser.