1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.commons.beanutils; 18 19 /** 20 * {@link ConvertUtilsBean} implementation that delegates <code>convert()</code> 21 * methods to the new {@link ConvertUtilsBean#convert(Object, Class)} method. 22 * 23 * <p> 24 * To configure this implementation for the current context ClassLoader invoke 25 * <code>BeanUtilsBean.setInstance(new BeanUtilsBean2());</code> 26 * </p> 27 * 28 * @see BeanUtilsBean2 29 * @version $Id$ 30 * @since 1.8.0 31 */ 32 public class ConvertUtilsBean2 extends ConvertUtilsBean { 33 34 /** 35 * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)} 36 * method. 37 * 38 * @param value Value to be converted (may be null) 39 * @return The converted String value or null if value is null 40 * 41 * @see ConvertUtilsBean#convert(String[], Class) 42 */ 43 @Override 44 public String convert(final Object value) { 45 return (String)convert(value, String.class); 46 } 47 48 /** 49 * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)} 50 * method. 51 * 52 * @param value Value to be converted (may be null) 53 * @param clazz Java class to be converted to (must not be null) 54 * @return The converted value or null if value is null 55 * 56 * @see ConvertUtilsBean#convert(String[], Class) 57 */ 58 @Override 59 public Object convert(final String value, final Class<?> clazz) { 60 return convert((Object)value, clazz); 61 } 62 63 /** 64 * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)} 65 * method. 66 * 67 * @param value Array of values to be converted 68 * @param clazz Java array or element class to be converted to (must not be null) 69 * @return The converted value 70 * 71 * @see ConvertUtilsBean#convert(String[], Class) 72 */ 73 @Override 74 public Object convert(final String[] value, final Class<?> clazz) { 75 return convert((Object)value, clazz); 76 } 77 78 }