KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > databinding > validation > ReadOnlyValidator


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

13 package org.eclipse.core.internal.databinding.validation;
14
15 import org.eclipse.core.databinding.validation.IValidator;
16 import org.eclipse.core.databinding.validation.ValidationStatus;
17 import org.eclipse.core.internal.databinding.BindingMessages;
18 import org.eclipse.core.runtime.IStatus;
19
20 /**
21  * ReadOnlyValidator. A validator that can be used as a partial validator for read-only fields.
22  */

23 public class ReadOnlyValidator implements IValidator {
24
25     private static ReadOnlyValidator singleton = null;
26
27     /**
28      * Returns the ReadOnlyValidator
29      *
30      * @return the ReadOnlyValidator
31      */

32     public static ReadOnlyValidator getDefault() {
33         if (singleton == null) {
34             singleton = new ReadOnlyValidator();
35         }
36         return singleton;
37     }
38
39     public IStatus validate(Object JavaDoc value) {
40         // No changes are allowed
41
return ValidationStatus.error(BindingMessages
42                 .getString("Validate_NoChangeAllowedHelp")); //$NON-NLS-1$
43
}
44
45 }
46
Popular Tags