001    /*
002     * Sonar, open source software quality management tool.
003     * Copyright (C) 2009 SonarSource SA
004     * mailto:contact AT sonarsource DOT com
005     *
006     * Sonar is free software; you can redistribute it and/or
007     * modify it under the terms of the GNU Lesser General Public
008     * License as published by the Free Software Foundation; either
009     * version 3 of the License, or (at your option) any later version.
010     *
011     * Sonar 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 GNU
014     * Lesser General Public License for more details.
015     *
016     * You should have received a copy of the GNU Lesser General Public
017     * License along with Sonar; if not, write to the Free Software
018     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
019     */
020    package org.sonar.squid.api;
021    
022    import java.nio.charset.Charset;
023    
024    public class SquidConfiguration {
025    
026      private boolean analysePropertyAccessors = true;
027    
028      private Charset charset                  = Charset.defaultCharset();
029    
030      private double  commentedCodeThreshold   = 0.9;
031    
032      public SquidConfiguration() {
033      }
034    
035      public SquidConfiguration(boolean analysePropertyAccessors) {
036        this.analysePropertyAccessors = analysePropertyAccessors;
037      }
038    
039      public SquidConfiguration(double commentedCodeThreshold) {
040        setCommentedCodeThreshold(commentedCodeThreshold);
041      }
042    
043      public SquidConfiguration(boolean analysePropertyAccessors, Charset charset) {
044        this.analysePropertyAccessors = analysePropertyAccessors;
045        this.charset = charset;
046      }
047    
048      public SquidConfiguration(boolean analysePropertyAccessors, Charset charset, double commentedCodeThreshold) {
049        this.analysePropertyAccessors = analysePropertyAccessors;
050        this.charset = charset;
051        setCommentedCodeThreshold(commentedCodeThreshold);
052      }
053    
054      public boolean isAnalysePropertyAccessors() {
055        return analysePropertyAccessors;
056      }
057    
058      public Charset getCharset() {
059        return charset;
060      }
061    
062      public void setCharset(Charset charset) {
063        this.charset = charset;
064      }
065    
066      private void setCommentedCodeThreshold(double commentedCodeThreshold) {
067        if (commentedCodeThreshold < 0 || commentedCodeThreshold > 1) {
068          throw new IllegalArgumentException("Commented Code Threshold should be between [0...1]. Current value : " + commentedCodeThreshold);
069        }
070        this.commentedCodeThreshold = commentedCodeThreshold;
071      }
072    
073      public double getCommentedCodeThreshold() {
074        return commentedCodeThreshold;
075      }
076    }