Search in sources :

Example 1 with MatchingEntryCountResponseControl

use of com.unboundid.ldap.sdk.unboundidds.controls.MatchingEntryCountResponseControl in project ldapsdk by pingidentity.

the class ResultUtils method addMatchingEntryCountResponseControl.

/**
 * Adds a multi-line string representation of the provided control, which is
 * expected to be a matching entry count response control, to the given list.
 *
 * @param  lines     The list to which the lines should be added.
 * @param  c         The control to be formatted.
 * @param  prefix    The prefix to use for each line.
 * @param  maxWidth  The maximum length of each line in characters, including
 *                   the comment prefix and indent.
 */
private static void addMatchingEntryCountResponseControl(@NotNull final List<String> lines, @NotNull final Control c, @NotNull final String prefix, final int maxWidth) {
    final MatchingEntryCountResponseControl decoded;
    try {
        decoded = new MatchingEntryCountResponseControl(c.getOID(), c.isCritical(), c.getValue());
    } catch (final Exception e) {
        Debug.debugException(e);
        addGenericResponseControl(lines, c, prefix, maxWidth);
        return;
    }
    wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_HEADER.get(), prefix, maxWidth);
    final String indentPrefix = prefix + "     ";
    wrap(lines, INFO_RESULT_UTILS_RESPONSE_CONTROL_OID.get(c.getOID()), indentPrefix, maxWidth);
    switch(decoded.getCountType()) {
        case EXAMINED_COUNT:
            wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_TYPE_EXAMINED.get(), indentPrefix, maxWidth);
            wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_VALUE.get(decoded.getCountValue()), indentPrefix, maxWidth);
            break;
        case UNEXAMINED_COUNT:
            wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_TYPE_UNEXAMINED.get(), indentPrefix, maxWidth);
            wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_VALUE.get(decoded.getCountValue()), indentPrefix, maxWidth);
            break;
        case UPPER_BOUND:
            wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_TYPE_UPPER_BOUND.get(), indentPrefix, maxWidth);
            wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_VALUE.get(decoded.getCountValue()), indentPrefix, maxWidth);
            break;
        case UNKNOWN:
        default:
            wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_TYPE_UNKNOWN.get(), indentPrefix, maxWidth);
            break;
    }
    wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_INDEXED.get(decoded.searchIndexed()), indentPrefix, maxWidth);
    final Boolean shortCircuited = decoded.getShortCircuited();
    if (shortCircuited != null) {
        wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_SHORT_CIRCUITED.get(String.valueOf(shortCircuited)), indentPrefix, maxWidth);
    }
    final Boolean fullyIndexed = decoded.getFullyIndexed();
    if (fullyIndexed != null) {
        wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_FULLY_INDEXED.get(String.valueOf(fullyIndexed)), indentPrefix, maxWidth);
    }
    final Boolean candidatesAreInScope = decoded.getCandidatesAreInScope();
    if (candidatesAreInScope != null) {
        wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_CANDIDATES_IN_SCOPE.get(String.valueOf(candidatesAreInScope)), indentPrefix, maxWidth);
    }
    final Filter remainingFilter = decoded.getRemainingFilter();
    if (remainingFilter != null) {
        wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_REMAINING_FILTER.get(String.valueOf(remainingFilter)), indentPrefix, maxWidth);
    }
    final List<String> debugInfo = decoded.getDebugInfo();
    if ((debugInfo != null) && (!debugInfo.isEmpty())) {
        wrap(lines, INFO_RESULT_UTILS_MATCHING_ENTRY_COUNT_DEBUG_HEADER.get(), indentPrefix, maxWidth);
        for (final String s : debugInfo) {
            wrap(lines, s, indentPrefix + "     ", maxWidth);
        }
    }
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) LDAPException(com.unboundid.ldap.sdk.LDAPException) MatchingEntryCountResponseControl(com.unboundid.ldap.sdk.unboundidds.controls.MatchingEntryCountResponseControl)

Aggregations

ASN1OctetString (com.unboundid.asn1.ASN1OctetString)1 Filter (com.unboundid.ldap.sdk.Filter)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1 MatchingEntryCountResponseControl (com.unboundid.ldap.sdk.unboundidds.controls.MatchingEntryCountResponseControl)1