001: /*******************************************************************************
002: * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 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: *******************************************************************************/package net.sf.oval.constraint;
013:
014: import net.sf.oval.Validator;
015: import net.sf.oval.configuration.annotation.AbstractAnnotationCheck;
016: import net.sf.oval.context.OValContext;
017:
018: /**
019: * @author Sebastian Thomschke
020: */
021: public class AssertFieldConstraintsCheck extends
022: AbstractAnnotationCheck<AssertFieldConstraints> {
023: private static final long serialVersionUID = 1L;
024:
025: private String fieldName;
026:
027: private Class declaringClass;
028:
029: @Override
030: public void configure(
031: final AssertFieldConstraints constraintAnnotation) {
032: super .configure(constraintAnnotation);
033: setFieldName(constraintAnnotation.value());
034: setDeclaringClass(constraintAnnotation.declaringClass());
035: }
036:
037: /**
038: * @return the declaringClass
039: */
040: public Class getDeclaringClass() {
041: return declaringClass;
042: }
043:
044: @Override
045: public String getErrorCode() {
046: throw new UnsupportedOperationException();
047: }
048:
049: /**
050: * @return the fieldName
051: */
052: public String getFieldName() {
053: return fieldName;
054: }
055:
056: @Override
057: public String getMessage() {
058: throw new UnsupportedOperationException();
059: }
060:
061: @Override
062: public int getSeverity() {
063: throw new UnsupportedOperationException();
064: }
065:
066: /**
067: * <b>This method is not used.</b><br>
068: * The validation of this special constraint is directly performed by the Validator class
069: */
070: public boolean isSatisfied(final Object validatedObject,
071: final Object value, final OValContext context,
072: final Validator validator) {
073: throw new UnsupportedOperationException();
074: }
075:
076: /**
077: * @param declaringClass the declaringClass to set
078: */
079: public void setDeclaringClass(final Class declaringClass) {
080: this .declaringClass = declaringClass == Void.class ? null
081: : declaringClass;
082: }
083:
084: @Override
085: public void setErrorCode(final String errorCode) {
086: throw new UnsupportedOperationException();
087: }
088:
089: /**
090: * @param fieldName the fieldName to set
091: */
092: public void setFieldName(final String fieldName) {
093: this .fieldName = fieldName;
094: }
095:
096: @Override
097: public void setMessage(final String message) {
098: throw new UnsupportedOperationException();
099: }
100:
101: @Override
102: public void setSeverity(final int severity) {
103: throw new UnsupportedOperationException();
104: }
105: }
|