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     */
017    package 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 $Revision: 552381 $ $Date: 2007-07-02 03:00:17 +0100 (Mon, 02 Jul 2007) $
030     * @since 1.8.0
031     */
032    public 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
040         *
041         * @see ConvertUtilsBean#convert(String[], Class)
042         */
043        public String convert(Object value) {
044            return (String)convert(value, String.class);
045        }
046    
047        /**
048         * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)}
049         * method.
050         *
051         * @param value Value to be converted (may be null)
052         * @param clazz Java class to be converted to
053         * @return The converted value
054         *
055         * @see ConvertUtilsBean#convert(String[], Class)
056         */
057        public Object convert(String value, Class clazz) {
058            return convert((Object)value, clazz);
059        }
060    
061        /**
062         * Delegates to the new {@link ConvertUtilsBean#convert(Object, Class)}
063         * method.
064         *
065         * @param value Array of values to be converted
066         * @param clazz Java array or element class to be converted to
067         * @return The converted value
068         *
069         * @see ConvertUtilsBean#convert(String[], Class)
070         */
071        public Object convert(String[] value, Class clazz) {
072            return convert((Object)value, clazz);
073        }
074    
075    }