since 3.0

This commit is contained in:
Keith Donald 2009-06-13 18:25:59 +00:00
parent 079b856a6c
commit 42cdeb4302
51 changed files with 78 additions and 55 deletions

View File

@ -23,7 +23,7 @@ import org.springframework.ui.format.Formatter;
/**
* Binds user-entered values to properties of a model object.
* @author Keith Donald
*
* @since 3.0
* @param <M> The kind of model object this binder binds to
* @see #add(BindingConfiguration)
* @see #bind(UserValues)

View File

@ -18,6 +18,7 @@ package org.springframework.ui.binding;
/**
* A binding between a user interface element and a model property.
* @author Keith Donald
* @since 3.0
*/
public interface Binding {

View File

@ -21,6 +21,7 @@ import org.springframework.ui.format.Formatter;
/**
* Configuration used to create a new {@link Binding} registered with a {@link GenericBinder}.
* @author Keith Donald
* @since 3.0
* @see GenericBinder#add(BindingConfiguration)
*/
public class BindingConfiguration {

View File

@ -18,6 +18,7 @@ package org.springframework.ui.binding;
/**
* The result of a bind operation.
* @author Keith Donald
* @since 3.0
* @see Binder#bind(UserValues)
* @see Binding#setValue(Object)
*/

View File

@ -20,6 +20,7 @@ import java.util.List;
/**
* The results of a bind operation.
* @author Keith Donald
* @since 3.0
* @see Binder#bind(UserValues)
*/
public interface BindingResults extends Iterable<BindingResult> {

View File

@ -6,8 +6,8 @@ import org.springframework.ui.format.Formatter;
/**
* A centralized registry of Formatters indexed by property types.
*
* @author Keith Donald
* @since 3.0
*/
public interface FormatterRegistry {

View File

@ -18,7 +18,8 @@ package org.springframework.ui.binding;
/**
* Holds a user-entered value to bind to a model property.
* @author Keith Donald
* @see Binder#bind(List).
* @since 3.0
* @see Binder#bind(List)
*/
public class UserValue {

View File

@ -1,3 +1,18 @@
/*
* Copyright 2004-2009 the original author or authors.
*
* 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.springframework.ui.binding;
import java.util.ArrayList;
@ -6,9 +21,9 @@ import java.util.Iterator;
import java.util.List;
/**
* A simpler holder for a list of UserValues.
*
* A holder for a list of UserValues.
* @author Keith Donald
* @since 3.0
* @see Binder#bind(UserValues)
*/
public class UserValues implements Iterable<UserValue> {

View File

@ -57,8 +57,9 @@ import org.springframework.ui.format.AnnotationFormatterFactory;
import org.springframework.ui.format.Formatter;
/**
* A generic {@link Binder binder} suitable for use in most binding environments.
* A generic {@link Binder binder} suitable for use in most environments.
* @author Keith Donald
* @since 3.0
* @see #add(BindingConfiguration)
* @see #bind(UserValues)
*/

View File

@ -31,6 +31,7 @@ import org.springframework.ui.format.Formatter;
/**
* A generic implementation of {@link FormatterRegistry} suitable for use in most binding environments.
* @author Keith Donald
* @since 3.0
* @see #add(Formatter, Class)
* @see #add(AnnotationFormatterFactory)
*/

View File

@ -24,6 +24,7 @@ import org.springframework.ui.binding.UserValues;
* A binder designed for use in HTTP (web) environments.
* Suited for binding user-provided HTTP query parameters to model properties.
* @author Keith Donald
* @since 3.0
* @see #setDefaultPrefix(String)
* @see #setPresentPrefix(String)
*/

View File

@ -21,6 +21,7 @@ import java.lang.annotation.Annotation;
* A factory that creates {@link Formatter formatters} to format property values on properties annotated with a particular format {@link Annotation}.
* For example, a <code>CurrencyAnnotationFormatterFactory</code> might create a <code>Formatter</code> that formats a <code>BigDecimal</code> value set on a property annotated with <code>@CurrencyFormat</code>.
* @author Keith Donald
* @since 3.0
* @param <A> The type of Annotation this factory uses to create Formatter instances
* @param <T> The type of Object Formatters created by this factory format
*/

View File

@ -21,6 +21,7 @@ import java.util.Locale;
/**
* Formats objects of type T for display.
* @author Keith Donald
* @since 3.0
* @param <T> the type of object this formatter can format
*/
public interface Formatter<T> {

View File

@ -28,8 +28,9 @@ import org.springframework.ui.format.Formatter;
/**
* A formatter for {@link Date} types.
* Allows the configuration of an explicit date pattern and locale.
* @see SimpleDateFormat
* @author Keith Donald
* @since 3.0
* @see SimpleDateFormat
*/
public class DateFormatter implements Formatter<Date> {

View File

@ -31,6 +31,7 @@ import org.springframework.ui.format.Formatter;
* Sets the scale of parsed BigDecimal values to {@link NumberFormat#getMaximumFractionDigits()}.
* Applies {@link RoundingMode#DOWN} to parsed values.
* @author Keith Donald
* @since 3.0
*/
public class CurrencyFormatter implements Formatter<BigDecimal> {

View File

@ -23,6 +23,7 @@ import java.util.Locale;
/**
* Produces NumberFormat instances that format currency values.
* @author Keith Donald
* @since 3.0
* @see NumberFormat
*/
final class CurrencyNumberFormatFactory extends NumberFormatFactory {

View File

@ -29,6 +29,7 @@ import org.springframework.ui.format.Formatter;
* Configures BigDecimal parsing so there is no loss in precision.
* Allows configuration over the decimal number pattern; see {@link #DecimalFormatter(String)}.
* @author Keith Donald
* @since 3.0
*/
public class DecimalFormatter implements Formatter<BigDecimal> {

View File

@ -29,6 +29,7 @@ import org.apache.commons.logging.LogFactory;
* @author Keith Donald
* @see NumberFormat
* @see DecimalFormat
* @since 3.0
*/
class DefaultNumberFormatFactory extends NumberFormatFactory {

View File

@ -26,6 +26,7 @@ import org.springframework.ui.format.Formatter;
* A Long formatter for whole integer values.
* Delegates to {@link NumberFormat#getIntegerInstance(Locale)}.
* @author Keith Donald
* @since 3.0
*/
public class IntegerFormatter implements Formatter<Long> {

View File

@ -23,6 +23,7 @@ import java.util.Locale;
*
* @author Keith Donald
* @see NumberFormat
* @since 3.0
*/
final class IntegerNumberFormatFactory extends NumberFormatFactory {
public NumberFormat getNumberFormat(Locale locale) {

View File

@ -23,6 +23,7 @@ import java.util.Locale;
* caching number format instances.
*
* @author Keith Donald
* @since 3.0
*/
abstract class NumberFormatFactory {

View File

@ -28,6 +28,7 @@ import org.springframework.ui.format.Formatter;
* Delegates to {@link NumberFormat#getPercentInstance(Locale)}.
* Configures BigDecimal parsing so there is no loss in precision.
* @author Keith Donald
* @since 3.0
*/
public class PercentFormatter implements Formatter<BigDecimal> {

View File

@ -24,6 +24,7 @@ import java.util.Locale;
*
* @see NumberFormat
* @author Keith Donald
* @since 3.0
*/
final class PercentNumberFormatFactory extends NumberFormatFactory {
public NumberFormat getNumberFormat(Locale locale) {

View File

@ -33,7 +33,7 @@ import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.support.StandardEvaluationContext;
class DefaultMessageResolver implements MessageResolver, MessageSourceResolvable {
final class DefaultMessageResolver implements MessageResolver, MessageSourceResolvable {
private Severity severity;

View File

@ -20,6 +20,7 @@ package org.springframework.ui.message;
* For example, a error message may inform a user of a web application a business rule was violated.
* TODO - should we introduce summary/detail fields instead of just text
* @author Keith Donald
* @since 3.0
*/
public interface Message {

View File

@ -48,6 +48,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
* mathForm.decimalField=Decimal Field
* </pre>
* @author Keith Donald
* @since 3.0
* @see MessageContext#add(MessageResolver, String)
*/
public class MessageBuilder {

View File

@ -20,6 +20,8 @@ import java.util.Map;
/**
* A context for recording and retrieving messages for display in a user interface.
* @author Keith Donald
* @since 3.0
*/
public interface MessageContext {

View File

@ -18,6 +18,7 @@ package org.springframework.ui.message;
/**
* Runtime exception thrown by a {@link MessageResolver} if a message resolution fails.
* @author Keith Donald
* @since 3.0
*/
@SuppressWarnings("serial")
public class MessageResolutionException extends RuntimeException {

View File

@ -22,6 +22,7 @@ import org.springframework.context.MessageSource;
/**
* A factory for a localized Message.
* @author Keith Donald
* @since 3.0
* @see Message
* @see MessageSource
*/

View File

@ -19,7 +19,7 @@ package org.springframework.ui.message;
* Enum exposing supported message severities.
*
* @author Keith Donald
* @author Jeremy Grelle
* @since 3.0
* @see Message
*/
public enum Severity {

View File

@ -15,56 +15,46 @@
*/
package org.springframework.ui.message.support;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.context.support.AbstractMessageSource;
import org.springframework.core.style.ToStringCreator;
import org.springframework.ui.message.Message;
import org.springframework.ui.message.MessageContext;
import org.springframework.ui.message.MessageResolver;
import org.springframework.ui.message.Severity;
import org.springframework.util.Assert;
import org.springframework.util.CachingMapDecorator;
import edu.emory.mathcs.backport.java.util.Collections;
/**
* The default message context implementation.
* Uses a {@link MessageSource} to resolve messages that are added by callers.
*
* @author Keith Donald
* @since 3.0
*/
public class DefaultMessageContext implements MessageContext {
private MessageSource messageSource;
private final MessageSource messageSource;
@SuppressWarnings("serial")
private Map<String, ArrayList<Message>> messagesByElement = new CachingMapDecorator<String, ArrayList<Message>>(new LinkedHashMap<String, ArrayList<Message>>()) {
protected ArrayList<Message> create(String element) {
private Map<String, List<Message>> messagesByElement = new CachingMapDecorator<String, List<Message>>(new LinkedHashMap<String, List<Message>>()) {
protected List<Message> create(String element) {
return new ArrayList<Message>();
}
};
/**
* Creates a new default message context.
* Defaults to a message source that simply resolves default text and cannot resolve localized message codes.
*/
public DefaultMessageContext() {
init(null);
}
/**
* Creates a new default message context.
* @param messageSource the message source to resolve messages added to this context
*/
public DefaultMessageContext(MessageSource messageSource) {
init(messageSource);
Assert.notNull(messageSource, "The MessageSource is required");
this.messageSource = messageSource;
}
/**
@ -77,12 +67,10 @@ public class DefaultMessageContext implements MessageContext {
// implementing message context
@SuppressWarnings("unchecked")
public Map<String, List<Message>> getMessages() {
return Collections.unmodifiableMap(messagesByElement);
}
@SuppressWarnings("unchecked")
public List<Message> getMessages(String element) {
List<Message> messages = messagesByElement.get(element);
if (messages.isEmpty()) {
@ -102,23 +90,6 @@ public class DefaultMessageContext implements MessageContext {
// internal helpers
private void init(MessageSource messageSource) {
setMessageSource(messageSource);
}
private void setMessageSource(MessageSource messageSource) {
if (messageSource == null) {
messageSource = new DefaultTextFallbackMessageSource();
}
this.messageSource = messageSource;
}
private static class DefaultTextFallbackMessageSource extends AbstractMessageSource {
protected MessageFormat resolveCode(String code, Locale locale) {
return null;
}
}
class ResolvableMessage implements Message {
private MessageResolver resolver;

View File

@ -18,7 +18,6 @@ package org.springframework.ui.validation;
/**
* TODO Document ValidateResults.
*
* @author Keith Donald
* @since 3.0
*/

View File

@ -20,7 +20,6 @@ import java.util.List;
/**
* TODO Document Validator.
*
* @author Keith Donald
* @since 3.0
*/

View File

@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
/**
* Base class for {@link EmbeddedDatabaseConfigurer} implementations providing common shutdown behaviour.
* @author Oliver Gierke
* @since 3.0
*/
abstract class AbstractEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigurer {

View File

@ -20,8 +20,8 @@ import org.springframework.core.io.support.EncodedResource;
/**
* Thrown by {@link ResourceDatabasePopulator} if one of its SQL scripts could
* not be read during population.
*
* @author Keith Donald
* @since 3.0
*/
@SuppressWarnings("serial")
public class CannotReadScriptException extends RuntimeException {

View File

@ -19,6 +19,7 @@ package org.springframework.jdbc.datasource.embedded;
* DataSourceFactory helper that allows essential JDBC connection properties to be configured consistently,
* independent of the actual DataSource implementation.
* @author Keith Donald
* @since 3.0
* @see DataSourceFactory
*/
public interface ConnectionProperties {

View File

@ -22,7 +22,8 @@ import org.springframework.jdbc.datasource.SimpleDriverDataSource;
/**
* Encapsulates the creation of a particular DataSource implementation, such as a {@link SimpleDriverDataSource} or connection pool such as Apache DBCP or c3p0.
* Call {@link #getConnectionProperties()} to configure normalized DataSource properties before calling {@link #getDataSource()} to actually get the configured DataSource instance.
* @author Keith Donald
* @author Keith Donald
* @since 3.0
*/
public interface DataSourceFactory {

View File

@ -21,6 +21,7 @@ import java.sql.SQLException;
/**
* Strategy used to populate an embedded database during initialization.
* @author Keith Donald
* @since 3.0
* @see ResourceDatabasePopulator
*/
public interface DatabasePopulator {

View File

@ -32,8 +32,8 @@ import org.springframework.util.ClassUtils;
/**
* {@link EmbeddedDatabaseConfigurer} for the Apache Derby database.
*
* @author Oliver Gierke
* @since 3.0
*/
final class DerbyEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigurer {

View File

@ -22,6 +22,7 @@ import javax.sql.DataSource;
* Is a {@link DataSource}.
* Adds a shutdown operation so the embedded database instance can be shutdown.
* @author Keith Donald
* @since 3.0
*/
public interface EmbeddedDatabase extends DataSource {

View File

@ -29,6 +29,7 @@ import org.springframework.core.io.ResourceLoader;
* db.shutdown();
* </pre>
* @author Keith Donald
* @since 3.0
*/
public class EmbeddedDatabaseBuilder {

View File

@ -21,6 +21,7 @@ import javax.sql.DataSource;
* Encapsulates the configuration required to create, connect to, and shutdown a specific type of embedded database such as HSQL or H2.
* Create a implementation for each database type you wish to support; for example HSQL, H2, or some other type.
* @author Keith Donald
* @since 3.0
*/
public interface EmbeddedDatabaseConfigurer {

View File

@ -22,6 +22,7 @@ import org.springframework.util.Assert;
* strategies.
* @author Keith Donald
* @author Oliver Gierke
* @since 3.0
*/
final class EmbeddedDatabaseConfigurerFactory {

View File

@ -36,8 +36,8 @@ import org.springframework.util.Assert;
* Call {@link #setDatabasePopulator(DatabasePopulator)} to change the algorithm used to populate the database.<br>
* Call {@link #setDataSourceFactory(DataSourceFactory)} to change the type of DataSource used to connect to the database.<br>
* Call {@link #getDatabase()} to get the {@link EmbeddedDatabase} instance.<br>
*
* @author Keith Donald
* @since 3.0
*/
public class EmbeddedDatabaseFactory {

View File

@ -26,8 +26,8 @@ import org.springframework.beans.factory.InitializingBean;
* Returns the actual {@link DataSource} that provides connectivity to the embedded database to Spring.
* The target DataSource is returned instead of a {@link EmbeddedDatabase} proxy since the FactoryBean will manage the initialization and destruction lifecycle of the database instance.
* Implements DisposableBean to shutdown the embedded database when the managing Spring container is shutdown.
*
* @author Keith Donald
* @since 3.0
*/
public class EmbeddedDatabaseFactoryBean extends EmbeddedDatabaseFactory implements FactoryBean<DataSource>, InitializingBean, DisposableBean {

View File

@ -19,6 +19,7 @@ package org.springframework.jdbc.datasource.embedded;
* A supported embedded database type.
* @author Keith Donald
* @author Oliver Gierke
* @since 3.0
*/
public enum EmbeddedDatabaseType {
HSQL, H2, DERBY;

View File

@ -20,8 +20,8 @@ import org.springframework.util.ClassUtils;
/**
* Initializes an H2 embedded database instance.
* Call {@link #getInstance()} to get the singleton instance of this class.
*
* @author Oliver Gierke
* @since 3.0
*/
final class H2EmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigurer {

View File

@ -20,9 +20,9 @@ import org.springframework.util.ClassUtils;
/**
* Initializes an HSQL embedded database instance.
* Call {@link #getInstance()} to get the singleton instance of this class.
*
* @author Keith Donald
* @author Oliver Gierke
* @since 3.0
*/
final class HsqlEmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigurer {

View File

@ -30,6 +30,7 @@ import org.springframework.jdbc.CannotGetJdbcConnectionException;
* Note there is some duplication here with JdbcUtils in jdbc.support package.
* We may want to consider simply using that at some point.
* @author Keith Donald
* @since 3.0
*/
final class JdbcUtils {

View File

@ -36,6 +36,8 @@ import org.springframework.util.StringUtils;
* <p>
* Call {@link #addScript(Resource)} to add a SQL script location.<br>
* Call {@link #setSqlScriptEncoding(String)} to set the encoding for all added scripts.<br>
* @author Keith Donald
* @since 3.0
*/
public class ResourceDatabasePopulator implements DatabasePopulator {

View File

@ -22,6 +22,7 @@ import org.springframework.jdbc.datasource.SimpleDriverDataSource;
/**
* Creates a {@link SimpleDriverDataSource}.
* @author Keith Donald
* @since 3.0
*/
final class SimpleDriverDataSourceFactory implements DataSourceFactory {