All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.thymeleaf.standard.expression.IStandardConversionService Maven / Gradle / Ivy

Go to download

Modern server-side Java template engine for both web and standalone environments

There is a newer version: 3.1.2.RELEASE
Show newest version
/*
 * =============================================================================
 *
 *   Copyright (c) 2011-2018, The THYMELEAF team (http://www.thymeleaf.org)
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 * =============================================================================
 */
package org.thymeleaf.standard.expression;

import org.thymeleaf.context.IExpressionContext;

/**
 * 

* Common interface for all implementations of a conversion service, to be used during template execution. *

*

* Thymeleaf conversion services work in a way similar to Spring Framework's {@code ConversionService} interface, * but this is a generic mechanism (not dependent on Spring). *

*

* Default implementation —registered by {@link org.thymeleaf.standard.StandardDialect}— * is {@link StandardConversionService}, which performs some standard conversions, but the * Spring Standard Dialect used by the Thymeleaf + Spring integration module automatically registers an implementation * of this interface that delegates on any existing Spring {@code ConversionService} objects (thus using * the Converters and Formatters registered at the Spring Application Context). *

*

* Important: there is one conversion that implementations of this interface should * always implement, because it is heavily used at the Thymeleaf core: conversion of any Object to String. *

*

* The implementation of this interface that should be used is specified as an execution attribute * by the Standard Dialects (see {@link org.thymeleaf.standard.StandardDialect#getExecutionAttributes()}). *

*

* Implementations of this interface should be thread-safe. *

* * @author Daniel Fernández * * @since 2.1.0 * */ public interface IStandardConversionService { /** *

* Convert a value to the specified target class, if possible. *

*

* Might raise an exception (usually {@link IllegalArgumentException}) if a conversion is not available * for the specified object and the target class. *

* * @param the type of the target class * @param context the context object. * @param object the object to be converted. * @param targetClass the target class the object should be converted to. * @return the object, converted. Or an exception if the conversion has not been possible. */ public T convert(final IExpressionContext context, final Object object, final Class targetClass); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy