001    // Copyright 2007, 2008, 2011 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.tapestry5.services;
016    
017    import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
018    import org.apache.tapestry5.ioc.annotations.UsesOrderedConfiguration;
019    import org.apache.tapestry5.ioc.services.PropertyAdapter;
020    
021    /**
022     * Used by {@link BeanModelSource} to identify the type of data associated with a particular property (represented as a
023     * {@link PropertyAdapter}). The data type is a string used to determine what kind of interface to use for displaying
024     * the value of the property, or what kind of interface to use for editing the value of the property. Common property
025     * types are "text", "enum", "checkbox", but the list is extensible.
026     * <p/>
027     * Different strategies for identifying the data type are encapsulated in the DataTypeAnalyzer service, forming a
028     * chain of command.
029     * <p/>
030     * The DefaultDataTypeAnalyzer service maps property types to data type names.
031     * <p/>
032     * The DataTypeAnalyzer service is an extensible {@linkplain org.apache.tapestry5.ioc.services.ChainBuilder chain of
033     * command}), that (by default) includes {@link org.apache.tapestry5.internal.services.AnnotationDataTypeAnalyzer} and
034     * the {@link org.apache.tapestry5.internal.services.DefaultDataTypeAnalyzer} service (ordered last).   It uses an ordered configuration.
035     *
036     * @see org.apache.tapestry5.corelib.components.Grid
037     * @see org.apache.tapestry5.corelib.components.BeanEditForm
038     * @see BeanBlockSource
039     */
040    @UsesOrderedConfiguration(DataTypeAnalyzer.class)
041    @UsesMappedConfiguration(key = Class.class, value = String.class)
042    public interface DataTypeAnalyzer
043    {
044        /**
045         * Identifies the data type, if known, or returns null if not known.
046         */
047        String identifyDataType(PropertyAdapter adapter);
048    }