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

org.hibernate.validator.xml.XmlMappingParser Maven / Gradle / Ivy

// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.validator.xml;

import org.hibernate.validator.metadata.AnnotationIgnores;
import org.hibernate.validator.metadata.ConstraintHelper;
import org.hibernate.validator.metadata.MetaConstraint;

import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.util.*;

/**
 * @author Hardy Ferentschik
 */
public class XmlMappingParser {

	private static final String VALIDATION_MAPPING_XSD = "META-INF/validation-mapping-1.0.xsd";
	private static final String MESSAGE_PARAM = "message";
	private static final String GROUPS_PARAM = "groups";
	private static final String PAYLOAD_PARAM = "payload";
	private static final String PACKAGE_SEPARATOR = ".";

	private final Set> processedClasses = new HashSet>();
	private final ConstraintHelper constraintHelper;
	private final AnnotationIgnores annotationIgnores;
	private final Map, List>> constraintMap;
	private final Map, List> cascadedMembers;
	private final Map, List>> defaultSequences;

	public XmlMappingParser(ConstraintHelper constraintHelper) {
		this.constraintHelper = constraintHelper;
		this.annotationIgnores = new AnnotationIgnores();
		this.constraintMap = new HashMap, List>>();
		this.cascadedMembers = new HashMap, List>();
		this.defaultSequences = new HashMap, List>>();
	}

	public void parse(Set mappingStreams) {
		
	}

	public Set> getXmlConfiguredClasses() {
		return processedClasses;
	}

	public AnnotationIgnores getAnnotationIgnores() {
		return annotationIgnores;
	}

	public  List> getConstraintsForClass(Class beanClass) {
		List> list = new ArrayList>();
		if ( constraintMap.containsKey( beanClass ) ) {
			for ( MetaConstraint metaConstraint : constraintMap.get( beanClass ) ) {
				@SuppressWarnings("unchecked") // safe cast since the list of meta constraints is always specific to the bean type
						MetaConstraint boundMetaConstraint = ( MetaConstraint ) metaConstraint;
				list.add( boundMetaConstraint );
			}
			return list;
		}
		else {
			return Collections.emptyList();
		}
	}

	public List getCascadedMembersForClass(Class beanClass) {
		if ( cascadedMembers.containsKey( beanClass ) ) {
			return cascadedMembers.get( beanClass );
		}
		else {
			return Collections.emptyList();
		}
	}

	public List> getDefaultSequenceForClass(Class beanClass) {
		if ( defaultSequences.containsKey( beanClass ) ) {
			return defaultSequences.get( beanClass );
		}
		else {
			return Collections.emptyList();
		}
	}

	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy