001 /******************************************************************************* 002 * Portions created by Sebastian Thomschke are copyright (c) 2005-2011 Sebastian 003 * Thomschke. 004 * 005 * All Rights Reserved. This program and the accompanying materials 006 * are made available under the terms of the Eclipse Public License v1.0 007 * which accompanies this distribution, and is available at 008 * http://www.eclipse.org/legal/epl-v10.html 009 * 010 * Contributors: 011 * Sebastian Thomschke - initial implementation. 012 *******************************************************************************/ 013 package net.sf.oval.guard; 014 015 import net.sf.oval.AbstractCheck; 016 import net.sf.oval.Validator; 017 import net.sf.oval.context.OValContext; 018 import net.sf.oval.exception.OValException; 019 020 /** 021 * @author Sebastian Thomschke 022 */ 023 public class PostCheck extends AbstractCheck 024 { 025 private static final long serialVersionUID = 1L; 026 027 private String expression; 028 private String language; 029 private String old; 030 031 public void configure(final Post constraintAnnotation) 032 { 033 setMessage(constraintAnnotation.message()); 034 setErrorCode(constraintAnnotation.errorCode()); 035 setSeverity(constraintAnnotation.severity()); 036 setExpression(constraintAnnotation.expr()); 037 setLanguage(constraintAnnotation.lang()); 038 setOld(constraintAnnotation.old()); 039 setProfiles(constraintAnnotation.profiles()); 040 } 041 042 /** 043 * @return the condition 044 */ 045 public String getExpression() 046 { 047 return expression; 048 } 049 050 /** 051 * @return the language 052 */ 053 public String getLanguage() 054 { 055 return language; 056 } 057 058 /** 059 * @return the old 060 */ 061 public String getOld() 062 { 063 return old; 064 } 065 066 /** 067 * {@inheritDoc} 068 */ 069 public boolean isSatisfied(final Object validatedObject, final Object valueToValidate, final OValContext context, 070 final Validator validator) throws OValException 071 { 072 throw new UnsupportedOperationException(); 073 } 074 075 /** 076 * @param condition the condition to set 077 */ 078 public void setExpression(final String condition) 079 { 080 expression = condition; 081 } 082 083 /** 084 * @param language the language to set 085 */ 086 public void setLanguage(final String language) 087 { 088 this.language = language; 089 } 090 091 /** 092 * @param old the old to set 093 */ 094 public void setOld(final String old) 095 { 096 this.old = old; 097 } 098 }