[hibernate-commits] Hibernate SVN: r15751 - in validator/trunk: hibernate-validator/src/main/java/org/hibernate/validation/engine and 9 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Jan 7 10:32:23 EST 2009


Author: hardy.ferentschik
Date: 2009-01-07 10:32:23 -0500 (Wed, 07 Jan 2009)
New Revision: 15751

Added:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationDescriptor.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationFactory.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationProxy.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/FrenchZipcode.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/FrenchZipcodeConstraint.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/ValidProperty.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java
   validator/trunk/license.txt
Removed:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProvider.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProviderImpl.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/javadoc/
Modified:
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintContextImpl.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidationContext.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImplementor.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/BeanDescriptorImpl.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ValidatorFactoryImpl.java
   validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthConstraintTest.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/NoGroups.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/NoMessage.java
   validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java
   validator/trunk/pom.xml
   validator/trunk/validation-api/src/main/java/javax/validation/ConstraintContext.java
   validator/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java
Log:
BVAL-31 refactored some code, imported AnnotationFactory from annotations commons, added explicit license to project

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java (from rev 15744, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProvider.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -0,0 +1,81 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.hibernate.validation.engine;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Member;
+import java.util.List;
+import java.util.Map;
+import javax.validation.ElementDescriptor;
+import javax.validation.BeanDescriptor;
+import javax.validation.PropertyDescriptor;
+
+/**
+ * Interface defining the meta data about the constraints defined in a given bean.
+ *
+ * @author Hardy Ferentschik
+ */
+public interface BeanMetaData<T> {
+
+	/**
+	 * @return the class of the bean.
+	 */
+	Class<T> getBeanClass();
+
+	/**
+	 * @return an instance of <code>ElementDescriptor</code> describing the bean this meta data applies for.
+	 */
+	BeanDescriptor getBeanDescriptor();
+
+	/**
+	 * @return A list of all cascaded fields (fields annotated with &#064;Valid).
+	 */
+	List<Field> getCascadedFields();
+
+	/**
+	 * @return A list of all cascaded methods (methods annotated with &#064;Valid).
+	 */
+	List<Method> getCascadedMethods();
+
+	/**
+	 * @return A list of all cascaded methods and fields (methods/fields annotated with &#064;Valid).
+	 */
+	List<Member> getCascadedMembers();
+
+	/**
+	 * @return A map mapping defined group sequences to a list of groups.
+	 */
+	Map<Class<?>, List<Class<?>>> getGroupSequences();
+
+	/**
+	 * @return A list of <code>ValidatorMetaData</code> instances encapsulating the information of all the constraints
+	 *         defined on the bean.
+	 */
+	List<MetaConstraint> getConstraintMetaDataList();
+
+	/**
+	 * @return A map keying the property name of a constraint to its <code>ElementDescriptor</code>.
+	 *
+	 * @todo Maybe needs to be removed since this data structure is ambigious. There could be conflicts between field and
+	 * methods.
+	 */
+	Map<String, PropertyDescriptor> getPropertyDescriptors();
+
+	ElementDescriptor getPropertyDescriptors(String property);
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java
___________________________________________________________________
Name: svn:keywords
   + Id

Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java (from rev 15744, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProviderImpl.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -0,0 +1,432 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.hibernate.validation.engine;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.validation.BeanDescriptor;
+import javax.validation.Constraint;
+import javax.validation.ConstraintFactory;
+import javax.validation.ConstraintValidator;
+import javax.validation.GroupSequence;
+import javax.validation.GroupSequences;
+import javax.validation.PropertyDescriptor;
+import javax.validation.Valid;
+import javax.validation.ValidationException;
+
+import org.slf4j.Logger;
+
+import org.hibernate.validation.impl.ConstraintDescriptorImpl;
+import org.hibernate.validation.impl.ConstraintFactoryImpl;
+import org.hibernate.validation.impl.ElementDescriptorImpl;
+import org.hibernate.validation.impl.BeanDescriptorImpl;
+import org.hibernate.validation.util.LoggerFactory;
+import org.hibernate.validation.util.ReflectionHelper;
+
+
+/**
+ * This class encapsulates all meta data needed for validation. Implementations of <code>Validator</code> interface can
+ * instantiate an instance of this class and delegate the metadata extraction to it.
+ *
+ * @author Hardy Ferentschik
+ * FIXME create an interface for MetadataProvider
+ */
+
+public class BeanMetaDataImpl<T> implements BeanMetaData<T> {
+
+	private static final Logger log = LoggerFactory.make();
+
+	/**
+	 * The root bean class for this validator.
+	 */
+	private final Class<T> beanClass;
+
+	/**
+	 * The main element descriptor for <code>beanClass</code>.
+	 */
+	private BeanDescriptorImpl<T> beanDescriptor;
+
+	/**
+	 * List of constraints.
+	 */
+	private List<MetaConstraint> metaConstraintList = new ArrayList<MetaConstraint>();
+
+	/**
+	 * List of cascaded fields.
+	 */
+	private List<Field> cascadedFields = new ArrayList<Field>();
+
+	/**
+	 * List of cascaded methods.
+	 */
+	private List<Method> cascadedMethods = new ArrayList<Method>();
+
+	/**
+	 * Maps field and method names to their <code>ElementDescriptorImpl</code>.
+	 * FIXME This model is problematic as you can have conflicting names for fields and methods
+	 */
+	private Map<String, PropertyDescriptor> propertyDescriptors = new HashMap<String, PropertyDescriptor>();
+
+	/**
+	 * Factory to create acutal constraint instances from the annotated fields/method/class.
+	 */
+	private ConstraintFactory constraintFactory = new ConstraintFactoryImpl();
+
+	/**
+	 * Maps group sequences to the list of group/sequences.
+	 */
+	private Map<Class<?>, List<Class<?>>> groupSequences = new HashMap<Class<?>, List<Class<?>>>();
+
+	public BeanMetaDataImpl(Class<T> beanClass, ConstraintFactory constraintFactory) {
+		this.beanClass = beanClass;
+		this.constraintFactory = constraintFactory;
+		createMetaData();
+	}
+
+	/**
+	 * Create bean desciptor, find all classes/subclasses/interfaces which have to be taken in consideration
+	 * for this validator and create meta data.
+	 */
+	private void createMetaData() {
+		beanDescriptor = new BeanDescriptorImpl<T>( beanClass, this );
+		List<Class> classes = new ArrayList<Class>();
+		computeClassHierarchy( beanClass, classes );
+		for ( Class current : classes ) {
+			initClass( current );
+		}
+	}
+
+	/**
+	 * Get all superclasses and interfaces recursively.
+	 *
+	 * @param clazz The class to start the search with.
+	 * @param classes List of classes to which to add all found super classes and interfaces.
+	 */
+	private void computeClassHierarchy(Class clazz, List<Class> classes) {
+		if ( log.isTraceEnabled() ) {
+			log.trace( "Processing: {}", clazz );
+		}
+		for ( Class current = clazz; current != null; current = current.getSuperclass() ) {
+			if ( classes.contains( current ) ) {
+				return;
+			}
+			classes.add( current );
+			for ( Class currentInterface : current.getInterfaces() ) {
+				computeClassHierarchy( currentInterface, classes );
+			}
+		}
+	}
+
+	private void initClass(Class clazz) {
+		initGroupSequences( clazz );
+		initClassConstraints( clazz );
+		initMethodConstraints( clazz );
+		initFieldConstraints( clazz );
+	}
+
+	private void initGroupSequences(Class<?> clazz) {
+		GroupSequence groupSequenceAnnotation = clazz.getAnnotation( GroupSequence.class );
+		if ( groupSequenceAnnotation != null ) {
+			addGroupSequence( groupSequenceAnnotation );
+		}
+
+		GroupSequences groupSequencesAnnotation = clazz.getAnnotation( GroupSequences.class );
+		if ( groupSequencesAnnotation != null ) {
+			for ( GroupSequence group : groupSequencesAnnotation.value() ) {
+				addGroupSequence( group );
+			}
+		}
+
+		for ( Map.Entry<Class<?>, List<Class<?>>> mapEntry : groupSequences.entrySet() ) {
+			List<Class<?>> groups = mapEntry.getValue();
+			List<Class<?>> expandedGroups = new ArrayList<Class<?>>();
+			for ( Class<?> group : groups ) {
+				expandedGroups.addAll( expandGroupSequences( group ) );
+			}
+			groupSequences.put( mapEntry.getKey(), expandedGroups );
+		}
+		if ( log.isDebugEnabled() && !groupSequences.isEmpty() ) {
+			log.debug( "Expanded groups sequences: {}", groupSequences );
+		}
+	}
+
+	private List<Class<?>> expandGroupSequences(Class<?> group) {
+		List<Class<?>> groupList = new ArrayList<Class<?>>();
+		if ( groupSequences.containsKey( group ) ) {
+			for ( Class<?> localGroup : groupSequences.get( group ) ) {
+				groupList.addAll( expandGroupSequences( localGroup ) );
+			}
+		}
+		else {
+			groupList.add( group );
+		}
+		if ( log.isTraceEnabled() ) {
+			log.trace( "Expanded {} to {}", group, groupList.toString() );
+		}
+		return groupList;
+	}
+
+	private void addGroupSequence(GroupSequence groupSequence) {
+		if ( groupSequences.containsKey( groupSequence.name() ) ) {
+			throw new ValidationException( "Encountered duplicate sequence name: " + groupSequence.name() );
+		}
+		groupSequences.put( groupSequence.name(), Arrays.asList( groupSequence.sequence() ) );
+	}
+
+	private void initFieldConstraints(Class clazz) {
+		for ( Field field : clazz.getDeclaredFields() ) {
+			List<ConstraintDescriptorImpl> fieldMetadata = findFieldLevelConstraints( field );
+			for ( ConstraintDescriptorImpl constraintDescription : fieldMetadata ) {
+				ReflectionHelper.setAccessibility( field );
+				MetaConstraint metaConstraint = new MetaConstraint( field, constraintDescription );
+				metaConstraintList.add( metaConstraint );
+			}
+			if ( field.isAnnotationPresent( Valid.class ) ) {
+				cascadedFields.add( field );
+			}
+		}
+	}
+
+	private void initMethodConstraints(Class clazz) {
+		for ( Method method : clazz.getDeclaredMethods() ) {
+			List<ConstraintDescriptorImpl> methodMetadata = findMethodLevelConstraints( method );
+			for ( ConstraintDescriptorImpl constraintDescription : methodMetadata ) {
+				ReflectionHelper.setAccessibility( method );
+				MetaConstraint metaConstraint = new MetaConstraint( method, constraintDescription );
+				metaConstraintList.add( metaConstraint );
+			}
+			if ( method.isAnnotationPresent( Valid.class ) ) {
+				cascadedMethods.add( method );
+			}
+		}
+	}
+
+	private void initClassConstraints(Class clazz) {
+		List<ConstraintDescriptorImpl> classMetadata = findClassLevelConstraints( clazz );
+		for ( ConstraintDescriptorImpl constraintDescription : classMetadata ) {
+			MetaConstraint metaConstraint = new MetaConstraint( clazz, constraintDescription );
+			metaConstraintList.add( metaConstraint );
+		}
+	}
+
+	/**
+	 * Examines the given annotation to see whether it is a single or multi valued constraint annotation.
+	 *
+	 * @param annotation The annotation to examine.
+	 *
+	 * @return A list of constraint descriptors or the empty list in case <code>annotation</code> is neither a
+	 *         single nor multi value annotation.
+	 */
+	private <A extends Annotation> List<ConstraintDescriptorImpl> findConstraintAnnotations(A annotation) {
+		List<ConstraintDescriptorImpl> constraintDescriptors = new ArrayList<ConstraintDescriptorImpl>();
+
+		List<Annotation> constraints = new ArrayList<Annotation>();
+		if ( ReflectionHelper.isConstraintAnnotation( annotation ) ||
+				ReflectionHelper.isBuiltInConstraintAnnotation( annotation) ) {
+			constraints.add( annotation );
+		}
+
+		// check if we have a multi value constraint
+		constraints.addAll( ReflectionHelper.getMultiValueConstraints( annotation ) );
+
+		for ( Annotation constraint : constraints ) {
+			if ( ReflectionHelper.isBuiltInConstraintAnnotation( constraint ) ) {
+				Class constraintClass = ReflectionHelper.getBuiltInConstraint( constraint );
+				final ConstraintDescriptorImpl constraintDescriptor = buildConstraintDescriptor(
+						constraint, constraintClass
+				);
+				constraintDescriptors.add( constraintDescriptor );
+				continue;
+			}
+
+			if ( ReflectionHelper.isConstraintAnnotation( constraint ) ) {
+				ConstraintValidator constraintValidator = constraint.annotationType()
+						.getAnnotation( ConstraintValidator.class );
+				final ConstraintDescriptorImpl constraintDescriptor = buildConstraintDescriptor(
+						constraint, constraintValidator.value()
+				);
+				constraintDescriptors.add( constraintDescriptor );
+			}
+		}
+		return constraintDescriptors;
+	}
+
+	@SuppressWarnings("unchecked")
+	private <A extends Annotation> ConstraintDescriptorImpl buildConstraintDescriptor(A annotation, Class constraintClass) {
+		Class<?>[] groups = ReflectionHelper.getAnnotationParameter( annotation, "groups", Class[].class );
+		for ( Class<?> groupName : groups ) {
+			if ( groupSequences.containsKey( groupName ) ) {
+				throw new ValidationException( groupName + " is illegally used as group and sequence name." );
+			}
+		}
+
+		Constraint<A> constraint;
+		try {
+			//unchecked
+			constraint = constraintFactory.getInstance( constraintClass );
+		}
+		catch ( RuntimeException e ) {
+			throw new ValidationException( "Unable to instantiate " + constraintClass, e );
+		}
+
+		try {
+			constraint.initialize( annotation );
+		}
+		catch ( RuntimeException e ) {
+			throw new ValidationException( "Unable to intialize " + constraint.getClass().getName(), e );
+		}
+
+		return new ConstraintDescriptorImpl( annotation, groups, constraint, constraintClass );
+	}
+
+	/**
+	 * Finds all constraint annotations defined for the given class and returns them in a list of
+	 * constraint descriptors.
+	 *
+	 * @param beanClass The class to check for constraints annotations.
+	 *
+	 * @return A list of constraint descriptors for all constraint specified on the given class.
+	 *
+	 * @todo inject XML data here, probably externalizing the process
+	 */
+	private List<ConstraintDescriptorImpl> findClassLevelConstraints(Class beanClass) {
+		List<ConstraintDescriptorImpl> metadata = new ArrayList<ConstraintDescriptorImpl>();
+		for ( Annotation annotation : beanClass.getAnnotations() ) {
+			metadata.addAll( findConstraintAnnotations( annotation ) );
+		}
+		for ( ConstraintDescriptorImpl constraintDescriptor : metadata ) {
+			beanDescriptor.addConstraintDescriptor( constraintDescriptor );
+		}
+		return metadata;
+	}
+
+	/**
+	 * Finds all constraint annotations defined for the given methods and returns them in a list of
+	 * constraint descriptors.
+	 *
+	 * @param method The method to check for constraints annotations.
+	 *
+	 * @return A list of constraint descriptors for all constraint specified for the given method.
+	 *
+	 * @todo inject XML data here, probably externalizing the process
+	 */
+	private List<ConstraintDescriptorImpl> findMethodLevelConstraints(Method method) {
+		List<ConstraintDescriptorImpl> metadata = new ArrayList<ConstraintDescriptorImpl>();
+		for ( Annotation annotation : method.getAnnotations() ) {
+			metadata.addAll( findConstraintAnnotations( annotation ) );
+		}
+
+		String methodName = ReflectionHelper.getPropertyName( method );
+		for ( ConstraintDescriptorImpl constraintDescriptor : metadata ) {
+			if ( methodName == null ) {
+				throw new ValidationException(
+						"Annoated methods must follow the JavaBeans naming convention. " + method.getName() + "() does not."
+				);
+			}
+			ElementDescriptorImpl elementDescriptor = ( ElementDescriptorImpl ) propertyDescriptors.get( methodName );
+			if ( elementDescriptor == null ) {
+				elementDescriptor = new ElementDescriptorImpl(
+						method.getReturnType(),
+						method.isAnnotationPresent( Valid.class ),
+						methodName
+				);
+				propertyDescriptors.put( methodName, elementDescriptor );
+			}
+			elementDescriptor.addConstraintDescriptor( constraintDescriptor );
+		}
+		return metadata;
+	}
+
+	/**
+	 * Finds all constraint annotations defined for the given field and returns them in a list of
+	 * constraint descriptors.
+	 *
+	 * @param field The field to check for constraints annotations.
+	 *
+	 * @return A list of constraint descriptors for all constraint specified on the given field.
+	 *
+	 * @todo inject XML data here, probably externalizing the process
+	 */
+	private List<ConstraintDescriptorImpl> findFieldLevelConstraints(Field field) {
+		List<ConstraintDescriptorImpl> metadata = new ArrayList<ConstraintDescriptorImpl>();
+		for ( Annotation annotation : field.getAnnotations() ) {
+			metadata.addAll( findConstraintAnnotations( annotation ) );
+		}
+
+		String fieldName = field.getName();
+		for ( ConstraintDescriptorImpl constraintDescriptor : metadata ) {
+			ElementDescriptorImpl elementDescriptor = ( ElementDescriptorImpl ) propertyDescriptors.get( fieldName );
+			if ( elementDescriptor == null ) {
+				elementDescriptor = new ElementDescriptorImpl(
+						field.getType(),
+						field.isAnnotationPresent( Valid.class ),
+						fieldName
+				);
+				propertyDescriptors.put( field.getName(), elementDescriptor );
+			}
+			elementDescriptor.addConstraintDescriptor( constraintDescriptor );
+		}
+		return metadata;
+	}
+
+	public Class<T> getBeanClass() {
+		return beanClass;
+	}
+
+	public BeanDescriptor getBeanDescriptor() {
+		return beanDescriptor;
+	}
+
+	public List<Field> getCascadedFields() {
+		return cascadedFields;
+	}
+
+	public List<Method> getCascadedMethods() {
+		return cascadedMethods;
+	}
+
+	public List<Member> getCascadedMembers() {
+		List<Member> cascadedMembers = new ArrayList<Member>();
+		cascadedMembers.addAll( getCascadedFields() );
+		cascadedMembers.addAll( getCascadedMethods() );
+		return cascadedMembers;
+	}
+
+	public Map<Class<?>, List<Class<?>>> getGroupSequences() {
+		return groupSequences;
+	}
+
+	public List<MetaConstraint> getConstraintMetaDataList() {
+		return metaConstraintList;
+	}
+
+	public Map<String, PropertyDescriptor> getPropertyDescriptors() {
+		return propertyDescriptors;
+	}
+
+	public PropertyDescriptor getPropertyDescriptors(String property) {
+		return propertyDescriptors.get( property );
+	}
+}
\ No newline at end of file


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintContextImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintContextImpl.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintContextImpl.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -1,3 +1,20 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.hibernate.validation.engine;
 
 import java.util.List;

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -22,6 +22,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 import javax.validation.ValidationException;
+import javax.validation.ConstraintDescriptor;
 
 import org.hibernate.validation.impl.ConstraintDescriptorImpl;
 import org.hibernate.validation.util.ReflectionHelper;
@@ -138,7 +139,7 @@
 		return ReflectionHelper.isArray( t );
 	}
 
-	public ConstraintDescriptorImpl getDescriptor() {
+	public ConstraintDescriptor getDescriptor() {
 		return descriptor;
 	}
 

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProvider.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProvider.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProvider.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -1,81 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.hibernate.validation.engine;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Member;
-import java.util.List;
-import java.util.Map;
-import javax.validation.ElementDescriptor;
-import javax.validation.BeanDescriptor;
-import javax.validation.PropertyDescriptor;
-
-/**
- * Interface defining the meta data about the constraints defined in a given bean.
- *
- * @author Hardy Ferentschik
- */
-public interface MetaDataProvider<T> {
-
-	/**
-	 * @return the class of the bean.
-	 */
-	Class<T> getBeanClass();
-
-	/**
-	 * @return an instance of <code>ElementDescriptor</code> describing the bean this meta data applies for.
-	 */
-	BeanDescriptor getBeanDescriptor();
-
-	/**
-	 * @return A list of all cascaded fields (fields annotated with &#064;Valid).
-	 */
-	List<Field> getCascadedFields();
-
-	/**
-	 * @return A list of all cascaded methods (methods annotated with &#064;Valid).
-	 */
-	List<Method> getCascadedMethods();
-
-	/**
-	 * @return A list of all cascaded methods and fields (methods/fields annotated with &#064;Valid).
-	 */
-	List<Member> getCascadedMembers();
-
-	/**
-	 * @return A map mapping defined group sequences to a list of groups.
-	 */
-	Map<Class<?>, List<Class<?>>> getGroupSequences();
-
-	/**
-	 * @return A list of <code>ValidatorMetaData</code> instances encapsulating the information of all the constraints
-	 *         defined on the bean.
-	 */
-	List<MetaConstraint> getConstraintMetaDataList();
-
-	/**
-	 * @return A map keying the property name of a constraint to its <code>ElementDescriptor</code>.
-	 *
-	 * @todo Maybe needs to be removed since this data structure is ambigious. There could be conflicts between field and
-	 * methods.
-	 */
-	Map<String, PropertyDescriptor> getPropertyDescriptors();
-
-	ElementDescriptor getPropertyDescriptors(String property);
-}

Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProviderImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProviderImpl.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaDataProviderImpl.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -1,432 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.hibernate.validation.engine;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.validation.BeanDescriptor;
-import javax.validation.Constraint;
-import javax.validation.ConstraintFactory;
-import javax.validation.ConstraintValidator;
-import javax.validation.GroupSequence;
-import javax.validation.GroupSequences;
-import javax.validation.PropertyDescriptor;
-import javax.validation.Valid;
-import javax.validation.ValidationException;
-
-import org.slf4j.Logger;
-
-import org.hibernate.validation.impl.ConstraintDescriptorImpl;
-import org.hibernate.validation.impl.ConstraintFactoryImpl;
-import org.hibernate.validation.impl.ElementDescriptorImpl;
-import org.hibernate.validation.impl.BeanDescriptorImpl;
-import org.hibernate.validation.util.LoggerFactory;
-import org.hibernate.validation.util.ReflectionHelper;
-
-
-/**
- * This class encapsulates all meta data needed for validation. Implementations of <code>Validator</code> interface can
- * instantiate an instance of this class and delegate the metadata extraction to it.
- *
- * @author Hardy Ferentschik
- * FIXME create an interface for MetadataProvider
- */
-
-public class MetaDataProviderImpl<T> implements MetaDataProvider<T> {
-
-	private static final Logger log = LoggerFactory.make();
-
-	/**
-	 * The root bean class for this validator.
-	 */
-	private final Class<T> beanClass;
-
-	/**
-	 * The main element descriptor for <code>beanClass</code>.
-	 */
-	private BeanDescriptorImpl<T> beanDescriptor;
-
-	/**
-	 * List of constraints.
-	 */
-	private List<MetaConstraint> metaConstraintList = new ArrayList<MetaConstraint>();
-
-	/**
-	 * List of cascaded fields.
-	 */
-	private List<Field> cascadedFields = new ArrayList<Field>();
-
-	/**
-	 * List of cascaded methods.
-	 */
-	private List<Method> cascadedMethods = new ArrayList<Method>();
-
-	/**
-	 * Maps field and method names to their <code>ElementDescriptorImpl</code>.
-	 * FIXME This model is problematic as you can have conflicting names for fields and methods
-	 */
-	private Map<String, PropertyDescriptor> propertyDescriptors = new HashMap<String, PropertyDescriptor>();
-
-	/**
-	 * Factory to create acutal constraint instances from the annotated fields/method/class.
-	 */
-	private ConstraintFactory constraintFactory = new ConstraintFactoryImpl();
-
-	/**
-	 * Maps group sequences to the list of group/sequences.
-	 */
-	private Map<Class<?>, List<Class<?>>> groupSequences = new HashMap<Class<?>, List<Class<?>>>();
-
-	public MetaDataProviderImpl(Class<T> beanClass, ConstraintFactory constraintFactory) {
-		this.beanClass = beanClass;
-		this.constraintFactory = constraintFactory;
-		createMetaData();
-	}
-
-	/**
-	 * Create bean desciptor, find all classes/subclasses/interfaces which have to be taken in consideration
-	 * for this validator and create meta data.
-	 */
-	private void createMetaData() {
-		beanDescriptor = new BeanDescriptorImpl<T>( beanClass, this );
-		List<Class> classes = new ArrayList<Class>();
-		computeClassHierarchy( beanClass, classes );
-		for ( Class current : classes ) {
-			initClass( current );
-		}
-	}
-
-	/**
-	 * Get all superclasses and interfaces recursively.
-	 *
-	 * @param clazz The class to start the search with.
-	 * @param classes List of classes to which to add all found super classes and interfaces.
-	 */
-	private void computeClassHierarchy(Class clazz, List<Class> classes) {
-		if ( log.isTraceEnabled() ) {
-			log.trace( "Processing: {}", clazz );
-		}
-		for ( Class current = clazz; current != null; current = current.getSuperclass() ) {
-			if ( classes.contains( current ) ) {
-				return;
-			}
-			classes.add( current );
-			for ( Class currentInterface : current.getInterfaces() ) {
-				computeClassHierarchy( currentInterface, classes );
-			}
-		}
-	}
-
-	private void initClass(Class clazz) {
-		initGroupSequences( clazz );
-		initClassConstraints( clazz );
-		initMethodConstraints( clazz );
-		initFieldConstraints( clazz );
-	}
-
-	private void initGroupSequences(Class<?> clazz) {
-		GroupSequence groupSequenceAnnotation = clazz.getAnnotation( GroupSequence.class );
-		if ( groupSequenceAnnotation != null ) {
-			addGroupSequence( groupSequenceAnnotation );
-		}
-
-		GroupSequences groupSequencesAnnotation = clazz.getAnnotation( GroupSequences.class );
-		if ( groupSequencesAnnotation != null ) {
-			for ( GroupSequence group : groupSequencesAnnotation.value() ) {
-				addGroupSequence( group );
-			}
-		}
-
-		for ( Map.Entry<Class<?>, List<Class<?>>> mapEntry : groupSequences.entrySet() ) {
-			List<Class<?>> groups = mapEntry.getValue();
-			List<Class<?>> expandedGroups = new ArrayList<Class<?>>();
-			for ( Class<?> group : groups ) {
-				expandedGroups.addAll( expandGroupSequences( group ) );
-			}
-			groupSequences.put( mapEntry.getKey(), expandedGroups );
-		}
-		if ( log.isDebugEnabled() && !groupSequences.isEmpty() ) {
-			log.debug( "Expanded groups sequences: {}", groupSequences );
-		}
-	}
-
-	private List<Class<?>> expandGroupSequences(Class<?> group) {
-		List<Class<?>> groupList = new ArrayList<Class<?>>();
-		if ( groupSequences.containsKey( group ) ) {
-			for ( Class<?> localGroup : groupSequences.get( group ) ) {
-				groupList.addAll( expandGroupSequences( localGroup ) );
-			}
-		}
-		else {
-			groupList.add( group );
-		}
-		if ( log.isTraceEnabled() ) {
-			log.trace( "Expanded {} to {}", group, groupList.toString() );
-		}
-		return groupList;
-	}
-
-	private void addGroupSequence(GroupSequence groupSequence) {
-		if ( groupSequences.containsKey( groupSequence.name() ) ) {
-			throw new ValidationException( "Encountered duplicate sequence name: " + groupSequence.name() );
-		}
-		groupSequences.put( groupSequence.name(), Arrays.asList( groupSequence.sequence() ) );
-	}
-
-	private void initFieldConstraints(Class clazz) {
-		for ( Field field : clazz.getDeclaredFields() ) {
-			List<ConstraintDescriptorImpl> fieldMetadata = findFieldLevelConstraints( field );
-			for ( ConstraintDescriptorImpl constraintDescription : fieldMetadata ) {
-				ReflectionHelper.setAccessibility( field );
-				MetaConstraint metaConstraint = new MetaConstraint( field, constraintDescription );
-				metaConstraintList.add( metaConstraint );
-			}
-			if ( field.isAnnotationPresent( Valid.class ) ) {
-				cascadedFields.add( field );
-			}
-		}
-	}
-
-	private void initMethodConstraints(Class clazz) {
-		for ( Method method : clazz.getDeclaredMethods() ) {
-			List<ConstraintDescriptorImpl> methodMetadata = findMethodLevelConstraints( method );
-			for ( ConstraintDescriptorImpl constraintDescription : methodMetadata ) {
-				ReflectionHelper.setAccessibility( method );
-				MetaConstraint metaConstraint = new MetaConstraint( method, constraintDescription );
-				metaConstraintList.add( metaConstraint );
-			}
-			if ( method.isAnnotationPresent( Valid.class ) ) {
-				cascadedMethods.add( method );
-			}
-		}
-	}
-
-	private void initClassConstraints(Class clazz) {
-		List<ConstraintDescriptorImpl> classMetadata = findClassLevelConstraints( clazz );
-		for ( ConstraintDescriptorImpl constraintDescription : classMetadata ) {
-			MetaConstraint metaConstraint = new MetaConstraint( clazz, constraintDescription );
-			metaConstraintList.add( metaConstraint );
-		}
-	}
-
-	/**
-	 * Examines the given annotation to see whether it is a single or multi valued constraint annotation.
-	 *
-	 * @param annotation The annotation to examine.
-	 *
-	 * @return A list of constraint descriptors or the empty list in case <code>annotation</code> is neither a
-	 *         single nor multi value annotation.
-	 */
-	private <A extends Annotation> List<ConstraintDescriptorImpl> findConstraintAnnotations(A annotation) {
-		List<ConstraintDescriptorImpl> constraintDescriptors = new ArrayList<ConstraintDescriptorImpl>();
-
-		List<Annotation> constraints = new ArrayList<Annotation>();
-		if ( ReflectionHelper.isConstraintAnnotation( annotation ) ||
-				ReflectionHelper.isBuiltInConstraintAnnotation( annotation) ) {
-			constraints.add( annotation );
-		}
-
-		// check if we have a multi value constraint
-		constraints.addAll( ReflectionHelper.getMultiValueConstraints( annotation ) );
-
-		for ( Annotation constraint : constraints ) {
-			if ( ReflectionHelper.isBuiltInConstraintAnnotation( constraint ) ) {
-				Class constraintClass = ReflectionHelper.getBuiltInConstraint( constraint );
-				final ConstraintDescriptorImpl constraintDescriptor = buildConstraintDescriptor(
-						constraint, constraintClass
-				);
-				constraintDescriptors.add( constraintDescriptor );
-				continue;
-			}
-
-			if ( ReflectionHelper.isConstraintAnnotation( constraint ) ) {
-				ConstraintValidator constraintValidator = constraint.annotationType()
-						.getAnnotation( ConstraintValidator.class );
-				final ConstraintDescriptorImpl constraintDescriptor = buildConstraintDescriptor(
-						constraint, constraintValidator.value()
-				);
-				constraintDescriptors.add( constraintDescriptor );
-			}
-		}
-		return constraintDescriptors;
-	}
-
-	@SuppressWarnings("unchecked")
-	private <A extends Annotation> ConstraintDescriptorImpl buildConstraintDescriptor(A annotation, Class constraintClass) {
-		Class<?>[] groups = ReflectionHelper.getAnnotationParameter( annotation, "groups", Class[].class );
-		for ( Class<?> groupName : groups ) {
-			if ( groupSequences.containsKey( groupName ) ) {
-				throw new ValidationException( groupName + " is illegally used as group and sequence name." );
-			}
-		}
-
-		Constraint<A> constraint;
-		try {
-			//unchecked
-			constraint = constraintFactory.getInstance( constraintClass );
-		}
-		catch ( RuntimeException e ) {
-			throw new ValidationException( "Unable to instantiate " + constraintClass, e );
-		}
-
-		try {
-			constraint.initialize( annotation );
-		}
-		catch ( RuntimeException e ) {
-			throw new ValidationException( "Unable to intialize " + constraint.getClass().getName(), e );
-		}
-
-		return new ConstraintDescriptorImpl( annotation, groups, constraint, constraintClass );
-	}
-
-	/**
-	 * Finds all constraint annotations defined for the given class and returns them in a list of
-	 * constraint descriptors.
-	 *
-	 * @param beanClass The class to check for constraints annotations.
-	 *
-	 * @return A list of constraint descriptors for all constraint specified on the given class.
-	 *
-	 * @todo inject XML data here, probably externalizing the process
-	 */
-	private List<ConstraintDescriptorImpl> findClassLevelConstraints(Class beanClass) {
-		List<ConstraintDescriptorImpl> metadata = new ArrayList<ConstraintDescriptorImpl>();
-		for ( Annotation annotation : beanClass.getAnnotations() ) {
-			metadata.addAll( findConstraintAnnotations( annotation ) );
-		}
-		for ( ConstraintDescriptorImpl constraintDescriptor : metadata ) {
-			beanDescriptor.addConstraintDescriptor( constraintDescriptor );
-		}
-		return metadata;
-	}
-
-	/**
-	 * Finds all constraint annotations defined for the given methods and returns them in a list of
-	 * constraint descriptors.
-	 *
-	 * @param method The method to check for constraints annotations.
-	 *
-	 * @return A list of constraint descriptors for all constraint specified for the given method.
-	 *
-	 * @todo inject XML data here, probably externalizing the process
-	 */
-	private List<ConstraintDescriptorImpl> findMethodLevelConstraints(Method method) {
-		List<ConstraintDescriptorImpl> metadata = new ArrayList<ConstraintDescriptorImpl>();
-		for ( Annotation annotation : method.getAnnotations() ) {
-			metadata.addAll( findConstraintAnnotations( annotation ) );
-		}
-
-		String methodName = ReflectionHelper.getPropertyName( method );
-		for ( ConstraintDescriptorImpl constraintDescriptor : metadata ) {
-			if ( methodName == null ) {
-				throw new ValidationException(
-						"Annoated methods must follow the JavaBeans naming convention. " + method.getName() + "() does not."
-				);
-			}
-			ElementDescriptorImpl elementDescriptor = ( ElementDescriptorImpl ) propertyDescriptors.get( methodName );
-			if ( elementDescriptor == null ) {
-				elementDescriptor = new ElementDescriptorImpl(
-						method.getReturnType(),
-						method.isAnnotationPresent( Valid.class ),
-						methodName
-				);
-				propertyDescriptors.put( methodName, elementDescriptor );
-			}
-			elementDescriptor.addConstraintDescriptor( constraintDescriptor );
-		}
-		return metadata;
-	}
-
-	/**
-	 * Finds all constraint annotations defined for the given field and returns them in a list of
-	 * constraint descriptors.
-	 *
-	 * @param field The field to check for constraints annotations.
-	 *
-	 * @return A list of constraint descriptors for all constraint specified on the given field.
-	 *
-	 * @todo inject XML data here, probably externalizing the process
-	 */
-	private List<ConstraintDescriptorImpl> findFieldLevelConstraints(Field field) {
-		List<ConstraintDescriptorImpl> metadata = new ArrayList<ConstraintDescriptorImpl>();
-		for ( Annotation annotation : field.getAnnotations() ) {
-			metadata.addAll( findConstraintAnnotations( annotation ) );
-		}
-
-		String fieldName = field.getName();
-		for ( ConstraintDescriptorImpl constraintDescriptor : metadata ) {
-			ElementDescriptorImpl elementDescriptor = ( ElementDescriptorImpl ) propertyDescriptors.get( fieldName );
-			if ( elementDescriptor == null ) {
-				elementDescriptor = new ElementDescriptorImpl(
-						field.getType(),
-						field.isAnnotationPresent( Valid.class ),
-						fieldName
-				);
-				propertyDescriptors.put( field.getName(), elementDescriptor );
-			}
-			elementDescriptor.addConstraintDescriptor( constraintDescriptor );
-		}
-		return metadata;
-	}
-
-	public Class<T> getBeanClass() {
-		return beanClass;
-	}
-
-	public BeanDescriptor getBeanDescriptor() {
-		return beanDescriptor;
-	}
-
-	public List<Field> getCascadedFields() {
-		return cascadedFields;
-	}
-
-	public List<Method> getCascadedMethods() {
-		return cascadedMethods;
-	}
-
-	public List<Member> getCascadedMembers() {
-		List<Member> cascadedMembers = new ArrayList<Member>();
-		cascadedMembers.addAll( getCascadedFields() );
-		cascadedMembers.addAll( getCascadedMethods() );
-		return cascadedMembers;
-	}
-
-	public Map<Class<?>, List<Class<?>>> getGroupSequences() {
-		return groupSequences;
-	}
-
-	public List<MetaConstraint> getConstraintMetaDataList() {
-		return metaConstraintList;
-	}
-
-	public Map<String, PropertyDescriptor> getPropertyDescriptors() {
-		return propertyDescriptors;
-	}
-
-	public PropertyDescriptor getPropertyDescriptors(String property) {
-		return propertyDescriptors.get( property );
-	}
-}
\ No newline at end of file

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidationContext.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidationContext.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidationContext.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -70,7 +70,7 @@
 	/**
 	 * Stack for keep track of the currently validated object.
 	 */
-	private Stack<ValidatedBean> validatedobjectStack = new Stack<ValidatedBean>();
+	private Stack<ValidatedBean> validatedObjectStack = new Stack<ValidatedBean>();
 
 
 	public ValidationContext(T object) {
@@ -79,26 +79,26 @@
 
 	public ValidationContext(T rootBean, Object object) {
 		this.rootBean = rootBean;
-		validatedobjectStack.push( new ValidatedBean(object) );
+		validatedObjectStack.push( new ValidatedBean(object) );
 		processedObjects = new HashMap<Class<?>, IdentitySet>();
 		propertyPath = "";
 		failingConstraintViolations = new ArrayList<ConstraintViolationImpl<T>>();
 	}
 
 	public Object peekValidatedObject() {
-		return validatedobjectStack.peek().bean;
+		return validatedObjectStack.peek().bean;
 	}
 
 	public Class<?> peekValidatedObjectType() {
-		return validatedobjectStack.peek().beanType;
+		return validatedObjectStack.peek().beanType;
 	}
 
 	public void pushValidatedObject(Object validatedObject) {
-		validatedobjectStack.push( new ValidatedBean(validatedObject) );
+		validatedObjectStack.push( new ValidatedBean(validatedObject) );
 	}
 
 	public void popValidatedObject() {
-		validatedobjectStack.pop();
+		validatedObjectStack.pop();
 	}
 
 	public T getRootBean() {
@@ -115,11 +115,11 @@
 
 	public void markProcessedForCurrentGroup() {
 		if ( processedObjects.containsKey( currentGroup ) ) {
-			processedObjects.get( currentGroup ).add( validatedobjectStack.peek().bean );
+			processedObjects.get( currentGroup ).add( validatedObjectStack.peek().bean );
 		}
 		else {
 			IdentitySet set = new IdentitySet();
-			set.add( validatedobjectStack.peek().bean );
+			set.add( validatedObjectStack.peek().bean );
 			processedObjects.put( currentGroup, set );
 		}
 	}

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImplementor.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImplementor.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImplementor.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -1,3 +1,20 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.hibernate.validation.engine;
 
 import javax.validation.ValidatorFactory;
@@ -7,8 +24,8 @@
  */
 public interface ValidatorFactoryImplementor extends ValidatorFactory {
 	/**
-	 * Gives access to the required parsed meta data.
-	 * This never returns an null object
+	 * @param clazz The bean class for which to retrieve the meta data.
+	 * @return Gives access to the required parsed meta data. This never returns an <code>null</code> object.
 	 */
-	<T> MetaDataProviderImpl<T> getMetadataProvider(Class<T> clazz);
+	<T> BeanMetaDataImpl<T> getBeanMetaData(Class<T> clazz);
 }


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImplementor.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -64,14 +64,7 @@
 		Version.touch();
 	}
 
-	//TODO remove
 	/**
-	 * A map for caching validators for cascaded entities.
-	 */
-	//private final Map<Class<?>, ValidatorImpl> subValidators = new ConcurrentHashMap<Class<?>, ValidatorImpl>();
-
-	
-	/**
 	 * Message resolver used  for interpolating error messages.
 	 */
 	private final MessageResolver messageResolver;
@@ -151,10 +144,10 @@
 	private <T> void validateConstraints(ValidationContext<T> context) {
 		//casting rely on the fact that root object is at the top of the stack
 		@SuppressWarnings( "unchecked" )
-		MetaDataProviderImpl<T> metaDataProvider =
-				( MetaDataProviderImpl<T> ) factory.getMetadataProvider( context.peekValidatedObjectType() );
-		for ( MetaConstraint metaConstraint : metaDataProvider.getConstraintMetaDataList() ) {
-			ConstraintDescriptorImpl constraintDescriptor = metaConstraint.getDescriptor();
+		BeanMetaData<T> beanMetaData =
+				( BeanMetaData<T> ) factory.getBeanMetaData( context.peekValidatedObjectType() );
+		for ( MetaConstraint metaConstraint : beanMetaData.getConstraintMetaDataList() ) {
+			ConstraintDescriptorImpl constraintDescriptor = (ConstraintDescriptorImpl) metaConstraint.getDescriptor();
 			context.pushProperty( metaConstraint.getPropertyName() );
 
 			if ( !context.needsValidation( constraintDescriptor.getGroups() ) ) {
@@ -178,7 +171,7 @@
 							message,
 							interpolatedMessage,
 							context.getRootBean(),
-							metaDataProvider.getBeanClass(),
+							beanMetaData.getBeanClass(),
 							leafBeanInstance,
 							value,
 							context.peekPropertyPath(), //FIXME use error.getProperty()
@@ -223,7 +216,7 @@
 	}
 
 	private <T> void validateCascadedConstraints(ValidationContext<T> context) {
-		List<Member> cascadedMembers = factory.getMetadataProvider( context.peekValidatedObjectType() ).getCascadedMembers();
+		List<Member> cascadedMembers = factory.getBeanMetaData( context.peekValidatedObjectType() ).getCascadedMembers();
 		for ( Member member : cascadedMembers ) {
 			Type type = ReflectionHelper.typeOf( member );
 			context.pushProperty( ReflectionHelper.getPropertyName( member ) );
@@ -345,7 +338,7 @@
 	}
 
 	public BeanDescriptor getConstraintsForClass(Class<?> clazz) {
-		return factory.getMetadataProvider( clazz ).getBeanDescriptor();
+		return factory.getBeanMetaData( clazz ).getBeanDescriptor();
 	}
 
 
@@ -425,7 +418,7 @@
 		propertyIter.split();
 
 		if ( !propertyIter.hasNext() ) {
-			List<MetaConstraint> metaConstraintList = factory.getMetadataProvider(clazz).getConstraintMetaDataList();
+			List<MetaConstraint> metaConstraintList = factory.getBeanMetaData(clazz).getConstraintMetaDataList();
 			for ( MetaConstraint metaConstraint : metaConstraintList ) {
 				ConstraintDescriptor constraintDescriptor = metaConstraint.getDescriptor();
 				if ( metaConstraint.getPropertyName().equals( propertyIter.getHead() ) ) {
@@ -434,7 +427,7 @@
 			}
 		}
 		else {
-			List<Member> cascadedMembers = factory.getMetadataProvider(clazz).getCascadedMembers();
+			List<Member> cascadedMembers = factory.getBeanMetaData(clazz).getCascadedMembers();
 			for ( Member m : cascadedMembers ) {
 				if ( ReflectionHelper.getPropertyName( m ).equals( propertyIter.getHead() ) ) {
 					Type type = ReflectionHelper.typeOf( m );
@@ -463,7 +456,7 @@
 
 		// bottom out - there is only one token left
 		if ( !propertyIter.hasNext() ) {
-			List<MetaConstraint> metaConstraintList = factory.getMetadataProvider(clazz).getConstraintMetaDataList();
+			List<MetaConstraint> metaConstraintList = factory.getBeanMetaData(clazz).getConstraintMetaDataList();
 			for ( MetaConstraint metaConstraint : metaConstraintList ) {
 				ConstraintDescriptor constraintDescriptor = metaConstraint.getDescriptor();
 				if ( metaConstraint.getPropertyName().equals( propertyIter.getHead() ) ) {
@@ -474,7 +467,7 @@
 			}
 		}
 		else {
-			List<Member> cascadedMembers = factory.getMetadataProvider(clazz).getCascadedMembers();
+			List<Member> cascadedMembers = factory.getBeanMetaData(clazz).getCascadedMembers();
 			for ( Member m : cascadedMembers ) {
 				if ( ReflectionHelper.getPropertyName( m ).equals( propertyIter.getHead() ) ) {
 					ReflectionHelper.setAccessibility( m );
@@ -509,8 +502,9 @@
 
 	/**
 	 * Checks whether the provided group name is a group sequence and if so expands the group name and add the expanded
-	 * groups names to <code>expandedGroupName </code>
+	 * groups names to <code>expandedGroupName</code>.
 	 *
+	 * @param beanType The class for which to expand the group names.
 	 * @param group The group to expand
 	 * @param expandedGroups The exanded group names or just a list with the single provided group name id the name
 	 * was not expandable
@@ -523,7 +517,7 @@
 		}
 
 		boolean isGroupSequence;
-		MetaDataProviderImpl<T> metaDataProvider = factory.getMetadataProvider( beanType );
+		BeanMetaDataImpl<T> metaDataProvider = factory.getBeanMetaData( beanType );
 		if ( metaDataProvider.getGroupSequences().containsKey( group ) ) {
 			expandedGroups.addAll( metaDataProvider.getGroupSequences().get( group ) );
 			isGroupSequence = true;

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/BeanDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/BeanDescriptorImpl.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/BeanDescriptorImpl.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -5,31 +5,31 @@
 import javax.validation.BeanDescriptor;
 import javax.validation.PropertyDescriptor;
 
-import org.hibernate.validation.engine.MetaDataProvider;
+import org.hibernate.validation.engine.BeanMetaData;
 
 /**
  * @author Emmanuel Bernard
  */
 public class BeanDescriptorImpl<T> extends ElementDescriptorImpl implements BeanDescriptor {
-	private final MetaDataProvider<T> metadataProvider;
+	private final BeanMetaData<T> metadataBean;
 
-	public BeanDescriptorImpl(Class<T> returnType, MetaDataProvider<T> metadataProvider) {
+	public BeanDescriptorImpl(Class<T> returnType, BeanMetaData<T> metadataBean) {
 		super(returnType, false, "");
-		this.metadataProvider = metadataProvider;
+		this.metadataBean = metadataBean;
 	}
 
 	/**
 	 * @todo add child validation
 	 */
 	public boolean hasConstraints() {
-		return metadataProvider.getConstraintMetaDataList().size() > 0;
+		return metadataBean.getConstraintMetaDataList().size() > 0;
 	}
 
 	public PropertyDescriptor getConstraintsForProperty(String propertyName) {
-		return metadataProvider.getPropertyDescriptors().get( propertyName );
+		return metadataBean.getPropertyDescriptors().get( propertyName );
 	}
 
 	public Set<String> getPropertiesWithConstraints() {
-		return Collections.unmodifiableSet( metadataProvider.getPropertyDescriptors().keySet() );
+		return Collections.unmodifiableSet( metadataBean.getPropertyDescriptors().keySet() );
 	}
 }

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ValidatorFactoryImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ValidatorFactoryImpl.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/impl/ValidatorFactoryImpl.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -26,7 +26,7 @@
 import javax.validation.ValidatorBuilder;
 import javax.validation.spi.ValidatorFactoryConfiguration;
 
-import org.hibernate.validation.engine.MetaDataProviderImpl;
+import org.hibernate.validation.engine.BeanMetaDataImpl;
 import org.hibernate.validation.engine.ValidatorFactoryImplementor;
 
 /**
@@ -40,8 +40,8 @@
 	private final ConstraintFactory constraintFactory;
 
 	//TODO is there a way to replace ? by so kind of <T> to express the correlation?
-	private Map<Class<?>, MetaDataProviderImpl<?>> metadataProviders
-			= new ConcurrentHashMap<Class<?>, MetaDataProviderImpl<?>>(10);
+	private Map<Class<?>, BeanMetaDataImpl<?>> metadataProviders
+			= new ConcurrentHashMap<Class<?>, BeanMetaDataImpl<?>>(10);
 
 
 	public ValidatorFactoryImpl(ValidatorFactoryConfiguration configuration) {
@@ -66,13 +66,13 @@
 		return new ValidatorBuilderImpl(this, messageResolver, traversableResolver);
 	}
 
-	public <T> MetaDataProviderImpl<T> getMetadataProvider(Class<T> beanClass) {
+	public <T> BeanMetaDataImpl<T> getBeanMetaData(Class<T> beanClass) {
 		//FIXME make sure a optimized mock is provided when no constraints are present.
 		if (beanClass == null) throw new IllegalArgumentException( "Class cannot be null" );
 		@SuppressWarnings( "unchecked")
-		MetaDataProviderImpl<T> metadata = ( MetaDataProviderImpl<T> ) metadataProviders.get(beanClass);
+		BeanMetaDataImpl<T> metadata = ( BeanMetaDataImpl<T> ) metadataProviders.get(beanClass);
 		if (metadata == null) {
-			metadata = new MetaDataProviderImpl<T>(beanClass, constraintFactory);
+			metadata = new BeanMetaDataImpl<T>(beanClass, constraintFactory);
 			metadataProviders.put( beanClass, metadata );
 		}
 		return metadata;

Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ReflectionHelper.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -130,6 +130,15 @@
 			return false;
 		}
 
+		Method[] methods = annotation.getClass().getMethods();
+		for ( Method m : methods ) {
+			if ( m.getName().startsWith( "valid" ) ) {
+				String msg = "Parameters starting with 'valid' are not allowed in a constraint.";
+				log.warn( msg );
+				return false;
+			}
+		}
+
 		return true;
 	}
 
@@ -140,7 +149,6 @@
 	 *
 	 * @return A list of constraint annotations or the empty list if <code>annotation</code> is not a multi constraint
 	 *         annotation.
-	 *
 	 */
 	public static <A extends Annotation> List<Annotation> getMultiValueConstraints(A annotation) {
 		List<Annotation> annotationList = new ArrayList<Annotation>();
@@ -149,8 +157,8 @@
 			Class returnType = m.getReturnType();
 			if ( returnType.isArray() && returnType.getComponentType().isAnnotation() ) {
 				Annotation[] annotations = ( Annotation[] ) m.invoke( annotation );
-				for (Annotation a : annotations) {
-					if( isConstraintAnnotation( a ) || isBuiltInConstraintAnnotation( a )) {
+				for ( Annotation a : annotations ) {
+					if ( isConstraintAnnotation( a ) || isBuiltInConstraintAnnotation( a ) ) {
 						annotationList.add( a );
 					}
 				}

Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationDescriptor.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationDescriptor.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationDescriptor.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -0,0 +1,64 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.hibernate.validation.util.annotationfactory;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Encapsulates the data you need to create an annotation. In
+ * particular, it stores the type of an <code>Annotation</code> instance
+ * and the values of its elements.
+ * The "elements" we're talking about are the annotation attributes,
+ * not its targets (the term "element" is used ambiguously
+ * in Java's annotations documentation).
+ *
+ * @author Paolo Perrotta
+ * @author Davide Marchignoli
+ */
+public class AnnotationDescriptor {
+
+	private final Class<? extends Annotation> type;
+
+	private final Map<String, Object> elements = new HashMap<String, Object>();
+
+	public AnnotationDescriptor(Class<? extends Annotation> annotationType) {
+		type = annotationType;
+	}
+
+	public void setValue(String elementName, Object value) {
+		elements.put( elementName, value );
+	}
+
+	public Object valueOf(String elementName) {
+		return elements.get( elementName );
+	}
+
+	public boolean containsElement(String elementName) {
+		return elements.containsKey( elementName );
+	}
+
+	public int numberOfElements() {
+		return elements.size();
+	}
+
+	public Class<? extends Annotation> type() {
+		return type;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationDescriptor.java
___________________________________________________________________
Name: svn:keywords
   + Id

Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationFactory.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationFactory.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationFactory.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -0,0 +1,59 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.hibernate.validation.util.annotationfactory;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Constructor;
+
+
+/**
+ * Creates live annotations (actually <code>AnnotationProxies</code>) from <code>AnnotationDescriptors</code>.
+ *
+ * @author Paolo Perrotta
+ * @author Davide Marchignoli
+ * @see AnnotationProxy
+ */
+public class AnnotationFactory {
+
+	@SuppressWarnings("unchecked")
+	public static <T extends Annotation> T create(AnnotationDescriptor descriptor) {
+		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        //TODO round 34ms to generate the proxy, hug! is Javassist Faster?
+        Class<T> proxyClass = (Class<T>) Proxy.getProxyClass( classLoader, descriptor.type() );
+		InvocationHandler handler = new AnnotationProxy( descriptor );
+		try {
+			return getProxyInstance( proxyClass, handler );
+		}
+		catch (RuntimeException e) {
+			throw e;
+		}
+		catch (Exception e) {
+			throw new RuntimeException( e );
+		}
+	}
+
+	private static <T extends Annotation> T getProxyInstance(Class<T> proxyClass, InvocationHandler handler) throws
+			SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException,
+			IllegalAccessException, InvocationTargetException {
+		Constructor<T> constructor = proxyClass.getConstructor( new Class[]{InvocationHandler.class} );
+		return constructor.newInstance( new Object[]{handler} );
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationFactory.java
___________________________________________________________________
Name: svn:keywords
   + Id

Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationProxy.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationProxy.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationProxy.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -0,0 +1,128 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.hibernate.validation.util.annotationfactory;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+/**
+ * A concrete implementation of <code>Annotation</code> that pretends it is a
+ * "real" source code annotation. It's also an <code>InvocationHandler</code>.
+ * <p/>
+ * When you create an <code>AnnotationProxy</code>, you must initialize it
+ * with an <code>AnnotationDescriptor</code>.
+ * The adapter checks that the provided elements are the same elements defined
+ * in the annotation interface. However, it does <i>not</i> check that their
+ * values are the right type. If you omit an element, the adapter will use the
+ * default value for that element from the annotation interface, if it exists.
+ * If no default exists, it will throw an exception.
+ * <p/>
+ * Warning: this class does not implement <code>hashCode()</code> and
+ * <code>equals()</code> - it just uses the ones it inherits from <code>Object</code>.
+ * This means that an <code>AnnotationProxy</code> does <i>not</i> follow the
+ * recommendations of the <code>Annotation</code> javadoc about these two
+ * methods. That's why you should never mix <code>AnnotationProxies</code>
+ * with "real" annotations. For example, don't put them into the same
+ * <code>Collection</code>.
+ *
+ * @author Paolo Perrotta
+ * @author Davide Marchignoli
+ * @see java.lang.annotation.Annotation
+ */
+public class AnnotationProxy implements Annotation, InvocationHandler {
+
+	private final Class<? extends Annotation> annotationType;
+	//FIXME it's probably better to use String as a key rather than Method
+	//      to speed up and avoid any fancy permsize/GC issue
+	//      I'd better check the litterature on the subject
+	private final Map<Method, Object> values;
+
+	public AnnotationProxy(AnnotationDescriptor descriptor) {
+		this.annotationType = descriptor.type();
+		values = getAnnotationValues( descriptor );
+	}
+
+	private Map<Method, Object> getAnnotationValues(AnnotationDescriptor descriptor) {
+		Map<Method, Object> result = new HashMap<Method, Object>();
+		int processedValuesFromDescriptor = 0;
+		for ( Method m : annotationType.getDeclaredMethods() ) {
+			if ( descriptor.containsElement( m.getName() ) ) {
+				result.put( m, descriptor.valueOf( m.getName() ) );
+				processedValuesFromDescriptor++;
+			}
+			else if ( m.getDefaultValue() != null ) {
+				result.put( m, m.getDefaultValue() );
+			}
+			else {
+				throw new IllegalArgumentException( "No value provided for " + m.getName() );
+			}
+		}
+		if ( processedValuesFromDescriptor != descriptor.numberOfElements() ) {
+			throw new RuntimeException( "Trying to instanciate " + annotationType + " with unknown elements" );
+		}
+		return result;
+	}
+
+	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+		if ( values.containsKey( method ) ) {
+			return values.get( method );
+		}
+		return method.invoke( this, args );
+	}
+
+	public Class<? extends Annotation> annotationType() {
+		return annotationType;
+	}
+
+	public String toString() {
+		StringBuilder result = new StringBuilder();
+		result.append( '@' ).append( annotationType().getName() ).append( '(' );
+		for ( Method m : getRegisteredMethodsInAlphabeticalOrder() ) {
+			result.append( m.getName() ).append( '=' ).append( values.get( m ) ).append( ", " );
+		}
+		// remove last separator:
+		if ( values.size() > 0 ) {
+			result.delete( result.length() - 2, result.length() );
+			result.append( ")" );
+		}
+		else {
+			result.delete( result.length() - 1, result.length() );
+		}
+
+		return result.toString();
+	}
+
+	private SortedSet<Method> getRegisteredMethodsInAlphabeticalOrder() {
+		SortedSet<Method> result = new TreeSet<Method>(
+				new Comparator<Method>() {
+					public int compare(Method o1, Method o2) {
+						return o1.getName().compareTo( o2.getName() );
+					}
+				}
+		);
+		//List<Method> result = new LinkedList<Method>();
+		result.addAll( values.keySet() );
+		return result;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationProxy.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthConstraintTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthConstraintTest.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthConstraintTest.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -18,6 +18,7 @@
 package org.hibernate.validation.constraints;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -78,7 +79,7 @@
 	}
 
 	@Test
-	@SpecAssertion( section = "2.1", note="Incompatible type cause runtime error")
+	@SpecAssertion(section = "2.1", note = "Incompatible type cause runtime error")
 	public void testIncompatibleType() {
 		try {
 			constraint.isValid( new Object(), null );

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/FrenchZipcode.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/FrenchZipcode.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/FrenchZipcode.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -0,0 +1,44 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.hibernate.validation.eg.constraint;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.ConstraintValidator;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+ at NotNull
+ at Size(min = 5, max = 5)
+ at ConstraintValidator(FrenchZipcodeConstraint.class)
+ at Documented
+ at Target({ METHOD, FIELD, TYPE })
+ at Retention(RUNTIME)
+public @interface FrenchZipcode {
+	String message() default "Wrong zipcode";
+
+	Class<?>[] groups() default { };
+}


Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/FrenchZipcode.java
___________________________________________________________________
Name: svn:keywords
   + Id

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/FrenchZipcodeConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/FrenchZipcodeConstraint.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/FrenchZipcodeConstraint.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -0,0 +1,34 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.hibernate.validation.eg.constraint;
+
+import javax.validation.Constraint;
+import javax.validation.ConstraintContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class FrenchZipcodeConstraint implements Constraint<FrenchZipcode> {
+
+	public void initialize(FrenchZipcode parameters) {
+	}
+
+	public boolean isValid(Object object, ConstraintContext constraintContext) {
+		return false;
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/FrenchZipcodeConstraint.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/NoGroups.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/NoGroups.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/NoGroups.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -33,5 +33,5 @@
 @Target({ METHOD, FIELD })
 @Retention(RUNTIME)
 public @interface NoGroups {
-	public abstract String message() default "default message";
+	String message() default "default message";
 }
\ No newline at end of file

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/NoMessage.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/NoMessage.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/NoMessage.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -33,5 +33,5 @@
 @Target({ METHOD, FIELD })
 @Retention(RUNTIME)
 public @interface NoMessage {
-	public abstract String[] groups() default { };
+	Class<?>[] groups() default { };
 }
\ No newline at end of file

Copied: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/ValidProperty.java (from rev 15744, validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/NoGroups.java)
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/ValidProperty.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/ValidProperty.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -0,0 +1,41 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.hibernate.validation.eg.constraint;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.ConstraintValidator;
+
+/**
+ * @author Hardy Ferentschik
+ */
+ at Documented
+ at ConstraintValidator(NoGroupsConstraint.class)
+ at Target({ METHOD, FIELD })
+ at Retention(RUNTIME)
+public @interface ValidProperty {
+	String message() default "default message";
+
+	Class<?>[] groups() default { };
+
+	int validLength() default 0;
+}
\ No newline at end of file


Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/eg/constraint/ValidProperty.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:mergeinfo
   + 

Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ReflectionHelperTest.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -41,6 +41,7 @@
 import org.hibernate.validation.eg.Order;
 import org.hibernate.validation.eg.constraint.NoGroups;
 import org.hibernate.validation.eg.constraint.NoMessage;
+import org.hibernate.validation.eg.constraint.ValidProperty;
 import org.hibernate.tck.annotations.SpecAssertion;
 
 /**
@@ -151,7 +152,7 @@
 	@SpecAssertion(section = "2.1.1.1", note = "constraint annotation must specify a groups element")
 	public void testConstraintWithNoGroups() {
 		Annotation annotation = new NoMessage() {
-			public String[] groups() {
+			public Class<?>[] groups() {
 				return null;
 			}
 
@@ -165,6 +166,31 @@
 	}
 
 	@Test
+	@SpecAssertion(section = "2.1.1", note = "properties cannot begin with 'valid'")
+	public void testConstraintWithValidInPropertyName() {
+		Annotation annotation = new ValidProperty() {
+			public String message() {
+				return null;
+			}
+
+			public Class<?>[] groups() {
+				return null;
+			}
+
+			public int validLength() {
+				return 0;
+			}
+
+			public Class<? extends Annotation> annotationType() {
+				return this.getClass();
+			}
+		};
+		assertFalse(
+				"The constraint annotation should not be valid", ReflectionHelper.isConstraintAnnotation( annotation )
+		);
+	}
+
+	@Test
 	public void testGetMultiValueConstraints() throws Exception {
 		Engine engine = new Engine();
 		Field[] fields = engine.getClass().getDeclaredFields();
@@ -189,6 +215,6 @@
 		annotation = fields[0].getAnnotation( NotNull.class );
 		assertNotNull( annotation );
 		multiValueConstraintAnnotations = ReflectionHelper.getMultiValueConstraints( annotation );
-		assertTrue( "There should be two constraint annotations", multiValueConstraintAnnotations.size() == 0 );
+		assertTrue( "There should be no constraint annotations", multiValueConstraintAnnotations.size() == 0 );
 	}
 }

Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java	                        (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -0,0 +1,58 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.hibernate.validation.util.annotationfactory;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+import org.hibernate.validation.constraints.Length;
+import org.hibernate.validation.constraints.Pattern;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class AnnotationFactoryTest {
+
+	@Test
+	public void createAnnotationProxy() {
+		AnnotationDescriptor descriptor = new AnnotationDescriptor( Length.class );
+		descriptor.setValue( "min", 5 );
+		descriptor.setValue( "max", 10 );
+
+		Length l = AnnotationFactory.create( descriptor );
+
+		assertEquals( "Wrong parameter value", 5, l.min() );
+		assertEquals( "Wrong parameter value", 10, l.max() );
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void createAnnotationProxyMissingRequiredParamter() {
+		AnnotationDescriptor descriptor = new AnnotationDescriptor( Pattern.class );
+		Pattern pattern = AnnotationFactory.create( descriptor );
+	}
+
+	@Test
+	public void createAnnotationProxyWithRequiredParamter() {
+		AnnotationDescriptor descriptor = new AnnotationDescriptor( Pattern.class );
+		descriptor.setValue( "regex", ".*" );
+
+		Pattern pattern = AnnotationFactory.create( descriptor );
+
+		assertEquals( "Wrong parameter value", ".*", pattern.regex() );
+	}
+}


Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java
___________________________________________________________________
Name: svn:keywords
   + Id

Added: validator/trunk/license.txt
===================================================================
--- validator/trunk/license.txt	                        (rev 0)
+++ validator/trunk/license.txt	2009-01-07 15:32:23 UTC (rev 15751)
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

Modified: validator/trunk/pom.xml
===================================================================
--- validator/trunk/pom.xml	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/pom.xml	2009-01-07 15:32:23 UTC (rev 15751)
@@ -161,7 +161,7 @@
     <licenses>
         <license>
             <name>Apache License, Version 2.0</name>
-            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+            <url>license.txt</url>
         </license>
     </licenses>
 

Modified: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintContext.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintContext.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintContext.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -17,7 +17,7 @@
 	void disableDefaultError();
 
 	/**
-	 * return the current unexpanded default message
+	 * @return the current unexpanded default message
 	 * TODO: is it needed
 	 */
 	String getDefaultErrorMessage();

Modified: validator/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java	2009-01-06 21:55:41 UTC (rev 15750)
+++ validator/trunk/validation-api/src/main/java/javax/validation/OverridesParameter.java	2009-01-07 15:32:23 UTC (rev 15751)
@@ -33,18 +33,18 @@
 @Retention(RUNTIME)
 public @interface OverridesParameter {
 	/**
-	 * constraint type the parameter is overriding
+	 * @return Constraint type the parameter is overriding
 	 */
 	Class<? extends Annotation> constraint();
 
 	/**
-	 * name of constraint parameter overridden
-	 * Defaults to the name of the parameter hosting the annotation  
+	 * @return name of constraint parameter overridden.
+	 * Defaults to the name of the parameter hosting the annotation.
 	 */
 	String parameter();
 
 	/**
-	 * index of the targetted constraint declaration when using
+	 * @return The index of the targeted constraint declaration when using
 	 * multiple constraints of the same type.
 	 * The index represents the index of the constraint in the value() array.
 	 *




More information about the hibernate-commits mailing list