01: /*
02: * $Header: /cvsroot/jvalidate/jvalidate-framework/jvalidate/src/test/java/nl/knowlogy/validation/metadata/testexample/TestObject.java,v 1.3 2007/03/24 17:17:57 roberthofstra Exp $
03: * $Revision: 1.3 $
04: * $Date: 2007/03/24 17:17:57 $
05: *
06: *
07: * Created on Oct 6, 2004
08: *
09: * All right reserved(c) 2004, Knowlogy
10: *
11: * Copyright 2004 - 2005 Knowlogy, the Netherlands. All rights reserved.
12: * All Knowlogy brand and product names are trademarks or registered trademarks
13: * of Knowlogy in the Netherlands and other countries.
14: *
15: * No part of this publication may be reproduced, transmitted, stored in a retrieval system,
16: * or translated into any human or computer language, in any form, or by any means, electronic,
17: * mechanical, magnetic, optical, chemical, manual, or otherwise,
18: * without the prior written permission of the copyright owner, Knowlogy.
19: *
20: */
21: package nl.knowlogy.validation.metadata.testexample;
22:
23: import nl.knowlogy.validation.ClassValidator;
24: import nl.knowlogy.validation.ClassValidatorImpl;
25: import nl.knowlogy.validation.MessageType;
26: import nl.knowlogy.validation.Messages;
27: import nl.knowlogy.validation.PropertyValidation;
28:
29: /**
30: *
31: * @author Robert
32: */
33: public class TestObject {
34:
35: private String testValue;
36: private static final ClassValidator testObjectValidator = new ClassValidatorImpl(
37: null);
38:
39: {
40:
41: testObjectValidator.add(new PropertyValidation() {
42: /*
43: * (non-Javadoc)
44: *
45: * @see nl.knowlogy.validation.metadata.PropertyValidation#getPropertyName()
46: */
47: public String getPropertyName() {
48:
49: return "test";
50: }
51:
52: /* (non-Javadoc)
53: * @see nl.knowlogy.validation.metadata.PropertyValidation#doValidatePropertyValue(java.lang.Object, nl.knowlogy.validation.errors.Errors)
54: */
55: public void doValidatePropertyValue(Object toValidate,
56: Object value, Messages errors) {
57: if (value.equals("ok")) {
58: errors.addPropertyMessage(MessageType.ERROR,
59: toValidate, "testvalue", "nok");
60: }
61:
62: }
63:
64: });
65: }
66:
67: public String getTestValue() {
68: return testValue;
69: }
70:
71: public void setTestValue(String value) {
72: testValue = value;
73: }
74:
75: public void validate(Messages errors) {
76: testObjectValidator.validate(this, errors);
77: }
78: }
|