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.ExtendedRequest; 026import org.apache.directory.api.ldap.model.message.ExtendedResponse; 027 028 029/** 030 * The factory interface, defined by the codec API, for creating new 031 * requests/responses for extended operations. 032 * 033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 034 * @version $Rev$, $Date$ 035 */ 036public interface ExtendedOperationFactory 037{ 038 /** 039 * Gets the OID of the extended requests this factory generates. 040 * 041 * @return the extended request OID 042 */ 043 String getOid(); 044 045 046 /** 047 * Returns a new {@link ExtendedRequest} with no value 048 * 049 * @return the decorator for the extended request type 050 */ 051 ExtendedRequest newRequest(); 052 053 054 /** 055 * Returns a new {@link ExtendedRequest} with the following encoded value. 056 * 057 * @param value the encoded value 058 * @return the decorator for the extended request type 059 * @throws DecoderException If we can't decode the response 060 */ 061 ExtendedRequest newRequest( byte[] value ) throws DecoderException; 062 063 064 /** 065 * Creates a new ExtendedResponse, for the ExtendedRequest with no value 066 * 067 * @return The new ExtendedResponse. 068 * @throws DecoderException If the response cannot be decoded 069 */ 070 ExtendedResponse newResponse() throws DecoderException; 071 072 073 /** 074 * Creates a new ExtendedResponse, for the ExtendedRequest with a specific 075 * encoded value. 076 * 077 * @param encodedValue The encoded value for the ExtendedResponse instance. 078 * @return The new ExtendedResponse. 079 * @throws DecoderException If we can't decode the response 080 */ 081 ExtendedResponse newResponse( byte[] encodedValue ) throws DecoderException; 082 083 084 /** 085 * Encode the value part of the extended request operation. 086 * 087 * @param buffer The buffer into which to put the encoded value 088 * @param extendedRequest The ExtendedRequest Operation to encode 089 */ 090 void encodeValue( Asn1Buffer buffer, ExtendedRequest extendedRequest ); 091 092 093 /** 094 * Decode the value part of the extended request operation. 095 * 096 * @param extendedRequest The ExtendedRequest Operation to feed 097 * @param requestValue The request value to decode 098 * @throws DecoderException If the value cannot be decoded 099 */ 100 void decodeValue( ExtendedRequest extendedRequest, byte[] requestValue ) throws DecoderException; 101 102 103 /** 104 * Encode the value part of the extended response operation. 105 * 106 * @param buffer The buffer into which to put the encoded value 107 * @param extendedResponse The ExtendedResponse Operation to encode 108 */ 109 void encodeValue( Asn1Buffer buffer, ExtendedResponse extendedResponse ); 110 111 112 /** 113 * Decode the value part of the extended response operation. 114 * 115 * @param extendedResponse The ExtendedResponse Operation to feed 116 * @param responseValue The response value to decode 117 * @throws DecoderException If the value cannot be decoded 118 */ 119 void decodeValue( ExtendedResponse extendedResponse, byte[] responseValue ) throws DecoderException; 120}