~ubuntu-branches/ubuntu/maverick/cdk/maverick

« back to all changes in this revision

Viewing changes to src/org/openscience/cdk/io/setting/IOSetting.java

  • Committer: Bazaar Package Importer
  • Author(s): Paul Cager
  • Date: 2008-04-09 21:17:53 UTC
  • Revision ID: james.westby@ubuntu.com-20080409211753-46lmjw5z8mx5pd8d
Tags: upstream-1.0.2
ImportĀ upstreamĀ versionĀ 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $RCSfile$
 
2
 * $Author: egonw $
 
3
 * $Date: 2007-01-04 18:46:10 +0100 (Thu, 04 Jan 2007) $
 
4
 * $Revision: 7636 $
 
5
 *
 
6
 * Copyright (C) 2003-2007  The CDK Development Team
 
7
 *
 
8
 * Contact: cdk-devel@lists.sourceforge.net
 
9
 *
 
10
 *  This library is free software; you can redistribute it and/or
 
11
 *  modify it under the terms of the GNU Lesser General Public
 
12
 *  License as published by the Free Software Foundation; either
 
13
 *  version 2.1 of the License, or (at your option) any later version.
 
14
 *
 
15
 *  This library is distributed in the hope that it will be useful,
 
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
18
 *  Lesser General Public License for more details.
 
19
 *
 
20
 *  You should have received a copy of the GNU Lesser General Public
 
21
 *  License along with this library; if not, write to the Free Software
 
22
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
23
 */
 
24
package org.openscience.cdk.io.setting;
 
25
 
 
26
import org.openscience.cdk.exception.CDKException;
 
27
 
 
28
/**
 
29
 * An interface for reader settings. It is subclassed by implementations,
 
30
 * one for each type of field, e.g. IntReaderSetting.
 
31
 *
 
32
 * @cdk.module io
 
33
 *
 
34
 * @author Egon Willighagen <egonw@sci.kun.nl>
 
35
 */
 
36
public abstract class IOSetting {
 
37
 
 
38
    /** The levels available:
 
39
     *    HIGH         important question
 
40
     *    MEDIUM
 
41
     *    LOW          unimportant question
 
42
     */
 
43
    public static final int HIGH   = 0;
 
44
    public static final int MEDIUM = 1;
 
45
    public static final int LOW    = 2;
 
46
    
 
47
    protected int    level;
 
48
    protected String name;
 
49
    protected String question;
 
50
    protected String setting;
 
51
    
 
52
    /**
 
53
     * The default constructor that sets this field. All textual 
 
54
     * information is supposed to be English. Localization is taken care
 
55
     * off by the ReaderConfigurator.
 
56
     *
 
57
     * @param name           Name of the setting
 
58
     * @param level          Level at which question is asked
 
59
     * @param question       Question that is poped to the user when the 
 
60
     *                       ReaderSetting needs setting
 
61
     * @param defaultSetting The default setting, used if not overwritten
 
62
     *                       by a user
 
63
     */
 
64
    public IOSetting(String name, int level, 
 
65
                         String question, String defaultSetting) {
 
66
        this.level = level;
 
67
        this.name  = name;
 
68
        this.question = question;
 
69
        this.setting = defaultSetting;
 
70
    }
 
71
    
 
72
    public String getName() {
 
73
        return this.name;
 
74
    }
 
75
    
 
76
    public String getQuestion() {
 
77
        return this.question;
 
78
    }
 
79
 
 
80
    public String getDefaultSetting() {
 
81
        return this.setting;
 
82
    }
 
83
    
 
84
    public int getLevel() {
 
85
        return this.level;
 
86
    }
 
87
    
 
88
    /**
 
89
     * Sets the setting for a certain question. It will throw
 
90
     * a CDKException when the setting is not valid.    
 
91
     *
 
92
     */
 
93
    public void setSetting(String setting) throws CDKException {
 
94
        // by default, except all input, so no setting checking                     
 
95
        this.setting = setting;
 
96
    }
 
97
 
 
98
    /**
 
99
     * Sets the setting for a certain question. It will throw
 
100
     * a CDKException when the setting is not valid.    
 
101
     *
 
102
     */
 
103
    public String getSetting() {
 
104
        // by default, except all input, so no setting checking                     
 
105
        return this.setting;
 
106
    }
 
107
}