source: trunk/gli/src/org/greenstone/gatherer/cdm/Classifier.java@ 12635

Last change on this file since 12635 was 12635, checked in by mdewsnip, 18 years ago

Made some of the new plugins/classifiers code static in preparation for possibly moving it into new classes.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 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.util.StaticStrings;
32import org.greenstone.gatherer.util.Utility;
33import org.w3c.dom.*;
34
35
36/** 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.
37 * @author John Thompson, Greenstone Digital Library, University of Waikato
38 * @version 2.3
39 */
40public class Classifier
41 extends ArgumentContainer
42{
43 static final public String CLASSIFIER_PREFIX = "CL";
44
45
46 /** Constructor used only in DOMProxyListModel initializations.
47 */
48 public Classifier() {
49 }
50
51
52 public Classifier(Element element, Classifier base_classifier) {
53 super(element, base_classifier);
54 }
55
56
57 /** The assigned classifier constructor.
58 * @param element the DOM Element this classifier is based upon
59 */
60 public DOMProxyListEntry create(Element element) {
61 String classifier_name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE);
62 // Determine the base classifier from the classifier name
63 Classifier base_classifier = ClassifierManager.getClassifier(classifier_name, true);
64 Classifier classifier = new Classifier(element, base_classifier);
65 if (base_classifier == null) {
66 // 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.
67 classifier.setAssigned(false);
68 }
69 base_classifier = null;
70 classifier_name = null;
71 return classifier;
72 }
73
74
75 /** Generate the string showing this classifiers position. */
76 public String getPositionString() {
77 String position_string = CLASSIFIER_PREFIX;
78 if(element != null) {
79 // Determine our place in the collect.cfg file
80 int position_int = CollectionDesignManager.classifier_manager.indexOf(this) + 1;
81 if(position_int != -1) {
82 position_string = position_string + position_int;
83 }
84 }
85 return position_string;
86 }
87}
Note: See TracBrowser for help on using the repository browser.