示例#1
0
  /**
   * Retrieves the value of the specified attribute as a string.
   *
   * @param attributeName The name of the target attribute.
   * @return The string value of the specified attribute, or {@code null} if it does not exist in
   *     the entry.
   */
  protected final String getString(final String attributeName) {
    final String valueStr = entry.getAttributeValue(attributeName);
    if ((valueStr == null) && debugEnabled(DebugType.MONITOR)) {
      debugMonitor(entry, "No value for string attribute " + attributeName);
    }

    return valueStr;
  }
示例#2
0
  /**
   * Retrieves the value of the specified attribute as a {@code Boolean} object.
   *
   * @param attributeName The name of the target attribute.
   * @return The {@code Boolean} object parsed from the specified attribute, or {@code null} if the
   *     attribute does not exist in the entry or it cannot be parsed as a {@code Boolean} value.
   */
  protected final Boolean getBoolean(final String attributeName) {
    final String valueStr = entry.getAttributeValue(attributeName);
    if (valueStr == null) {
      if (debugEnabled(DebugType.MONITOR)) {
        debugMonitor(entry, "No value for Boolean attribute " + attributeName);
      }

      return null;
    } else if (valueStr.equalsIgnoreCase("true")) {
      return Boolean.TRUE;
    } else if (valueStr.equalsIgnoreCase("false")) {
      return Boolean.FALSE;
    } else {
      if (debugEnabled(DebugType.MONITOR)) {
        debugMonitor(
            entry, "Invalid value '" + valueStr + "' for Boolean attribute " + attributeName);
      }

      return null;
    }
  }
示例#3
0
  /**
   * Retrieves the value of the specified attribute as a {@code Long} object.
   *
   * @param attributeName The name of the target attribute.
   * @return The {@code Long} object parsed from the specified attribute, or {@code null} if the
   *     attribute does not exist in the entry or it cannot be parsed as a {@code Long} value.
   */
  protected final Long getLong(final String attributeName) {
    final String valueStr = entry.getAttributeValue(attributeName);
    if (valueStr == null) {
      if (debugEnabled(DebugType.MONITOR)) {
        debugMonitor(entry, "No value for Long attribute " + attributeName);
      }

      return null;
    } else {
      try {
        return Long.parseLong(valueStr);
      } catch (Exception e) {
        debugException(e);

        if (debugEnabled(DebugType.MONITOR)) {
          debugMonitor(
              entry, "Invalid value '" + valueStr + "' for Long attribute " + attributeName);
        }

        return null;
      }
    }
  }
示例#4
0
  /**
   * Retrieves the value of the specified attribute as a {@code Date} object.
   *
   * @param attributeName The name of the target attribute.
   * @return The {@code Date} object parsed from the specified attribute, or {@code null} if the
   *     attribute does not exist in the entry or it cannot be parsed as a {@code Date} value.
   */
  protected final Date getDate(final String attributeName) {
    final String valueStr = entry.getAttributeValue(attributeName);
    if (valueStr == null) {
      if (debugEnabled(DebugType.MONITOR)) {
        debugMonitor(entry, "No value for Date attribute " + attributeName);
      }

      return null;
    } else {
      try {
        return decodeGeneralizedTime(valueStr);
      } catch (Exception e) {
        debugException(e);

        if (debugEnabled(DebugType.MONITOR)) {
          debugMonitor(
              entry, "Invalid value '" + valueStr + "' for Date attribute " + attributeName);
        }

        return null;
      }
    }
  }