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

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

Moved the new classifiers stuff out into a new static class (greenstone.Classifiers) in preparation for extending it to do collection-specific classifiers.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 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
47 /** Constructor used only in DOMProxyListModel initializations.
48 */
49 public Classifier() {
50 }
51
52
53 public Classifier(Element element, Classifier base_classifier) {
54 super(element, base_classifier);
55 }
56
57
58 /** The assigned classifier constructor.
59 * @param element the DOM Element this classifier is based upon
60 */
61 public DOMProxyListEntry create(Element element) {
62 String classifier_name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE);
63 // Determine the base classifier from the classifier name
64 Classifier base_classifier = Classifiers.getClassifier(classifier_name, true);
65 Classifier classifier = new Classifier(element, base_classifier);
66 if (base_classifier == null) {
67 // 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.
68 classifier.setAssigned(false);
69 }
70 base_classifier = null;
71 classifier_name = null;
72 return classifier;
73 }
74
75
76 /** Generate the string showing this classifiers position. */
77 public String getPositionString() {
78 String position_string = CLASSIFIER_PREFIX;
79 if(element != null) {
80 // Determine our place in the collect.cfg file
81 int position_int = CollectionDesignManager.classifier_manager.indexOf(this) + 1;
82 if(position_int != -1) {
83 position_string = position_string + position_int;
84 }
85 }
86 return position_string;
87 }
88}
Note: See TracBrowser for help on using the repository browser.