|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.unboundid.ldap.sdk.LDAPRequest
com.unboundid.ldap.sdk.UpdatableLDAPRequest
com.unboundid.ldap.sdk.CompareRequest
@Mutable @ThreadSafety(level=NOT_THREADSAFE) public final class CompareRequest
This class implements the processing necessary to perform an LDAPv3 compare
operation, which may be used to determine whether a specified entry contains
a given attribute value. Compare requests include the DN of the target
entry, the name of the target attribute, and the value for which to make the
determination. It may also include a set of controls to send to the server.
The assertion value may be specified as either a string or a byte array. If
it is specified as a byte array, then it may represent either a binary or a
string value. If a string value is provided as a byte array, then it should
use the UTF-8 encoding for that value.
CompareRequest objects are mutable and therefore can be altered and
re-used for multiple requests. Note, however, that CompareRequest
objects are not threadsafe and therefore a single CompareRequest
object instance should not be used to process multiple requests at the same
time.
CompareRequest compareRequest =
new CompareRequest("dc=example,dc=com", "description", "test");
CompareResult compareResult;
try
{
compareResult = connection.compare(compareRequest);
// The compare operation didn't throw an exception, so we can try to
// determine whether the compare matched.
if (compareResult.compareMatched())
{
// The entry does have a description value of test.
}
else
{
// The entry does not have a description value of test.
}
}
catch (LDAPException le)
{
// The compare operation failed.
compareResult = new CompareResult(le.toLDAPResult());
ResultCode resultCode = le.getResultCode();
String errorMessageFromServer = le.getDiagnosticMessage();
}
| Constructor Summary | |
|---|---|
CompareRequest(DN dn,
java.lang.String attributeName,
ASN1OctetString assertionValue,
Control[] controls)
Creates a new compare request with the provided information. |
|
CompareRequest(DN dn,
java.lang.String attributeName,
byte[] assertionValue)
Creates a new compare request with the provided information. |
|
CompareRequest(DN dn,
java.lang.String attributeName,
byte[] assertionValue,
Control[] controls)
Creates a new compare request with the provided information. |
|
CompareRequest(DN dn,
java.lang.String attributeName,
java.lang.String assertionValue)
Creates a new compare request with the provided information. |
|
CompareRequest(DN dn,
java.lang.String attributeName,
java.lang.String assertionValue,
Control[] controls)
Creates a new compare request with the provided information. |
|
CompareRequest(java.lang.String dn,
java.lang.String attributeName,
byte[] assertionValue)
Creates a new compare request with the provided information. |
|
CompareRequest(java.lang.String dn,
java.lang.String attributeName,
byte[] assertionValue,
Control[] controls)
Creates a new compare request with the provided information. |
|
CompareRequest(java.lang.String dn,
java.lang.String attributeName,
java.lang.String assertionValue)
Creates a new compare request with the provided information. |
|
CompareRequest(java.lang.String dn,
java.lang.String attributeName,
java.lang.String assertionValue,
Control[] controls)
Creates a new compare request with the provided information. |
|
| Method Summary | |
|---|---|
CompareRequest |
duplicate()
Creates a new instance of this LDAP request that may be modified without impacting this request. |
CompareRequest |
duplicate(Control[] controls)
Creates a new instance of this LDAP request that may be modified without impacting this request. |
ASN1Element |
encodeProtocolOp()
Encodes the compare request protocol op to an ASN.1 element. |
java.lang.String |
getAssertionValue()
Retrieves the assertion value to verify within the target entry. |
byte[] |
getAssertionValueBytes()
Retrieves the assertion value to verify within the target entry, formatted as a byte array. |
java.lang.String |
getAttributeName()
Retrieves the name of the attribute for which the comparison is to be performed. |
java.lang.String |
getDN()
Retrieves the DN of the entry in which the comparison is to be performed. |
int |
getLastMessageID()
Retrieves the message ID for the last LDAP message sent using this request. |
OperationType |
getOperationType()
Retrieves the type of operation that is represented by this request. |
byte |
getProtocolOpType()
Retrieves the BER type for this protocol op. |
ASN1OctetString |
getRawAssertionValue()
Retrieves the assertion value to verify within the target entry. |
protected CompareResult |
process(LDAPConnection connection,
int depth)
Sends this delete request to the directory server over the provided connection and returns the associated response. |
void |
responseReceived(LDAPResponse response)
Indicates that the provided LDAP response has been received by from the server. |
void |
setAssertionValue(ASN1OctetString assertionValue)
Specifies the assertion value to specify within the target entry. |
void |
setAssertionValue(byte[] assertionValue)
Specifies the assertion value to specify within the target entry. |
void |
setAssertionValue(java.lang.String assertionValue)
Specifies the assertion value to specify within the target entry. |
void |
setAttributeName(java.lang.String attributeName)
Specifies the name of the attribute for which the comparison is to be performed. |
void |
setDN(DN dn)
Specifies the DN of the entry in which the comparison is to be performed. |
void |
setDN(java.lang.String dn)
Specifies the DN of the entry in which the comparison is to be performed. |
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this request to the provided buffer. |
void |
writeTo(ASN1Buffer buffer)
Writes an ASN.1-encoded representation of this LDAP protocol op to the provided ASN.1 buffer. |
| Methods inherited from class com.unboundid.ldap.sdk.UpdatableLDAPRequest |
|---|
addControl, addControls, clearControls, removeControl, removeControl, replaceControl, replaceControl, setControls, setControls |
| Methods inherited from class com.unboundid.ldap.sdk.LDAPRequest |
|---|
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setResponseTimeoutMillis, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.unboundid.ldap.sdk.ReadOnlyLDAPRequest |
|---|
followReferrals, getControl, getControlList, getResponseTimeoutMillis, hasControl, hasControl, toString |
| Constructor Detail |
|---|
public CompareRequest(java.lang.String dn,
java.lang.String attributeName,
java.lang.String assertionValue)
dn - The DN of the entry in which the comparison is to
be performed. It must not be null.attributeName - The name of the target attribute for which the
comparison is to be performed. It must not be
null.assertionValue - The assertion value to verify within the entry. It
must not be null.
public CompareRequest(java.lang.String dn,
java.lang.String attributeName,
byte[] assertionValue)
dn - The DN of the entry in which the comparison is to
be performed. It must not be null.attributeName - The name of the target attribute for which the
comparison is to be performed. It must not be
null.assertionValue - The assertion value to verify within the entry. It
must not be null.
public CompareRequest(DN dn,
java.lang.String attributeName,
java.lang.String assertionValue)
dn - The DN of the entry in which the comparison is to
be performed. It must not be null.attributeName - The name of the target attribute for which the
comparison is to be performed. It must not be
null.assertionValue - The assertion value to verify within the entry. It
must not be null.
public CompareRequest(DN dn,
java.lang.String attributeName,
byte[] assertionValue)
dn - The DN of the entry in which the comparison is to
be performed. It must not be null.attributeName - The name of the target attribute for which the
comparison is to be performed. It must not be
null.assertionValue - The assertion value to verify within the entry. It
must not be null.
public CompareRequest(java.lang.String dn,
java.lang.String attributeName,
java.lang.String assertionValue,
Control[] controls)
dn - The DN of the entry in which the comparison is to
be performed. It must not be null.attributeName - The name of the target attribute for which the
comparison is to be performed. It must not be
null.assertionValue - The assertion value to verify within the entry. It
must not be null.controls - The set of controls for this compare request.
public CompareRequest(java.lang.String dn,
java.lang.String attributeName,
byte[] assertionValue,
Control[] controls)
dn - The DN of the entry in which the comparison is to
be performed. It must not be null.attributeName - The name of the target attribute for which the
comparison is to be performed. It must not be
null.assertionValue - The assertion value to verify within the entry. It
must not be null.controls - The set of controls for this compare request.
public CompareRequest(DN dn,
java.lang.String attributeName,
java.lang.String assertionValue,
Control[] controls)
dn - The DN of the entry in which the comparison is to
be performed. It must not be null.attributeName - The name of the target attribute for which the
comparison is to be performed. It must not be
null.assertionValue - The assertion value to verify within the entry. It
must not be null.controls - The set of controls for this compare request.
public CompareRequest(DN dn,
java.lang.String attributeName,
ASN1OctetString assertionValue,
Control[] controls)
dn - The DN of the entry in which the comparison is to
be performed. It must not be null.attributeName - The name of the target attribute for which the
comparison is to be performed. It must not be
null.assertionValue - The assertion value to verify within the entry. It
must not be null.controls - The set of controls for this compare request.
public CompareRequest(DN dn,
java.lang.String attributeName,
byte[] assertionValue,
Control[] controls)
dn - The DN of the entry in which the comparison is to
be performed. It must not be null.attributeName - The name of the target attribute for which the
comparison is to be performed. It must not be
null.assertionValue - The assertion value to verify within the entry. It
must not be null.controls - The set of controls for this compare request.| Method Detail |
|---|
public java.lang.String getDN()
getDN in interface ReadOnlyCompareRequestpublic void setDN(java.lang.String dn)
dn - The DN of the entry in which the comparison is to be performed.
It must not be null.public void setDN(DN dn)
dn - The DN of the entry in which the comparison is to be performed.
It must not be null.public java.lang.String getAttributeName()
getAttributeName in interface ReadOnlyCompareRequestpublic void setAttributeName(java.lang.String attributeName)
attributeName - The name of the attribute for which the comparison
is to be performed. It must not be null.public java.lang.String getAssertionValue()
getAssertionValue in interface ReadOnlyCompareRequestpublic byte[] getAssertionValueBytes()
getAssertionValueBytes in interface ReadOnlyCompareRequestpublic ASN1OctetString getRawAssertionValue()
getRawAssertionValue in interface ReadOnlyCompareRequestpublic void setAssertionValue(java.lang.String assertionValue)
assertionValue - The assertion value to specify within the target
entry. It must not be null.public void setAssertionValue(byte[] assertionValue)
assertionValue - The assertion value to specify within the target
entry. It must not be null.public void setAssertionValue(ASN1OctetString assertionValue)
assertionValue - The assertion value to specify within the target
entry. It must not be null.public byte getProtocolOpType()
getProtocolOpType in interface ProtocolOppublic void writeTo(ASN1Buffer buffer)
writeTo in interface ProtocolOpbuffer - The ASN.1 buffer to which the encoded representation should
be written.public ASN1Element encodeProtocolOp()
encodeProtocolOp in interface ProtocolOp
protected CompareResult process(LDAPConnection connection,
int depth)
throws LDAPException
process in class LDAPRequestconnection - The connection to use to communicate with the directory
server.depth - The current referral depth for this request. It should
always be one for the initial request, and should only
be incremented when following referrals.
LDAPException - If a problem occurs while sending the request or
reading the response.
@InternalUseOnly
public void responseReceived(LDAPResponse response)
throws LDAPException
response - The LDAP response that has been received from the server.
It may be null if the connection has been closed
without having received any response.
LDAPException - If a problem occurs while handling the response.public int getLastMessageID()
getLastMessageID in class LDAPRequestpublic OperationType getOperationType()
getOperationType in class LDAPRequestpublic CompareRequest duplicate()
duplicate in interface ReadOnlyCompareRequestduplicate in interface ReadOnlyLDAPRequestpublic CompareRequest duplicate(Control[] controls)
duplicate in interface ReadOnlyCompareRequestduplicate in interface ReadOnlyLDAPRequestcontrols - The set of controls to include in the duplicate request.
public void toString(java.lang.StringBuilder buffer)
toString in interface ProtocolOptoString in interface ReadOnlyLDAPRequesttoString in class LDAPRequestbuffer - The buffer to which to append a string representation of
this request.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||