wms-jax.validation

ameterExists(annotation);
    
    assertNoParameterStartsWithValid(annotation);
    
    return true;
  }
  
  private void assertNoParameterStartsWithValid(Annotation annotation)
  {
    GetMethods getMethods = GetMethods.action(annotation.annotationType());
    Method[] methods;
    Method[] methods;
    if (System.getSecurityManager() != null) {
      methods = (Method[])AccessController.doPrivileged(getMethods);
    } else {
      methods = getMethods.run();
    }
    for (Method m : methods) {
      if (m.getName().startsWith("valid"))
      {
        String msg = "Parameters starting with 'valid' are not allowed in a constraint.";
        throw new ConstraintDefinitionException(msg);
      }
    }
  }
  
  private void assertPayloadParameterExists(Annotation annotation)
  {
    try
    {
      GetMethod getMethod = GetMethod.action(annotation.annotationType(), "payload");
      Method method;
      Method method;
      if (System.getSecurityManager() != null) {
        method = (Method)AccessController.doPrivileged(getMethod);
      } else {
        method = getMethod.run();
      }
      if (method == null)
      {
        String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " + "not contain a payload parameter.";
        
        throw new ConstraintDefinitionException(msg);
      }
      Class<?>[] defaultPayload = (Class[])method.getDefaultValue();
      if (defaultPayload.length != 0)
      {
        String msg = annotation.annotationType().getName() + " contains Constraint annotation, but the payload " + "paramter default value is not the empty array.";
        
        throw new ConstraintDefinitionException(msg);
      }
    }
    catch (ClassCastException e)
    {
      String msg = annotation.annotationType().getName() + " contains Constraint annotation, but the " + "payload parameter is of wrong type.";
      
      throw new ConstraintDefinitionException(msg);
    }
  }
  
  private void assertGroupsParameterExists(Annotation annotation)
  {
    try
    {
      GetMethod getMethod = GetMethod.action(annotation.annotationType(), "groups");
      Method method;
      Method method;
      if (System.getSecurityManager() != null) {
        method = (Method)AccessController.doPrivileged(getMethod);
      } else {
        method = getMethod.run();
      }
      if (method == null)
      {
        String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " + "not contain a groups parameter.";
        
        throw new ConstraintDefinitionException(msg);
      }
      Class<?>[] defaultGroups = (Class[])method.getDefaultValue();
      if (defaultGroups.length != 0)
      {
        String msg = annotation.annotationType().getName() + " contains Constraint annotation, but the groups " + "paramter default value is not the empty array.";
        
        throw new ConstraintDefinitionException(msg);
      }
    }
    catch (ClassCastException e)
    {
      String msg = annotation.annotationType().getName() + " contains Constraint annotation, but the " + "groups parameter is of wrong type.";
      
      throw new ConstraintDefinitionException(msg);
    }
  }
  
  private void assertMessageParameterExists(Annotation annotation)
  {
    try
    {
      GetAnnotationParameter<?> action = GetAnnotationParameter.action(annotation, "message", String.class);
      if (System.getSecurityManager() != null) {
        AccessController.doPrivileged(action);
      } else {
        action.run();
      }
    }
    catch (Exception e)
    {
      String msg = annotation.annotationType().getName() + " contains Constraint annotation, but does " + "not contain a message parameter.";
      
      throw new ConstraintDefinitionException(msg);
    }
  }
  
  public <T extends Annotation> List<Class<? extends ConstraintValidator<T, ?>>> getConstraintValidatorDefinition(Class<T> annotationClass)
  {
    if (annotationClass == null) {
      throw new IllegalArgumentException("Class cannot be null");
    }
    List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> list = (List)constraintValidatorDefinitons.get(annotationClass);
    
    List<Class<? extends ConstraintValidator<T, ?>>> constraintsValidators = new ArrayList(list.size());
    for (Class<? extends ConstraintValidator<?, ?>> validatorClass : list)
    {
      Class<ConstraintValidator<T, ?>> safeValdiatorClass = validatorClass;
      constraintsValidators.add(safeValdiatorClass);
    }
    return constraintsValidators;
  }
  
  public <A extends Annotation> void addConstraintValidatorDefinition(Class<A> annotationClass, List<Class<? extends ConstraintValidator<? extends Annotation, ?>>> definitionClasses)
  {
    constraintValidatorDefinitons.putIfAbsent(annotationClass, definitionClasses);
  }
  
  public boolean containsConstraintValidatorDefinition(Class<? extends Annotation> annotationClass)
  {
    return constraintValidatorDefinitons.containsKey(annotationClass);
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.metadata.ConstraintHelper
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.metadata;

public enum ConstraintOrigin
{
  DEFINED_LOCALLY,  DEFINED_IN_HIERARCHY;
  
  private ConstraintOrigin() {}
}

/* Location:
 * Qualified Name:     org.hibernate.validator.metadata.ConstraintOrigin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.metadata;

import java.lang.annotation.ElementType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.validation.groups.Default;
import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.metadata.ElementDescriptor.ConstraintFinder;
import javax.validation.metadata.Scope;
import org.hibernate.validator.engine.groups.Group;
import org.hibernate.validator.engine.groups.GroupChain;
import org.hibernate.validator.engine.groups.GroupChainGenerator;

class ElementDescriptorImpl$ConstraintFinderImpl
  implements ElementDescriptor.ConstraintFinder
{
  private List<Class<?>> groups;
  private Set<ConstraintOrigin> definedInSet;
  private Set<ElementType> elementTypes;
  
  ElementDescriptorImpl$ConstraintFinderImpl(ElementDescriptorImpl paramElementDescriptorImpl)
  {
    elementTypes = new HashSet();
    elementTypes.add(ElementType.TYPE);
    elementTypes.add(ElementType.METHOD);
    elementTypes.add(ElementType.FIELD);
    definedInSet = new HashSet();
    definedInSet.add(ConstraintOrigin.DEFINED_LOCALLY);
    definedInSet.add(ConstraintOrigin.DEFINED_IN_HIERARCHY);
    groups = Collections.emptyList();
  }
  
  public ElementDescriptor.ConstraintFinder unorderedAndMatchingGroups(Class<?>... classes)
  {
    groups = new ArrayList();
    for (Class<?> clazz : classes) {
      if ((Default.class.equals(clazz)) && (this$0.metaDataBean.defaultGroupSequenceIsRedefined())) {
        groups.addAll(this$0.metaDataBean.getDefaultGroupSequence());
      } else {
        groups.add(clazz);
      }
    }
    return this;
  }
  
  public ElementDescriptor.ConstraintFinder lookingAt(Scope visibility)
  {
    if (visibility.equals(Scope.LOCAL_ELEMENT)) {
      definedInSet.remove(ConstraintOrigin.DEFINED_IN_HIERARCHY);
    }
    return this;
  }
  
  public ElementDescriptor.ConstraintFinder declaredOn(ElementType... elementTypes)
  {
    this.elementTypes.clear();
    this.elementTypes.addAll(Arrays.asList(elementTypes));
    return this;
  }
  
  public Set<ConstraintDescriptor<?>> getConstraintDescriptors()
  {
    Set<ConstraintDescriptor<?>> matchingDescriptors = new HashSet();
    findMatchingDescriptors(matchingDescriptors);
    return Collections.unmodifiableSet(matchingDescriptors);
  }
  
  private void findMatchingDescriptors(Set<ConstraintDescriptor<?>> matchingDescriptors)
  {
    if (!groups.isEmpty())
    {
      GroupChain groupChain = new GroupChainGenerator().getGroupChainFor(groups);
      Iterator<Group> groupIterator = groupChain.getGroupIterator();
      while (groupIterator.hasNext())
      {
        Group g = (Group)groupIterator.next();
        addMatchingDescriptorsForGroup(g.getGroup(), matchingDescriptors);
      }
    }
    else
    {
      for (ConstraintDescriptorImpl<?> descriptor : ElementDescriptorImpl.access$000(this$0)) {
        if ((definedInSet.contains(descriptor.getDefinedOn())) && (elementTypes.contains(descriptor.getElementType()))) {
          matchingDescriptors.add(descriptor);
        }
      }
    }
  }
  
  public boolean hasConstraints()
  {
    return getConstraintDescriptors().size() != 0;
  }
  
  private void addMatchingDescriptorsForGroup(Class<?> group, Set<ConstraintDescriptor<?>> matchingDescriptors)
  {
    for (ConstraintDescriptorImpl<?> descriptor : ElementDescriptorImpl.access$000(this$0)) {
      if ((definedInSet.contains(descriptor.getDefinedOn())) && (elementTypes.contains(descriptor.getElementType())) && (descriptor.getGroups().contains(group))) {
        matchingDescriptors.add(descriptor);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.metadata.ElementDescriptorImpl.ConstraintFinderImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.metadata;

import java.lang.annotation.ElementType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.validation.groups.Default;
import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.metadata.ElementDescriptor;
import javax.validation.metadata.ElementDescriptor.ConstraintFinder;
import javax.validation.metadata.Scope;
import org.hibernate.validator.engine.groups.Group;
import org.hibernate.validator.engine.groups.GroupChain;
import org.hibernate.validator.engine.groups.GroupChainGenerator;

public class ElementDescriptorImpl
  implements ElementDescriptor
{
  protected final BeanMetaData<?> metaDataBean;
  private final Class<?> type;
  private final Set<ConstraintDescriptorImpl<?>> constraintDescriptors = new HashSet();
  
  public ElementDescriptorImpl(Class<?> type, BeanMetaData<?> metaDataBean)
  {
    this.metaDataBean = metaDataBean;
    this.type = type;
  }
  
  public void addConstraintDescriptor(ConstraintDescriptorImpl constraintDescriptor)
  {
    constraintDescriptors.add(constraintDescriptor);
  }
  
  public boolean hasConstraints()
  {
    return constraintDescriptors.size() != 0;
  }
  
  public Class<?> getElementClass()
  {
    return type;
  }
  
  public Set<ConstraintDescriptor<?>> getConstraintDescriptors()
  {
    return findConstraints().getConstraintDescriptors();
  }
  
  public ElementDescriptor.ConstraintFinder findConstraints()
  {
    return new ConstraintFinderImpl();
  }
  
  private class ConstraintFinderImpl
    implements ElementDescriptor.ConstraintFinder
  {
    private List<Class<?>> groups;
    private Set<ConstraintOrigin> definedInSet;
    private Set<ElementType> elementTypes;
    
    ConstraintFinderImpl()
    {
      elementTypes = new HashSet();
      elementTypes.add(ElementType.TYPE);
      elementTypes.add(ElementType.METHOD);
      elementTypes.add(ElementType.FIELD);
      definedInSet = new HashSet();
      definedInSet.add(ConstraintOrigin.DEFINED_LOCALLY);
      definedInSet.add(ConstraintOrigin.DEFINED_IN_HIERARCHY);
      groups = Collections.emptyList();
    }
    
    public ElementDescriptor.ConstraintFinder unorderedAndMatchingGroups(Class<?>... classes)
    {
      groups = new ArrayList();
      for (Class<?> clazz : classes) {
        if ((Default.class.equals(clazz)) && (metaDataBean.defaultGroupSequenceIsRedefined())) {
          groups.addAll(metaDataBean.getDefaultGroupSequence());
        } else {
          groups.add(clazz);
        }
      }
      return this;
    }
    
    public ElementDescriptor.ConstraintFinder lookingAt(Scope visibility)
    {
      if (visibility.equals(Scope.LOCAL_ELEMENT)) {
        definedInSet.remove(ConstraintOrigin.DEFINED_IN_HIERARCHY);
      }
      return this;
    }
    
    public ElementDescriptor.ConstraintFinder declaredOn(ElementType... elementTypes)
    {
      this.elementTypes.clear();
      this.elementTypes.addAll(Arrays.asList(elementTypes));
      return this;
    }
    
    public Set<ConstraintDescriptor<?>> getConstraintDescriptors()
    {
      Set<ConstraintDescriptor<?>> matchingDescriptors = new HashSet();
      findMatchingDescriptors(matchingDescriptors);
      return Collections.unmodifiableSet(matchingDescriptors);
    }
    
    private void findMatchingDescriptors(Set<ConstraintDescriptor<?>> matchingDescriptors)
    {
      if (!groups.isEmpty())
      {
        GroupChain groupChain = new GroupChainGenerator().getGroupChainFor(groups);
        Iterator<Group> groupIterator = groupChain.getGroupIterator();
        while (groupIterator.hasNext())
        {
          Group g = (Group)groupIterator.next();
          addMatchingDescriptorsForGroup(g.getGroup(), matchingDescriptors);
        }
      }
      else
      {
        for (ConstraintDescriptorImpl<?> descriptor : constraintDescriptors) {
          if ((definedInSet.contains(descriptor.getDefinedOn())) && (elementTypes.contains(descriptor.getElementType()))) {
            matchingDescriptors.add(descriptor);
          }
        }
      }
    }
    
    public boolean hasConstraints()
    {
      return getConstraintDescriptors().size() != 0;
    }
    
    private void addMatchingDescriptorsForGroup(Class<?> group, Set<ConstraintDescriptor<?>> matchingDescriptors)
    {
      for (ConstraintDescriptorImpl<?> descriptor : constraintDescriptors) {
        if ((definedInSet.contains(descriptor.getDefinedOn())) && (elementTypes.contains(descriptor.getElementType())) && (descriptor.getGroups().contains(group))) {
          matchingDescriptors.add(descriptor);
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.metadata.ElementDescriptorImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.metadata;

class MetaConstraint$1
{
  static
  {
    try
    {
      $SwitchMap$java$lang$annotation$ElementType[java.lang.annotation.ElementType.TYPE.ordinal()] = 1;
    }
    catch (NoSuchFieldError ex) {}
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.metadata.MetaConstraint.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.metadata;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.ValidationException;
import org.hibernate.validator.engine.ConstraintTree;
import org.hibernate.validator.engine.GlobalExecutionContext;
import org.hibernate.validator.engine.LocalExecutionContext;
import org.hibernate.validator.util.ReflectionHelper;

public class MetaConstraint<T, A extends Annotation>
{
  private final Member member;
  private final String propertyName;
  private final Class<T> beanClass;
  private final ConstraintTree<A> constraintTree;
  
  public MetaConstraint(Class<T> beanClass, Member member, ConstraintDescriptorImpl<A> constraintDescriptor)
  {
    this.member = member;
    if (this.member != null)
    {
      propertyName = ReflectionHelper.getPropertyName(member);
      if (((member instanceof Method)) && (propertyName == null)) {
        throw new ValidationException("Annotated methods must follow the JavaBeans naming convention. " + member.getName() + "() does not.");
      }
    }
    else
    {
      propertyName = null;
    }
    this.beanClass = beanClass;
    constraintTree = new ConstraintTree(constraintDescriptor);
  }
  
  public Set<Class<?>> getGroupList()
  {
    return constraintTree.getDescriptor().getGroups();
  }
  
  public ConstraintDescriptorImpl<A> getDescriptor()
  {
    return constraintTree.getDescriptor();
  }
  
  public Class<T> getBeanClass()
  {
    return beanClass;
  }
  
  public Member getMember()
  {
    return member;
  }
  
  public String getPropertyName()
  {
    return propertyName;
  }
  
  public ElementType getElementType()
  {
    return constraintTree.getDescriptor().getElementType();
  }
  
  public <T, U, V> boolean validateConstraint(GlobalExecutionContext<T> executionContext, LocalExecutionContext<U, V> localExecutionContext)
  {
    List<ConstraintViolation<T>> constraintViolations = new ArrayList();
    localExecutionContext.setElementType(getElementType());
    constraintTree.validateConstraints(typeOfAnnotatedElement(), executionContext, localExecutionContext, constraintViolations);
    if (constraintViolations.size() > 0)
    {
      executionContext.addConstraintFailures(constraintViolations);
      return false;
    }
    return true;
  }
  
  public Object getValue(Object o)
  {
    switch (getElementType())
    {
    case TYPE: 
      return o;
    }
    return ReflectionHelper.getValue(member, o);
  }
  
  private Type typeOfAnnotatedElement()
  {
    Type t;
    switch (getElementType())
    {
    case TYPE: 
      t = beanClass;
      break;
    default: 
      t = ReflectionHelper.typeOf(member);
      if (((t instanceof Class)) && (((Class)t).isPrimitive())) {
        t = ReflectionHelper.boxedType(t);
      }
      break;
    }
    return t;
  }
  
  public String toString()
  {
    StringBuilder sb = new StringBuilder();
    sb.append("MetaConstraint");
    sb.append("{beanClass=").append(beanClass);
    sb.append(", member=").append(member);
    sb.append(", propertyName='").append(propertyName).append('\'');
    sb.append('}');
    return sb.toString();
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.metadata.MetaConstraint
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.metadata;

import javax.validation.metadata.PropertyDescriptor;

public class PropertyDescriptorImpl
  extends ElementDescriptorImpl
  implements PropertyDescriptor
{
  private final boolean cascaded;
  private final String property;
  
  public PropertyDescriptorImpl(Class<?> returnType, boolean cascaded, String property, BeanMetaData<?> beanMetaData)
  {
    super(returnType, beanMetaData);
    this.cascaded = cascaded;
    this.property = property;
  }
  
  public boolean isCascaded()
  {
    return cascaded;
  }
  
  public String getPropertyName()
  {
    return property;
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.metadata.PropertyDescriptorImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util.annotationfactory;

import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class AnnotationDescriptor<T extends Annotation>
{
  private final Class<T> type;
  private final Map<String, Object> elements = new HashMap();
  
  public AnnotationDescriptor(Class<T> annotationType)
  {
    type = annotationType;
  }
  
  public AnnotationDescriptor(Class<T> annotationType, Map<String, Object> elements)
  {
    type = annotationType;
    for (Map.Entry<String, Object> entry : elements.entrySet()) {
      this.elements.put(entry.getKey(), entry.getValue());
    }
  }
  
  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<T> type()
  {
    return type;
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.annotationfactory.AnnotationDescriptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util.annotationfactory;

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;
import java.security.AccessController;
import org.hibernate.validator.util.GetClassLoader;
import org.hibernate.validator.util.GetConstructor;

public class AnnotationFactory
{
  public static <T extends Annotation> T create(AnnotationDescriptor<T> descriptor)
  {
    boolean isSecured = System.getSecurityManager() != null;
    GetClassLoader action = GetClassLoader.fromContext();
    ClassLoader classLoader = isSecured ? (ClassLoader)AccessController.doPrivileged(action) : action.run();
    
    Class<T> proxyClass = Proxy.getProxyClass(classLoader, new Class[] { 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
  {
    GetConstructor<T> action = GetConstructor.action(proxyClass, new Class[] { InvocationHandler.class });
    Constructor<T> constructor;
    Constructor<T> constructor;
    if (System.getSecurityManager() != null) {
      constructor = (Constructor)AccessController.doPrivileged(action);
    } else {
      constructor = action.run();
    }
    return (Annotation)constructor.newInstance(new Object[] { handler });
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.annotationfactory.AnnotationFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util.annotationfactory;

import java.lang.reflect.Method;
import java.util.Comparator;

class AnnotationProxy$1
  implements Comparator<Method>
{
  AnnotationProxy$1(AnnotationProxy paramAnnotationProxy) {}
  
  public int compare(Method o1, Method o2)
  {
    return o1.getName().compareTo(o2.getName());
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.annotationfactory.AnnotationProxy.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util.annotationfactory;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
import org.hibernate.validator.util.GetDeclaredMethods;

public class AnnotationProxy
  implements Annotation, InvocationHandler
{
  private final Class<? extends Annotation> annotationType;
  private final Map<Method, Object> values;
  
  public AnnotationProxy(AnnotationDescriptor descriptor)
  {
    annotationType = descriptor.type();
    values = getAnnotationValues(descriptor);
  }
  
  private Map<Method, Object> getAnnotationValues(AnnotationDescriptor descriptor)
  {
    Map<Method, Object> result = new HashMap();
    int processedValuesFromDescriptor = 0;
    GetDeclaredMethods action = GetDeclaredMethods.action(annotationType);
    Method[] declaredMethods;
    Method[] declaredMethods;
    if (System.getSecurityManager() != null) {
      declaredMethods = (Method[])AccessController.doPrivileged(action);
    } else {
      declaredMethods = action.run();
    }
    for (Method m : declaredMethods) {
      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 paramters.");
    }
    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(", ");
    }
    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(new Comparator()
    {
      public int compare(Method o1, Method o2)
      {
        return o1.getName().compareTo(o2.getName());
      }
    });
    result.addAll(values.keySet());
    return result;
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.annotationfactory.AnnotationProxy
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.security.PrivilegedAction;

public class ContainsField
  implements PrivilegedAction<Boolean>
{
  private final Class<?> clazz;
  private final String property;
  
  public static ContainsField action(Class<?> clazz, String property)
  {
    return new ContainsField(clazz, property);
  }
  
  private ContainsField(Class<?> clazz, String property)
  {
    this.clazz = clazz;
    this.property = property;
  }
  
  public Boolean run()
  {
    try
    {
      clazz.getDeclaredField(property);
      return Boolean.valueOf(true);
    }
    catch (NoSuchFieldException e) {}
    return Boolean.valueOf(false);
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.ContainsField
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.security.PrivilegedAction;

public class ContainsMethod
  implements PrivilegedAction<Boolean>
{
  private final Class<?> clazz;
  private final String property;
  
  public static ContainsMethod action(Class<?> clazz, String property)
  {
    return new ContainsMethod(clazz, property);
  }
  
  private ContainsMethod(Class<?> clazz, String property)
  {
    this.clazz = clazz;
    this.property = property;
  }
  
  public Boolean run()
  {
    return Boolean.valueOf(ReflectionHelper.getMethod(clazz, property) != null);
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.ContainsMethod
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.lang.annotation.Annotation;
import java.security.PrivilegedAction;

public class GetAnnotationParameter<T>
  implements PrivilegedAction<T>
{
  private final Annotation annotation;
  private final String parameterName;
  private final Class<T> type;
  
  public static <T> GetAnnotationParameter<T> action(Annotation annotation, String parameterName, Class<T> type)
  {
    return new GetAnnotationParameter(annotation, parameterName, type);
  }
  
  private GetAnnotationParameter(Annotation annotation, String parameterName, Class<T> type)
  {
    this.annotation = annotation;
    this.parameterName = parameterName;
    this.type = type;
  }
  
  public T run()
  {
    return (T)ReflectionHelper.getAnnotationParameter(annotation, parameterName, type);
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.GetAnnotationParameter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.security.PrivilegedAction;

public class GetClassLoader
  implements PrivilegedAction<ClassLoader>
{
  private final Class<?> clazz;
  
  public static GetClassLoader fromContext()
  {
    return new GetClassLoader(null);
  }
  
  public static GetClassLoader fromClass(Class<?> clazz)
  {
    if (clazz == null) {
      throw new IllegalArgumentException("Class is null");
    }
    return new GetClassLoader(clazz);
  }
  
  private GetClassLoader(Class<?> clazz)
  {
    this.clazz = clazz;
  }
  
  public ClassLoader run()
  {
    if (clazz != null) {
      return clazz.getClassLoader();
    }
    return Thread.currentThread().getContextClassLoader();
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.GetClassLoader
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.lang.reflect.Constructor;
import java.security.PrivilegedAction;

public class GetConstructor<T>
  implements PrivilegedAction<Constructor<T>>
{
  private final Class<T> clazz;
  private final Class<?>[] params;
  
  public static <T> GetConstructor<T> action(Class<T> clazz, Class<?>... params)
  {
    return new GetConstructor(clazz, params);
  }
  
  private GetConstructor(Class<T> clazz, Class<?>... params)
  {
    this.clazz = clazz;
    this.params = params;
  }
  
  public Constructor<T> run()
  {
    try
    {
      return clazz.getConstructor(params);
    }
    catch (NoSuchMethodException e) {}
    return null;
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.GetConstructor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.lang.reflect.Field;
import java.security.PrivilegedAction;

public class GetDeclaredField
  implements PrivilegedAction<Field>
{
  private final Class<?> clazz;
  private final String fieldName;
  
  public static GetDeclaredField action(Class<?> clazz, String fieldName)
  {
    return new GetDeclaredField(clazz, fieldName);
  }
  
  private GetDeclaredField(Class<?> clazz, String fieldName)
  {
    this.clazz = clazz;
    this.fieldName = fieldName;
  }
  
  public Field run()
  {
    try
    {
      Field field = clazz.getDeclaredField(fieldName);
      ReflectionHelper.setAccessibility(field);
      return field;
    }
    catch (NoSuchFieldException e) {}
    return null;
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.GetDeclaredField
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.lang.reflect.Field;
import java.security.PrivilegedAction;

public class GetDeclaredFields
  implements PrivilegedAction<Field[]>
{
  private final Class<?> clazz;
  
  public static GetDeclaredFields action(Class<?> clazz)
  {
    return new GetDeclaredFields(clazz);
  }
  
  private GetDeclaredFields(Class<?> clazz)
  {
    this.clazz = clazz;
  }
  
  public Field[] run()
  {
    return clazz.getDeclaredFields();
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.GetDeclaredFields
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.lang.reflect.Method;
import java.security.PrivilegedAction;

public class GetDeclaredMethods
  implements PrivilegedAction<Method[]>
{
  private final Class<?> clazz;
  
  public static GetDeclaredMethods action(Class<?> clazz)
  {
    return new GetDeclaredMethods(clazz);
  }
  
  private GetDeclaredMethods(Class<?> clazz)
  {
    this.clazz = clazz;
  }
  
  public Method[] run()
  {
    return clazz.getDeclaredMethods();
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.GetDeclaredMethods
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.lang.reflect.Method;
import java.security.PrivilegedAction;

public class GetMethod
  implements PrivilegedAction<Method>
{
  private final Class<?> clazz;
  private final String methodName;
  
  public static GetMethod action(Class<?> clazz, String methodName)
  {
    return new GetMethod(clazz, methodName);
  }
  
  private GetMethod(Class<?> clazz, String methodName)
  {
    this.clazz = clazz;
    this.methodName = methodName;
  }
  
  public Method run()
  {
    try
    {
      return clazz.getMethod(methodName, new Class[0]);
    }
    catch (NoSuchMethodException e) {}
    return null;
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.GetMethod
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.lang.reflect.Method;
import java.security.PrivilegedAction;

public class GetMethodFromPropertyName
  implements PrivilegedAction<Method>
{
  private final Class<?> clazz;
  private final String property;
  
  public static GetMethodFromPropertyName action(Class<?> clazz, String property)
  {
    return new GetMethodFromPropertyName(clazz, property);
  }
  
  private GetMethodFromPropertyName(Class<?> clazz, String property)
  {
    this.clazz = clazz;
    this.property = property;
  }
  
  public Method run()
  {
    return ReflectionHelper.getMethod(clazz, property);
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.GetMethodFromPropertyName
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.lang.reflect.Method;
import java.security.PrivilegedAction;

public class GetMethods
  implements PrivilegedAction<Method[]>
{
  private final Class<?> clazz;
  
  public static GetMethods action(Class<?> clazz)
  {
    return new GetMethods(clazz);
  }
  
  private GetMethods(Class<?> clazz)
  {
    this.clazz = clazz;
  }
  
  public Method[] run()
  {
    return clazz.getMethods();
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.GetMethods
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.util.Collection;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class IdentitySet
  implements Set
{
  private Map<Object, Object> map;
  private Object CONTAINS = new Object();
  
  public IdentitySet()
  {
    this(10);
  }
  
  public IdentitySet(int size)
  {
    map = new IdentityHashMap(size);
  }
  
  public int size()
  {
    return map.size();
  }
  
  public boolean isEmpty()
  {
    return map.isEmpty();
  }
  
  public boolean contains(Object o)
  {
    return map.containsKey(o);
  }
  
  public Iterator iterator()
  {
    return map.keySet().iterator();
  }
  
  public Object[] toArray()
  {
    return map.keySet().toArray();
  }
  
  public boolean add(Object o)
  {
    return map.put(o, CONTAINS) == null;
  }
  
  public boolean remove(Object o)
  {
    return map.remove(o) == CONTAINS;
  }
  
  public boolean addAll(Collection c)
  {
    boolean doThing = false;
    for (Object o : c) {
      doThing = (doThing) || (add(o));
    }
    return doThing;
  }
  
  public void clear()
  {
    map.clear();
  }
  
  public boolean removeAll(Collection c)
  {
    boolean remove = false;
    for (Object o : c) {
      remove = (remove) || (remove(o));
    }
    return remove;
  }
  
  public boolean retainAll(Collection c)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean containsAll(Collection c)
  {
    for (Object o : c) {
      if (!contains(o)) {
        return false;
      }
    }
    return true;
  }
  
  public Object[] toArray(Object[] a)
  {
    return map.keySet().toArray(a);
  }
  
  public String toString()
  {
    return "IdentitySet{map=" + map + '}';
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.IdentitySet
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import javax.validation.Configuration;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.MessageInterpolator;
import javax.validation.TraversableResolver;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorContext;
import javax.validation.ValidatorFactory;

public class LazyValidatorFactory
  implements ValidatorFactory
{
  private final Configuration<?> configuration;
  private volatile ValidatorFactory delegate;
  
  public LazyValidatorFactory()
  {
    this(null);
  }
  
  public LazyValidatorFactory(Configuration<?> configuration)
  {
    this.configuration = configuration;
  }
  
  private ValidatorFactory getDelegate()
  {
    ValidatorFactory result = delegate;
    if (result == null) {
      synchronized (this)
      {
        result = delegate;
        if (result == null) {
          delegate = (result = initFactory());
        }
      }
    }
    return result;
  }
  
  public Validator getValidator()
  {
    return getDelegate().getValidator();
  }
  
  private ValidatorFactory initFactory()
  {
    if (configuration == null) {
      return Validation.buildDefaultValidatorFactory();
    }
    return configuration.buildValidatorFactory();
  }
  
  public ValidatorContext usingContext()
  {
    return getDelegate().usingContext();
  }
  
  public MessageInterpolator getMessageInterpolator()
  {
    return getDelegate().getMessageInterpolator();
  }
  
  public TraversableResolver getTraversableResolver()
  {
    return getDelegate().getTraversableResolver();
  }
  
  public ConstraintValidatorFactory getConstraintValidatorFactory()
  {
    return getDelegate().getConstraintValidatorFactory();
  }
  
  public <T> T unwrap(Class<T> clazz)
  {
    return (T)getDelegate().unwrap(clazz);
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.LazyValidatorFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import java.security.PrivilegedAction;
import javax.validation.ValidationException;

public class LoadClass
  implements PrivilegedAction<Class<?>>
{
  private final String className;
  private final Class<?> caller;
  
  public static LoadClass action(String className, Class<?> caller)
  {
    return new LoadClass(className, caller);
  }
  
  private LoadClass(String className, Class<?> caller)
  {
    this.className = className;
    this.caller = caller;
  }
  
  public Class<?> run()
  {
    try
    {
      ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
      if (contextClassLoader != null) {
        return contextClassLoader.loadClass(className);
      }
    }
    catch (Throwable e) {}
    try
    {
      return Class.forName(className, true, caller.getClassLoader());
    }
    catch (ClassNotFoundException e)
    {
      throw new ValidationException("Unable to load class: " + className, e);
    }
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.LoadClass
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validator.util;

import org.slf4j.Logger;

public class LoggerFactory
{
  public static Logger make()
  {
    Throwable t = new Throwable();
    StackTraceElement directCaller = t.getStackTrace()[1];
    return org.slf4j.LoggerFactory.getLogger(directCaller.getClassName());
  }
}

/* Location:
 * Qualified Name:     org.hibernate.validator.util.LoggerFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.hibernate.validat
1 2 3 4 5 6 7 8 9 10 11

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd