001 /* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2011 SonarSource 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.channel; 021 022 import java.util.ArrayList; 023 import java.util.Arrays; 024 import java.util.List; 025 026 /** 027 * Configuration parameters used by a CodeReader to handle some specificities. 028 */ 029 public class CodeReaderConfiguration { 030 031 /** 032 * @deprecated in 2.12, do not use anymore. 033 */ 034 @Deprecated 035 public final static int DEFAULT_BUFFER_CAPACITY = 8000; 036 037 public final static int DEFAULT_TAB_WIDTH = 1; 038 039 private int tabWidth = DEFAULT_TAB_WIDTH; 040 041 private List<CodeReaderFilter<?>> codeReaderFilters = new ArrayList<CodeReaderFilter<?>>(); 042 043 /** 044 * @deprecated in 2.12, do not use anymore. 045 * @return the constant Integer.MAX_VALUE 046 */ 047 @Deprecated 048 public int getBufferCapacity() { 049 return Integer.MAX_VALUE; 050 } 051 052 /** 053 * @deprecated in 2.12, do not use anymore. 054 * @param bufferCapacity 055 * the bufferCapacity to set 056 */ 057 @Deprecated 058 public void setBufferCapacity(int bufferCapacity) { 059 } 060 061 /** 062 * @return the tabWidth 063 */ 064 public int getTabWidth() { 065 return tabWidth; 066 } 067 068 /** 069 * @param tabWidth 070 * the tabWidth to set 071 */ 072 public void setTabWidth(int tabWidth) { 073 this.tabWidth = tabWidth; 074 } 075 076 /** 077 * @return the codeReaderFilters 078 */ 079 @SuppressWarnings("rawtypes") 080 public CodeReaderFilter[] getCodeReaderFilters() { 081 return codeReaderFilters.toArray(new CodeReaderFilter[codeReaderFilters.size()]); 082 } 083 084 /** 085 * @param codeReaderFilters 086 * the codeReaderFilters to set 087 */ 088 public void setCodeReaderFilters(CodeReaderFilter<?>... codeReaderFilters) { 089 this.codeReaderFilters = new ArrayList<CodeReaderFilter<?>>(Arrays.asList(codeReaderFilters)); 090 } 091 092 /** 093 * Adds a code reader filter 094 * 095 * @param codeReaderFilter 096 * the codeReaderFilter to add 097 */ 098 public void addCodeReaderFilters(CodeReaderFilter<?> codeReaderFilter) { 099 this.codeReaderFilters.add(codeReaderFilter); 100 } 101 102 public CodeReaderConfiguration cloneWithoutCodeReaderFilters() { 103 CodeReaderConfiguration clone = new CodeReaderConfiguration(); 104 clone.setTabWidth(tabWidth); 105 return clone; 106 } 107 108 }