001    /**
002     * Copyright (C) 2007-2011, Jens Lehmann
003     *
004     * This file is part of DL-Learner.
005     *
006     * DL-Learner is free software; you can redistribute it and/or modify
007     * it under the terms of the GNU General Public License as published by
008     * the Free Software Foundation; either version 3 of the License, or
009     * (at your option) any later version.
010     *
011     * DL-Learner is distributed in the hope that it will be useful,
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014     * GNU General Public License for more details.
015     *
016     * You should have received a copy of the GNU General Public License
017     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
018     */
019    
020    package org.dllearner.core.options;
021    
022    
023    /**
024     * A configuration option representing a boolean value.
025     * 
026     * @author Jens Lehmann
027     * 
028     */
029    public class BooleanConfigOption extends ConfigOption<Boolean> {
030    
031            public BooleanConfigOption(String name, String description) {
032                    super(name, description);
033                    
034            }
035            
036            public BooleanConfigOption(String name, String description, Boolean defaultValue) {
037                    super(name, description, defaultValue);
038                    
039            }       
040            
041            public BooleanConfigOption(String name, String description, Boolean defaultValue, boolean mandatory, boolean requiresInit) {
042                    super(name, description, defaultValue, mandatory, requiresInit);
043                    
044            }       
045    
046            /* (non-Javadoc)
047             * @see org.dllearner.core.config.ConfigOption#getValueTypeAsJavaString()
048             */
049            @Override
050            public String getValueTypeAsJavaString(){
051                    return "boolean";
052            }
053            
054            /*
055             * (non-Javadoc)
056             * 
057             * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object)
058             */
059            @Override
060            public boolean checkType(Object object) {
061                    return (object instanceof Boolean);
062            }
063    
064            /*
065             * (non-Javadoc)
066             * 
067             * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object)
068             */
069            @Override
070            public boolean isValidValue(Boolean value) {
071                    return true;
072            }
073    
074            /*
075             * (non-Javadoc)
076             * 
077             * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object)
078             */
079            @Override
080            public String getValueFormatting(Boolean value) {
081                    if (value != null) {
082                            if (value)
083                                    return "true;";
084                            else
085                                    return "false;";
086                    } else
087                            return null;
088            }
089    
090    }