Revision 259 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dynobject/impl/DefaultDynField.java

View differences:

DefaultDynField.java
403 403
				}
404 404
			}
405 405
			break;
406

  
406 407
		case DataTypes.MAP:
407 408
			if (!(value instanceof Map)) {
408 409
				throw new DynFieldValidateException(value, this);
......
434 435
			}
435 436
			break;
436 437

  
437
		case DataTypes.OBJECT:
438
			if (this.theClass != null) {
439
				if (!this.theClass.isInstance(value)) {
440
					throw new DynFieldValidateException(value, this);
441
				}
442
			}
443
			break;
444

  
445 438
		case DataTypes.DYNOBJECT:
446 439
			if (!(value instanceof DynObject)) {
447 440
				throw new DynFieldValidateException(value, this);
......
463 456
			break;
464 457

  
465 458
		default:
466
			throw new DynFieldValidateException(value, this);
459
			if( this.dataType.isObject() ) {
460
				if (this.theClass != null) {
461
					if (!this.theClass.isInstance(value)) {
462
						throw new DynFieldValidateException(value, this);
463
					}
464
				}
465
			} else {
466
				throw new DynFieldValidateException(value, this);
467
			}
467 468
		}
468 469

  
469
//		if (this.mandatory && value == null) {
470
//			throw new DynFieldValidateException(value, this);
471
//		}
472

  
473 470
		if (this.getAvailableValues() != null) {
474 471
			if (!(value instanceof Comparable)) {
475 472
				throw new DynFieldValidateException(value, this);
......
495 492
				throw new DynFieldValidateException(value, this);
496 493
			}
497 494
		}
495
//
496
//      Esto no deberia hacer falta ya que cualquier asignacion pasa
497
//      Por el coerce.
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
//		}
498 505
		
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
		}
505 506
	}
506 507

  
507 508
	public Object coerce(Object value) throws CoercionException {

Also available in: Unified diff