KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > internal > databinding > provisional > validation > ValidationError


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  ******************************************************************************/

11
12 package org.eclipse.jface.internal.databinding.provisional.validation;
13
14 /**
15  * @since 1.0
16  *
17  */

18 public class ValidationError {
19     
20     /**
21      * A constant indicating that something may not be quite right.
22      */

23     public static final int WARNING = 1;
24     
25     /**
26      * A constant indicating that something bad has happened.
27      */

28     public static final int ERROR = 2;
29
30     /**
31      * Indicates the current status.
32      */

33     public final int status;
34     
35     /**
36      * Holds the current error or warning message.
37      */

38     public final String JavaDoc message;
39     
40     /**
41      * A convenience factory for error ValidationResults representing errors.
42      *
43      * @param message The error message
44      * @return A new ValidationResult representing the error
45      */

46     public static ValidationError error(String JavaDoc message) {
47         return new ValidationError(ERROR, message);
48     }
49     
50     /**
51      * A convenience factory for warning ValidationResults.
52      *
53      * @param message The warning message
54      * @return A new ValidationResult representing the warning
55      */

56     public static ValidationError warning(String JavaDoc message) {
57         return new ValidationError(WARNING, message);
58     }
59     
60     /**
61      * Construct a ValidationResult with an arbitrary status and error message.
62      *
63      * @param status One of the constants in ValidationResult.
64      * @param message An error message string or warning.
65      */

66     public ValidationError(int status, String JavaDoc message) {
67         this.status = status;
68         this.message = message;
69     }
70     
71     public String JavaDoc toString() {
72         return message;
73     }
74 }
75
76
Popular Tags