001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.beanutils; 018 019/** 020 * {@link ConvertUtilsBean} implementation that delegates <code>convert()</code> 021 * methods to the new {@link ConvertUtilsBean#convert(Object, Class)} method. 022 * 023 * <p> 024 * To configure this implementation for the current context ClassLoader invoke 025 * <code>BeanUtilsBean.setInstance(new BeanUtilsBean2());</code> 026 * </p> 027 * 028 * @see BeanUtilsBean2 029 * @version $Id$ 030 * @since 1.8.0 031 */ 032public class ConvertUtilsBean2 extends ConvertUtilsBean { 033 034 /** 035 * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)} 036 * method. 037 * 038 * @param value Value to be converted (may be null) 039 * @return The converted String value or null if value is null 040 * 041 * @see ConvertUtilsBean#convert(String[], Class) 042 */ 043 @Override 044 public String convert(final Object value) { 045 return (String)convert(value, String.class); 046 } 047 048 /** 049 * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)} 050 * method. 051 * 052 * @param value Value to be converted (may be null) 053 * @param clazz Java class to be converted to (must not be null) 054 * @return The converted value or null if value is null 055 * 056 * @see ConvertUtilsBean#convert(String[], Class) 057 */ 058 @Override 059 public Object convert(final String value, final Class<?> clazz) { 060 return convert((Object)value, clazz); 061 } 062 063 /** 064 * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)} 065 * method. 066 * 067 * @param value Array of values to be converted 068 * @param clazz Java array or element class to be converted to (must not be null) 069 * @return The converted value 070 * 071 * @see ConvertUtilsBean#convert(String[], Class) 072 */ 073 @Override 074 public Object convert(final String[] value, final Class<?> clazz) { 075 return convert((Object)value, clazz); 076 } 077 078}