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 static final double COMMENTED_CODE_DEFAULT_THRESHOLD = 0.9; 031 private double commentedCodeThreshold = COMMENTED_CODE_DEFAULT_THRESHOLD; 032 033 public SquidConfiguration() { 034 } 035 036 public SquidConfiguration(boolean analysePropertyAccessors) { 037 this.analysePropertyAccessors = analysePropertyAccessors; 038 } 039 040 public SquidConfiguration(double commentedCodeThreshold) { 041 setCommentedCodeThreshold(commentedCodeThreshold); 042 } 043 044 public SquidConfiguration(boolean analysePropertyAccessors, Charset charset) { 045 this.analysePropertyAccessors = analysePropertyAccessors; 046 this.charset = charset; 047 } 048 049 public SquidConfiguration(boolean analysePropertyAccessors, Charset charset, double commentedCodeThreshold) { 050 this.analysePropertyAccessors = analysePropertyAccessors; 051 this.charset = charset; 052 setCommentedCodeThreshold(commentedCodeThreshold); 053 } 054 055 public boolean isAnalysePropertyAccessors() { 056 return analysePropertyAccessors; 057 } 058 059 public Charset getCharset() { 060 return charset; 061 } 062 063 public void setCharset(Charset charset) { 064 this.charset = charset; 065 } 066 067 private void setCommentedCodeThreshold(double commentedCodeThreshold) { 068 if (commentedCodeThreshold < 0 || commentedCodeThreshold > 1) { 069 throw new IllegalArgumentException("Commented Code Threshold should be between [0...1]. Current value : " + commentedCodeThreshold); 070 } 071 this.commentedCodeThreshold = commentedCodeThreshold; 072 } 073 074 public double getCommentedCodeThreshold() { 075 return commentedCodeThreshold; 076 } 077 }