예제 #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 set of values of the specified attribute as a string list.
   *
   * @param attributeName The name of the target attribute.
   * @return The string values of the specified attribute, or an empty list if the specified
   *     attribute does not exist in the entry.
   */
  protected final List<String> getStrings(final String attributeName) {
    final String[] valueStrs = entry.getAttributeValues(attributeName);
    if (valueStrs == null) {
      if (debugEnabled(DebugType.MONITOR)) {
        debugMonitor(entry, "No values for string attribute " + attributeName);
      }

      return Collections.emptyList();
    }

    return Collections.unmodifiableList(Arrays.asList(valueStrs));
  }
예제 #3
0
  /**
   * Retrieves the set of parsed monitor attributes for this monitor entry, mapped from a unique
   * identifier (in all lowercase characters) to the corresponding monitor attribute.
   *
   * @return The set of parsed monitor attributes for this monitor entry.
   */
  public Map<String, MonitorAttribute> getMonitorAttributes() {
    // Retrieve a map of all attributes in the entry except cn and objectClass.
    final LinkedHashMap<String, MonitorAttribute> attrs =
        new LinkedHashMap<String, MonitorAttribute>();

    for (final Attribute a : entry.getAttributes()) {
      final String lowerName = toLowerCase(a.getName());
      if (lowerName.equals("cn") || lowerName.equals("objectclass")) {
        continue;
      }

      attrs.put(lowerName, new MonitorAttribute(lowerName, a.getName(), "", a.getValues()));
    }

    return Collections.unmodifiableMap(attrs);
  }
예제 #4
0
  /**
   * Appends a string representation of this monitor entry to the provided buffer.
   *
   * @param buffer The buffer to which the information should be appended.
   */
  public final void toString(final StringBuilder buffer) {
    buffer.append("MonitorEntry(dn='");
    buffer.append(entry.getDN());
    buffer.append("', monitorClass='");
    buffer.append(monitorClass);
    buffer.append('\'');

    final Iterator<MonitorAttribute> iterator = getMonitorAttributes().values().iterator();
    while (iterator.hasNext()) {
      buffer.append(iterator.next());
      if (iterator.hasNext()) {
        buffer.append(", ");
      }
    }

    buffer.append(')');
  }
예제 #5
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;
    }
  }
예제 #6
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;
      }
    }
  }
예제 #7
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;
      }
    }
  }
예제 #8
0
 /**
  * Retrieves the DN for this monitor entry.
  *
  * @return The DN for this monitor entry.
  */
 public final String getDN() {
   return entry.getDN();
 }