/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.harmony.jndi.provider.ldap;
import org.apache.harmony.jndi.internal.parser.AttributeTypeAndValuePair;
import org.apache.harmony.jndi.provider.ldap.asn1.ASN1Decodable;
import org.apache.harmony.jndi.provider.ldap.asn1.ASN1Encodable;
import org.apache.harmony.jndi.provider.ldap.asn1.LdapASN1Constant;
import org.apache.harmony.jndi.provider.ldap.asn1.Utils;
public class CompareOp implements LdapOperation, ASN1Encodable {
private String entry;
private AttributeTypeAndValuePair ava;
public CompareOp(String entry, AttributeTypeAndValuePair pair) {
this.entry = entry;
this.ava = pair;
}
private LdapResult result;
public ASN1Encodable getRequest() {
return this;
}
public int getRequestId() {
return LdapASN1Constant.OP_COMPARE_REQUEST;
}
public ASN1Decodable getResponse() {
return result = (result == null) ? new LdapResult() : result;
}
public int getResponseId() {
return LdapASN1Constant.OP_COMPARE_RESPONSE;
}
public void encodeValues(Object[] values) {
values[0] = Utils.getBytes(entry);
Object[] objs = new Object[2];
objs[0] = Utils.getBytes(ava.getType());
objs[1] = ava.getValue();
// FIXME: convert according to schema
values[1] = objs;
}
public LdapResult getResult() {
return result;
}
}