    1   /*
    2    * Copyright 2004-2009 the Seasar Foundation and the Others.
    3    *
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    *
    8    *     http://www.apache.org/licenses/LICENSE-2.0
    9    *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
    13   * either express or implied. See the License for the specific language
    14   * governing permissions and limitations under the License.
    15   */
    16  package org.seasar.cubby.mock;
    17
    18  import java.util.ArrayList;
    19  import java.util.Arrays;
    20  import java.util.Collection;
    21  import java.util.List;
    22
    23  import org.seasar.cubby.converter.Converter;
    24  import org.seasar.cubby.converter.impl.BigDecimalConverter;
    25  import org.seasar.cubby.converter.impl.BigIntegerConverter;
    26  import org.seasar.cubby.converter.impl.BooleanConverter;
    27  import org.seasar.cubby.converter.impl.ByteArrayFileItemConverter;
    28  import org.seasar.cubby.converter.impl.ByteConverter;
    29  import org.seasar.cubby.converter.impl.CharacterConverter;
    30  import org.seasar.cubby.converter.impl.DateConverter;
    31  import org.seasar.cubby.converter.impl.DoubleConverter;
    32  import org.seasar.cubby.converter.impl.EnumConverter;
    33  import org.seasar.cubby.converter.impl.FloatConverter;
    34  import org.seasar.cubby.converter.impl.InputStreamFileItemConverter;
    35  import org.seasar.cubby.converter.impl.IntegerConverter;
    36  import org.seasar.cubby.converter.impl.LongConverter;
    37  import org.seasar.cubby.converter.impl.ShortConverter;
    38  import org.seasar.cubby.converter.impl.SqlDateConverter;
    39  import org.seasar.cubby.converter.impl.SqlTimeConverter;
    40  import org.seasar.cubby.converter.impl.SqlTimestampConverter;
    41  import org.seasar.cubby.spi.impl.AbstractCachedConverterProvider;
    42
    43  public class MockConverterProvider extends AbstractCachedConverterProvider {
    44
    45  	private final List<Converter> converters;
    46
    47  	private final List<Converter> defaults = Arrays.asList(new Converter[] {
    48  			new BigDecimalConverter(),
    49  			new BigIntegerConverter(),
    50  			new BooleanConverter(),
    51  			new ByteArrayFileItemConverter(),
    52  			new ByteConverter(),
    53  			new CharacterConverter(),
    54  			new DateConverter(),
    55  			new DoubleConverter(),
    56  			new EnumConverter(),
    57  			new FloatConverter(),
    58  			new InputStreamFileItemConverter(),
    59  			new IntegerConverter(),
    60  			new LongConverter(),
    61  			new ShortConverter(),
    62  			new SqlDateConverter(),
    63  			new SqlTimeConverter(),
    64  			new SqlTimestampConverter() });
    65
    66  	public MockConverterProvider(Converter... additionalConverters) {
    67  		final List<Converter> converters = new ArrayList<Converter>();
    68  		converters.addAll(defaults);
    69  		for (final Converter additionalConverter : additionalConverters) {
    70  			converters.add(additionalConverter);
    71  		}
    72  		this.converters = converters;
    73  	}
    74
    75  	@Override
    76  	protected Collection<Converter> getConverters() {
    77  		return converters;
    78  	}
    79
    80  }