Revision 256

View differences:

org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dynobject/exception/DynFieldRequiredValueException.java
1
package org.gvsig.tools.dynobject.exception;
2

  
3
import org.gvsig.tools.dynobject.DynField;
4

  
5
public class DynFieldRequiredValueException extends DynFieldValidateException {
6

  
7
	/**
8
	 * 
9
	 */
10
	private static final long serialVersionUID = -7813629748228774776L;
11

  
12
	public DynFieldRequiredValueException(DynField field) {
13
		super(
14
			"Required field '%(field)' is null.",
15
			"_required_field_XfieldX_is_null",
16
			serialVersionUID
17
		);
18
		setValue("field",field.getName());
19
	}
20

  
21
}
0 22

  
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dynobject/impl/DefaultDynField.java
21 21
import org.gvsig.tools.dynobject.DynObjectValueItem;
22 22
import org.gvsig.tools.dynobject.DynStruct;
23 23
import org.gvsig.tools.dynobject.exception.DynFieldIsNotAContainerException;
24
import org.gvsig.tools.dynobject.exception.DynFieldRequiereValueException;
24
import org.gvsig.tools.dynobject.exception.DynFieldRequiredValueException;
25 25
import org.gvsig.tools.dynobject.exception.DynFieldValidateException;
26 26
import org.gvsig.tools.dynobject.exception.DynObjectValidateException;
27 27
import org.gvsig.tools.exception.ListBaseException;
......
344 344
		Comparable v;
345 345
		if (value == null) {
346 346
			if (this.mandatory) {
347
				throw new DynFieldRequiereValueException(this);
347
				throw new DynFieldRequiredValueException(this);
348 348
			}
349 349
			return;
350 350
		}
......
403 403
				}
404 404
			}
405 405
			break;
406

  
407 406
		case DataTypes.MAP:
408 407
			if (!(value instanceof Map)) {
409 408
				throw new DynFieldValidateException(value, this);
......
496 495
				throw new DynFieldValidateException(value, this);
497 496
			}
498 497
		}
498
		
499
		//if all the above is correct, then we should check that coercing is possible
500
		try {
501
			coerce(value);
502
		} catch (CoercionException e) {
503
			throw new DynFieldValidateException(value, this);
504
		}
499 505
	}
500 506

  
501 507
	public Object coerce(Object value) throws CoercionException {
502 508
		if (value == null) {
503
			return value; // O debe retorna this.defaultValue
509
			return value; // O debe devolver this.defaultValue
504 510
		}
505 511
		return this.dataType.coerce(value);
506 512
	}

Also available in: Unified diff