001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2010 Sun Microsystems, Inc. 025 * Portions copyright 2012 ForgeRock AS. 026 */ 027package org.forgerock.opendj.ldap.responses; 028 029import java.util.List; 030 031import org.forgerock.opendj.ldap.DecodeException; 032import org.forgerock.opendj.ldap.DecodeOptions; 033import org.forgerock.opendj.ldap.ResultCode; 034import org.forgerock.opendj.ldap.controls.Control; 035import org.forgerock.opendj.ldap.controls.ControlDecoder; 036 037/** 038 * An Compare result indicates the final status of an Compare operation. 039 * <p> 040 * If the attribute value assertion in the Compare request matched a value of 041 * the attribute or sub-type according to the attribute's equality matching rule 042 * then the result code is set to {@link ResultCode#COMPARE_TRUE} and can be 043 * determined by invoking the {@link #matched} method. 044 * <p> 045 * The following excerpt shows how to use the Compare operation to check whether 046 * a member belongs to a (possibly large) static group. 047 * 048 * <pre> 049 * Connection connection = ...; 050 * String groupDN = ...; 051 * String memberDN = ...; 052 * 053 * CompareRequest request = 054 * Requests.newCompareRequest(groupDN, "member", memberDN); 055 * CompareResult result = connection.compare(request); 056 * if (result.matched()) { 057 * // The member belongs to the group. 058 * } 059 * </pre> 060 */ 061public interface CompareResult extends Result { 062 063 @Override 064 CompareResult addControl(Control control); 065 066 @Override 067 CompareResult addReferralURI(String uri); 068 069 @Override 070 Throwable getCause(); 071 072 @Override 073 <C extends Control> C getControl(ControlDecoder<C> decoder, DecodeOptions options) 074 throws DecodeException; 075 076 @Override 077 List<Control> getControls(); 078 079 @Override 080 String getDiagnosticMessage(); 081 082 @Override 083 String getMatchedDN(); 084 085 @Override 086 List<String> getReferralURIs(); 087 088 @Override 089 ResultCode getResultCode(); 090 091 @Override 092 boolean isReferral(); 093 094 @Override 095 boolean isSuccess(); 096 097 /** 098 * Indicates whether or not the attribute value assertion in the Compare 099 * request matched a value of the attribute or sub-type according to the 100 * attribute's equality matching rule. 101 * <p> 102 * Specifically, this method returns {@code true} if the result code is 103 * equal to {@link ResultCode#COMPARE_TRUE}. 104 * 105 * @return {@code true} if the attribute value assertion matched, otherwise 106 * {@code false}. 107 */ 108 boolean matched(); 109 110 @Override 111 CompareResult setCause(Throwable cause); 112 113 @Override 114 CompareResult setDiagnosticMessage(String message); 115 116 @Override 117 CompareResult setMatchedDN(String dn); 118 119 @Override 120 CompareResult setResultCode(ResultCode resultCode); 121 122}