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.xbean.propertyeditor;
018    
019    import java.beans.PropertyEditor;
020    
021    /**
022     * @version $Rev: 6680 $ $Date: 2005-12-24T04:38:27.427468Z $
023     */
024    public interface Converter extends PropertyEditor {
025        /**
026         * Gets the the type of object supported by this converter.
027         * @return
028         */
029        Class getType();
030    
031        /**
032         * Converts the supplied object to text.  If value is null, null will be returned.  If value is not an instance of
033         * the this converter's type, a PropertyEditorException will be thrown.
034         *
035         * @param value an instance of the editor type
036         * @return the text equivalent of the value
037         * @throws PropertyEditorException if an error occurs while converting the value to a String (this is very rare)
038         */
039        String toString(Object value) throws PropertyEditorException;
040    
041        /**
042         * Converts the supplied text in to an instance of the editor type.  If text is null, null will be returned.
043         *
044         * @param text the text to convert
045         * @return an instance of the editor type
046         * @throws PropertyEditorException if an error occurs while converting the text to an object
047         */
048        Object toObject(String text) throws PropertyEditorException;
049    }