Project

General

Profile

Download (1.16 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.apache.log4j.Logger;
13
import org.eclipse.jface.viewers.ICellEditorValidator;
14

    
15
/**
16
 * @author p.ciardelli
17
 * @created 11.11.2008
18
 * @version 1.0
19
 */
20
public class DayValidator implements ICellEditorValidator {
21
	private static final Logger logger = Logger.getLogger(DayValidator.class);
22

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

    
44
		if (day == 0 || day > 31) {
45
			return msg;
46
		}
47
		
48
		return null;
49
	}
50
}
(9-9/15)