root / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / plugins / config / generate / MyFieldValidator.java @ 38564
History | View | Annotate | Download (812 Bytes)
1 |
package org.gvsig.andami.plugins.config.generate; |
---|---|
2 |
|
3 |
import org.exolab.castor.xml.ValidationContext; |
4 |
import org.exolab.castor.xml.ValidationException; |
5 |
|
6 |
class MyFieldValidator extends org.exolab.castor.xml.FieldValidator { |
7 |
public void validate(Object arg0, ValidationContext arg1) |
8 |
throws ValidationException {
|
9 |
try {
|
10 |
super.validate(arg0, arg1);
|
11 |
} catch (ValidationException e) {
|
12 |
throw getException(e,arg0);
|
13 |
} |
14 |
} |
15 |
|
16 |
public void validate(Object object) throws ValidationException { |
17 |
try {
|
18 |
super.validate(object);
|
19 |
} catch (ValidationException e) {
|
20 |
throw getException(e,object);
|
21 |
} |
22 |
} |
23 |
|
24 |
private ValidationException getException(ValidationException ex, Object obj) { |
25 |
if( obj == null ) { |
26 |
return ex;
|
27 |
} |
28 |
return new ValidationException( ex.getMessage() + ". " + obj.toString(), ex); |
29 |
} |
30 |
} |