View Javadoc
1   /*******************************************************************************
2    * Portions created by Sebastian Thomschke are copyright (c) 2005-2011 Sebastian
3    * Thomschke.
4    * 
5    * All Rights Reserved. This program and the accompanying materials
6    * are made available under the terms of the Eclipse Public License v1.0
7    * which accompanies this distribution, and is available at
8    * http://www.eclipse.org/legal/epl-v10.html
9    * 
10   * Contributors:
11   *     Sebastian Thomschke - initial implementation.
12   *******************************************************************************/
13  package net.sf.oval.guard;
14  
15  import net.sf.oval.AbstractCheck;
16  import net.sf.oval.Validator;
17  import net.sf.oval.context.OValContext;
18  import net.sf.oval.exception.OValException;
19  
20  /**
21   * @author Sebastian Thomschke
22   */
23  public class PreCheck extends AbstractCheck
24  {
25  	private static final long serialVersionUID = 1L;
26  
27  	private String expression;
28  	private String language;
29  
30  	public void configure(final Pre constraintAnnotation)
31  	{
32  		setMessage(constraintAnnotation.message());
33  		setErrorCode(constraintAnnotation.errorCode());
34  		setSeverity(constraintAnnotation.severity());
35  		setExpression(constraintAnnotation.expr());
36  		setLanguage(constraintAnnotation.lang());
37  		setProfiles(constraintAnnotation.profiles());
38  	}
39  
40  	/**
41  	 * @return the condition
42  	 */
43  	public String getExpression()
44  	{
45  		return expression;
46  	}
47  
48  	/**
49  	 * @return the language
50  	 */
51  	public String getLanguage()
52  	{
53  		return language;
54  	}
55  
56  	/**
57  	 * {@inheritDoc}
58  	 */
59  	public boolean isSatisfied(final Object validatedObject, final Object valueToValidate, final OValContext context,
60  			final Validator validator) throws OValException
61  	{
62  		throw new UnsupportedOperationException();
63  	}
64  
65  	/**
66  	 * @param condition the condition to set
67  	 */
68  	public void setExpression(final String condition)
69  	{
70  		expression = condition;
71  	}
72  
73  	/**
74  	 * @param language the language to set
75  	 */
76  	public void setLanguage(final String language)
77  	{
78  		this.language = language;
79  	}
80  }