Example #1
0
  public synchronized Object getObjectValue(KeyValueCoding inspectable)
      throws AccessorInvocationException {
    if (inspectable == null) {
      if (logger.isLoggable(Level.WARNING)) {
        logger.warning(
            "Inspectable object is null for key "
                + name
                + ". We should definitely investigate this.");
      }
      return null;
    }

    try {
      KeyValueCoding target = getTargetObject(inspectable);
      if (target != null) {
        return target.objectForKey(getLastAccessor());
      } else {
        return null;
      }
    } catch (AccessorInvocationException e) {
      throw e;
    } catch (Exception e) {
      if (logger.isLoggable(Level.WARNING)) {
        logger.warning(
            "getObjectValue() failed for property "
                + name
                + " for object "
                + inspectable.getClass().getName()
                + " : exception "
                + e.getMessage());
      }
      return null;
    }
  }
Example #2
0
  public synchronized boolean hasObjectValue(KeyValueCoding inspectable)
      throws AccessorInvocationException {
    if (inspectable == null) {
      return false;
    }
    try {
      KeyValueCoding target = getTargetObject(inspectable);
      if (target != null) {
        target.objectForKey(getLastAccessor());
        return true;
      } else {
        return false;
      }

    } catch (InvalidObjectSpecificationException e) {
      return false;
    } catch (AccessorInvocationException e) {
      throw e;
    } catch (Exception e) {
      e.printStackTrace();
      if (logger.isLoggable(Level.WARNING)) {
        logger.warning(
            "getObjectValue() failed for property "
                + name
                + " for object "
                + inspectable.getClass().getName()
                + " : exception "
                + e.getMessage());
      }
      return false;
    }
  }