Пример #1
0
  void decode(final T o, final Entry e) throws LDAPPersistException {
    if (superclassHandler != null) {
      superclassHandler.decode(o, e);
    }

    setDNAndEntryFields(o, e);

    final ArrayList<String> failureReasons = new ArrayList<String>(5);
    boolean successful = true;

    for (final FieldInfo i : fieldMap.values()) {
      successful &= i.decode(o, e, failureReasons);
    }

    for (final SetterInfo i : setterMap.values()) {
      successful &= i.invokeSetter(o, e, failureReasons);
    }

    Throwable cause = null;
    if (postDecodeMethod != null) {
      try {
        postDecodeMethod.invoke(o);
      } catch (final Throwable t) {
        debugException(t);

        if (t instanceof InvocationTargetException) {
          cause = ((InvocationTargetException) t).getTargetException();
        } else {
          cause = t;
        }

        successful = false;
        failureReasons.add(
            ERR_OBJECT_HANDLER_ERROR_INVOKING_POST_DECODE_METHOD.get(
                postDecodeMethod.getName(), type.getName(), getExceptionMessage(t)));
      }
    }

    if (!successful) {
      throw new LDAPPersistException(concatenateStrings(failureReasons), o, cause);
    }
  }