Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) 2005, 2008 Borland Software Corporation
   * 
   * All rights reserved. This program and the accompanying materials are made
   * available under the terms of the Eclipse Public License v1.0 which
   * accompanies this distribution, and is available at
   * http://www.eclipse.org/legal/epl-v10.html
   * 
   * Contributors: 
  *    Radek Dvorak (Borland) - initial API and implementation
  *    Artem Tikhomirov (Borland) - refactoring
  */
 package org.eclipse.gmf.validate;
 
 
Validator of GMF constraint annotations. FIXME: though API, should be changed - no need to extend ValidatorChain, and all the fields are sort of odd See details.
 
 public class GMFValidator extends ValidatorChain {
 	
 	private static EValidator[] GMF_VALIDATORS = new EValidator[] { 
 		ExternModelImport.newImportValidator(),				
 	};
 	
 	private static EValidator[] ALL_VALIDATORS = new EValidator[] { 
 		ExternModelImport.newImportValidator(),				
 	};
 	
 	// XXX INSTANCE should rather be new GMFValidator(), and GMFValidator cons should take ALL_VALIDATORS then.
 	
Ecore compliant validator instance.
 
 	public static final EValidator INSTANCE = new ValidatorChain();	
 	
 	private GMFValidator() {
 		super();
 	}

Validates the given object using its registered EValidator and additionally performs validation of OCL constraints annotations, value-spec and constraint definitions.

Parameters:
eObject the subject for validation
Returns:
resulting root diagnostic object containing the children diagnostic elements representing the concrete constraint validation results
 
 	public static Diagnostic validate(EObject eObject) {
 		Diagnostician diagnostician = new Diagnostician(new DelegateRegistry());
 		return diagnostician.validate(eObject);
 	}	

Validates the given object using its registered EValidator and additionally performs validation of OCL constraints annotations, value-spec and constraint definitions.

Parameters:
eObject the subject for validation
options validation options
Returns:
resulting root diagnostic object containing the children diagnostic elements representing the concrete constraint validation results
 	
 	public static Diagnostic validate(EObject eObjectValidationOptions options) {
 		Diagnostician diagnostician = new Diagnostician(new DelegateRegistry(options));
 		return diagnostician.validate(eObject);
 	}
 		
 	private static class DelegateRegistry extends HashMap<EPackageObjectimplements Registry {
 		private static final long serialVersionUID = 8069287594754687573L;
 		
 		
 		@SuppressWarnings("synthetic-access")
 			this(null);
 		}
			this. = options;
		}
		@SuppressWarnings("synthetic-access")
			if( == null) {
			}
			return ;
		}
		@SuppressWarnings("synthetic-access")
			if( == null) {
			}
		}
		public EValidator getEValidator(EPackage ePackage) {
			if(containsKey(ePackage)) {
				return (EValidator)super.get(ePackage);
			}
			EValidator delegateValidator = ..getEValidator(ePackage);
			if(delegateValidator == null || delegateValidator.getClass().equals(EObjectValidator.class)) {
				return getGmfValidator();
			}
			return createDelegator(ePackagedelegateValidator);
		}
		private EValidator createDelegator(Object keyEValidator delegate) {		
			// extend custom validator retrieved from the registry only with GMF validators
			EValidator delegatingValidator = new ValidatorChain(new EValidator[] { delegategetNoEcoreValidator() });
			put((EPackage)keydelegatingValidator);
			return delegatingValidator;
		}
		public Object get(Object key) {
			Object provider = super.get(key);
			if(provider != null) {
				return provider;
			}
			provider = ..get(key);			
			if(provider != null && provider instanceof EValidator) {
				if(provider.getClass().equals(EObjectValidator.class)) {
					return getGmfValidator();
				}
				provider = createDelegator(key, (EValidator)provider);
			}
			return provider;
		}
	}		
New to GrepCode? Check out our FAQ X