Project

General

Profile

Download (1.05 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.propertysheet;
11

    
12
import org.eclipse.jface.viewers.ICellEditorValidator;
13

    
14
/**
15
 * @author p.ciardelli
16
 * @created 11.11.2008
17
 * @version 1.0
18
 */
19
public class DayValidator implements ICellEditorValidator {
20

    
21
	/* (non-Javadoc)
22
	 * @see org.eclipse.jface.viewers.ICellEditorValidator#isValid(java.lang.Object)
23
	 */
24
	
25
	public String isValid(Object value) {
26
		
27
		String msg = "Value in day field must be an integer between 1-31."; 
28
		
29
		if (((String) value).equals("")) {
30
			return null;
31
		}
32
		
33
		Integer day = 0;
34
		try {
35
			day = new Integer((String) value);
36
		} catch (ClassCastException e) {
37
			return msg;
38
		} catch (NumberFormatException e) {
39
			return msg;
40
		}
41

    
42
		if (day == 0 || day > 31) {
43
			return msg;
44
		}
45
		
46
		return null;
47
	}
48
}
(10-10/24)