|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AutomaticBean | Line # 56 | 90.4% |
0.90361446
|
20.36 | 69 | 20 | 20 | 0.29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| StrArrayConverter | Line # 310 | 60% |
0.6
|
26.54 | 30 | 14 | 14 | 0.47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ( 10 of 453) | |||
| Result | |||
|
0.7443609
|
com.puppycrawl.tools.checkstyle.checks.FinalParametersCheckTest.testCtorToken
com.puppycrawl.tools.checkstyle.checks.FinalParametersCheckTest.testCtorToken
|
1 PASS | |
|
0.7443609
|
com.puppycrawl.tools.checkstyle.checks.sizes.ExecutableStatementCountCheckTest.testInstanceInit
com.puppycrawl.tools.checkstyle.checks.sizes.ExecutableStatementCountCheckTest.testInstanceInit
|
1 PASS | |
|
0.7443609
|
com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportTest.testExcludes
com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportTest.testExcludes
|
1 PASS | |
|
0.7443609
|
com.puppycrawl.tools.checkstyle.checks.DescendantTokenCheckTest.testReturnFromCatch
com.puppycrawl.tools.checkstyle.checks.DescendantTokenCheckTest.testReturnFromCatch
|
1 PASS | |
|
0.7443609
|
com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheckTest.testMethod
com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheckTest.testMethod
|
1 PASS | |
|
0.7443609
|
com.puppycrawl.tools.checkstyle.checks.DescendantTokenCheckTest.testStringLiteralEquality
com.puppycrawl.tools.checkstyle.checks.DescendantTokenCheckTest.testStringLiteralEquality
|
1 PASS | |
|
0.7443609
|
com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheckTest.testIntegersOnly
com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheckTest.testIntegersOnly
|
1 PASS | |
|
0.7443609
|
com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenCheckTest.testNative
com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenCheckTest.testNative
|
1 PASS | |
|
0.7443609
|
com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheckTest.testLegalAbstractClassNames
com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheckTest.testLegalAbstractClassNames
|
1 PASS | |
|
0.7443609
|
com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheckTest.testParameter
com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheckTest.testParameter
|
1 PASS | |
| 443 tests are not displayed. This report was configured to show the top 10 tests that covered this file. | |||
| 1 | //////////////////////////////////////////////////////////////////////////////// | |
| 2 | // checkstyle: Checks Java source code for adherence to a set of rules. | |
| 3 | // Copyright (C) 2001-2005 Oliver Burn | |
| 4 | // | |
| 5 | // This library is free software; you can redistribute it and/or | |
| 6 | // modify it under the terms of the GNU Lesser General Public | |
| 7 | // License as published by the Free Software Foundation; either | |
| 8 | // version 2.1 of the License, or (at your option) any later version. | |
| 9 | // | |
| 10 | // This library is distributed in the hope that it will be useful, | |
| 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | // Lesser General Public License for more details. | |
| 14 | // | |
| 15 | // You should have received a copy of the GNU Lesser General Public | |
| 16 | // License along with this library; if not, write to the Free Software | |
| 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 18 | //////////////////////////////////////////////////////////////////////////////// | |
| 19 | package com.puppycrawl.tools.checkstyle.api; | |
| 20 | ||
| 21 | import org.apache.commons.beanutils.BeanUtilsBean; | |
| 22 | import org.apache.commons.beanutils.ConversionException; | |
| 23 | import org.apache.commons.beanutils.ConvertUtilsBean; | |
| 24 | import org.apache.commons.beanutils.PropertyUtils; | |
| 25 | import org.apache.commons.beanutils.PropertyUtilsBean; | |
| 26 | import org.apache.commons.beanutils.converters.AbstractArrayConverter; | |
| 27 | import org.apache.commons.beanutils.converters.BooleanArrayConverter; | |
| 28 | import org.apache.commons.beanutils.converters.BooleanConverter; | |
| 29 | import org.apache.commons.beanutils.converters.ByteArrayConverter; | |
| 30 | import org.apache.commons.beanutils.converters.ByteConverter; | |
| 31 | import org.apache.commons.beanutils.converters.CharacterArrayConverter; | |
| 32 | import org.apache.commons.beanutils.converters.CharacterConverter; | |
| 33 | import org.apache.commons.beanutils.converters.DoubleArrayConverter; | |
| 34 | import org.apache.commons.beanutils.converters.DoubleConverter; | |
| 35 | import org.apache.commons.beanutils.converters.FloatArrayConverter; | |
| 36 | import org.apache.commons.beanutils.converters.FloatConverter; | |
| 37 | import org.apache.commons.beanutils.converters.IntegerArrayConverter; | |
| 38 | import org.apache.commons.beanutils.converters.IntegerConverter; | |
| 39 | import org.apache.commons.beanutils.converters.LongArrayConverter; | |
| 40 | import org.apache.commons.beanutils.converters.LongConverter; | |
| 41 | import org.apache.commons.beanutils.converters.ShortArrayConverter; | |
| 42 | import org.apache.commons.beanutils.converters.ShortConverter; | |
| 43 | ||
| 44 | import java.beans.PropertyDescriptor; | |
| 45 | import java.lang.reflect.InvocationTargetException; | |
| 46 | import java.util.ArrayList; | |
| 47 | import java.util.List; | |
| 48 | import java.util.StringTokenizer; | |
| 49 | ||
| 50 | ||
| 51 | /** | |
| 52 | * A Java Bean that implements the component lifecycle interfaces by | |
| 53 | * calling the bean's setters for all configration attributes. | |
| 54 | * @author lkuehne | |
| 55 | */ | |
| 56 | public class AutomaticBean | |
| 57 | implements Configurable, Contextualizable | |
| 58 | { | |
| 59 | /** the configuration of this bean */ | |
| 60 | private Configuration mConfiguration; | |
| 61 | ||
| 62 | ||
| 63 | /** | |
| 64 | * Creates a BeanUtilsBean that is configured to use | |
| 65 | * type converters that throw a ConversionException | |
| 66 | * instead of using the default value when something | |
| 67 | * goes wrong. | |
| 68 | * | |
| 69 | * @return a configured BeanUtilsBean | |
| 70 | */ | |
| 71 | 2320 |
private static BeanUtilsBean createBeanUtilsBean() |
| 72 | { | |
| 73 | 2320 | final ConvertUtilsBean cub = new ConvertUtilsBean(); |
| 74 | ||
| 75 | // TODO: is there a smarter way to tell beanutils not to use defaults? | |
| 76 | ||
| 77 | 2320 | final boolean[] booleanArray = new boolean[0]; |
| 78 | 2320 | final byte[] byteArray = new byte[0]; |
| 79 | 2320 | final char[] charArray = new char[0]; |
| 80 | 2320 | final double[] doubleArray = new double[0]; |
| 81 | 2320 | final float[] floatArray = new float[0]; |
| 82 | 2320 | final int[] intArray = new int[0]; |
| 83 | 2320 | final long[] longArray = new long[0]; |
| 84 | 2320 | final short[] shortArray = new short[0]; |
| 85 | ||
| 86 | ||
| 87 | 2320 | cub.register(new BooleanConverter(), Boolean.TYPE); |
| 88 | 2320 | cub.register(new BooleanConverter(), Boolean.class); |
| 89 | 2320 | cub.register( |
| 90 | new BooleanArrayConverter(), booleanArray.getClass()); | |
| 91 | 2320 | cub.register(new ByteConverter(), Byte.TYPE); |
| 92 | 2320 | cub.register(new ByteConverter(), Byte.class); |
| 93 | 2320 | cub.register( |
| 94 | new ByteArrayConverter(byteArray), byteArray.getClass()); | |
| 95 | 2320 | cub.register(new CharacterConverter(), Character.TYPE); |
| 96 | 2320 | cub.register(new CharacterConverter(), Character.class); |
| 97 | 2320 | cub.register( |
| 98 | new CharacterArrayConverter(), charArray.getClass()); | |
| 99 | 2320 | cub.register(new DoubleConverter(), Double.TYPE); |
| 100 | 2320 | cub.register(new DoubleConverter(), Double.class); |
| 101 | 2320 | cub.register( |
| 102 | new DoubleArrayConverter(doubleArray), doubleArray.getClass()); | |
| 103 | 2320 | cub.register(new FloatConverter(), Float.TYPE); |
| 104 | 2320 | cub.register(new FloatConverter(), Float.class); |
| 105 | 2320 | cub.register(new FloatArrayConverter(), floatArray.getClass()); |
| 106 | 2320 | cub.register(new IntegerConverter(), Integer.TYPE); |
| 107 | 2320 | cub.register(new IntegerConverter(), Integer.class); |
| 108 | 2320 | cub.register(new IntegerArrayConverter(), intArray.getClass()); |
| 109 | 2320 | cub.register(new LongConverter(), Long.TYPE); |
| 110 | 2320 | cub.register(new LongConverter(), Long.class); |
| 111 | 2320 | cub.register(new LongArrayConverter(), longArray.getClass()); |
| 112 | 2320 | cub.register(new ShortConverter(), Short.TYPE); |
| 113 | 2320 | cub.register(new ShortConverter(), Short.class); |
| 114 | 2320 | cub.register(new ShortArrayConverter(), shortArray.getClass()); |
| 115 | // TODO: investigate: | |
| 116 | // StringArrayConverter doesn't properly convert an array of tokens with | |
| 117 | // elements containing an underscore, "_". | |
| 118 | // Hacked a replacement class :( | |
| 119 | // cub.register(new StringArrayConverter(), | |
| 120 | // String[].class); | |
| 121 | 2320 | cub.register(new StrArrayConverter(), String[].class); |
| 122 | 2320 | cub.register(new IntegerArrayConverter(), Integer[].class); |
| 123 | ||
| 124 | // BigDecimal, BigInteger, Class, Date, String, Time, TimeStamp | |
| 125 | // do not use defaults in the default configuration of ConvertUtilsBean | |
| 126 | ||
| 127 | 2320 | return new BeanUtilsBean(cub, new PropertyUtilsBean()); |
| 128 | } | |
| 129 | ||
| 130 | /** | |
| 131 | * Implements the Configurable interface using bean introspection. | |
| 132 | * | |
| 133 | * Subclasses are allowed to add behaviour. After the bean | |
| 134 | * based setup has completed first the method | |
| 135 | * {@link #finishLocalSetup finishLocalSetup} | |
| 136 | * is called to allow completion of the bean's local setup, | |
| 137 | * after that the method {@link #setupChild setupChild} | |
| 138 | * is called for each {@link Configuration#getChildren child Configuration} | |
| 139 | * of <code>aConfiguration</code>. | |
| 140 | * | |
| 141 | * @param aConfiguration {@inheritDoc} | |
| 142 | * @throws CheckstyleException {@inheritDoc} | |
| 143 | * @see Configurable | |
| 144 | */ | |
| 145 | 1389 |
public final void |