001/*
002 *   Licensed to the Apache Software Foundation (ASF) under one
003 *   or more contributor license agreements.  See the NOTICE file
004 *   distributed with this work for additional information
005 *   regarding copyright ownership.  The ASF licenses this file
006 *   to you under the Apache License, Version 2.0 (the
007 *   "License"); you may not use this file except in compliance
008 *   with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *   Unless required by applicable law or agreed to in writing,
013 *   software distributed under the License is distributed on an
014 *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *   KIND, either express or implied.  See the License for the
016 *   specific language governing permissions and limitations
017 *   under the License.
018 *
019 */
020package org.apache.directory.api.ldap.codec.api;
021
022
023import org.apache.directory.api.asn1.DecoderException;
024import org.apache.directory.api.asn1.util.Asn1Buffer;
025import org.apache.directory.api.ldap.model.message.IntermediateResponse;
026
027
028/**
029 * The factory interface, defined by the codec API, for creating new 
030 * Intermediate responses.
031 *
032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
033 */
034public interface IntermediateOperationFactory
035{
036    /**
037     * Gets the OID of the IntermediateResponse this factory generates.
038     *
039     * @return the extended request OID
040     */
041    String getOid();
042
043
044    /**
045     * Returns a new {@link IntermediateResponse} with no value.
046     * 
047     * @return the extended response type
048     */
049    IntermediateResponse newResponse();
050
051
052    /**
053     * Returns a new {@link IntermediateResponse} with the following encoded value.
054     * 
055     * @param value the encoded value
056     * @return the extended response type
057     */
058    IntermediateResponse newResponse( byte[] value );
059
060
061    /**
062     * Encode the value part of the intermediate response operation.
063     *
064     * @param buffer The buffer into which to put the encoded value
065     * @param intermediateResponse The IntermediateResponse Operation to encode
066     */
067    void encodeValue( Asn1Buffer buffer, IntermediateResponse intermediateResponse );
068
069
070    /**
071     * Decode the value part of the intermediate response operation.
072     *
073     * @param intermediateResponse The IntermediateResponse Operation to feed
074     * @param responseValue The response value to decode
075     * @throws DecoderException If the value cannot be decoded
076     */
077    void decodeValue( IntermediateResponse intermediateResponse, byte[] responseValue ) throws DecoderException;
078}