@Override
  public void setValue(Object newValue) throws ReadOnlyException, ConversionException {
    if (isReadOnly()) {
      throw new ReadOnlyException();
    }

    // If invalid values are not allowed, the value must be checked
    if (!isInvalidAllowed()) {
      final Collection<Validator> v = getValidators();
      if (v != null) {
        for (Validator validator : v) {
          validator.validate(newValue);
        }
      }
    }

    Type current = convertValue(wrapped.getValue());
    Type prevCache = cache;
    cache = convertValue(newValue);
    processNewCacheValue();
    if (differ(current, cache)) {
      modified = true;
      if (isWriteThrough()) {
        commit();
      }
    } else {
      modified = false;
    }
    if (differ(prevCache, cache)) {
      fireValueChange();
    }
  }
 /** @see com.vaadin.data.Validatable#isValid() */
 @Override
 public boolean isValid() {
   if (validators != null) {
     for (Validator validator : validators) {
       if (!validator.isValid(this.getValue())) {
         return false;
       }
     }
   }
   return true;
 }
 /** @see com.vaadin.data.Validatable#validate() */
 @Override
 public void validate() throws InvalidValueException {
   LinkedList<InvalidValueException> errors = null;
   if (validators != null) {
     for (Validator validator : validators) {
       try {
         validator.validate(this.getValue());
       } catch (InvalidValueException e) {
         if (errors == null) {
           errors = new LinkedList<InvalidValueException>();
         }
         errors.add(e);
       }
     }
   }
   if (errors != null) {
     throw new InvalidValueException(null, errors.toArray(new InvalidValueException[0]));
   }
 }
Пример #4
0
 public boolean isValid(Object value) {
   return validator.isValid(converter.parse((FIELD_DATA_TYPE) value));
 }
Пример #5
0
 public void validate(Object value) throws InvalidValueException {
   validator.validate(converter.parse((FIELD_DATA_TYPE) value));
 }