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