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.shared.ldap.codec.api; 021 022 023import org.apache.directory.shared.asn1.DecoderException; 024import org.apache.directory.shared.ldap.model.message.ExtendedRequest; 025import org.apache.directory.shared.ldap.model.message.ExtendedResponse; 026 027 028/** 029 * The factor interface, defined by the codec API for creating new 030 * ExtendedRequests. 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 * @version $Rev$, $Date$ 034 */ 035public interface ExtendedRequestFactory<Q extends ExtendedRequest<P>,P extends ExtendedResponse> 036{ 037 /** 038 * Gets the OID of the extended requests this factory generates. 039 * 040 * @return the extended request OID 041 */ 042 String getOid(); 043 044 045 /** 046 * @return A new instance of the {@link ExtendedRequestDecorator}. 047 */ 048 Q newRequest(); 049 050 051 /** 052 * Returns a new {@link ExtendedRequestDecorator} with the following encoded value. 053 * 054 * @param value the encoded value 055 * @return the decorator for the extended request type 056 */ 057 Q newRequest( byte[] value ); 058 059 060 /** 061 * Decorates a non-decorated request. 062 * 063 * @param modelRequest the non decorated model request 064 * @return the decorated model request 065 */ 066 ExtendedRequestDecorator<Q, P> decorate( ExtendedRequest<?> modelRequest ); 067 068 069 /** 070 * Creates a new ExtendedResponse, for the ExtendedRequest with a specific 071 * encoded value. 072 * 073 * @param encodedValue The encoded value for the ExtendedResponse instance. 074 * @return The new ExtendedResponse. 075 */ 076 P newResponse( byte[] encodedValue ) throws DecoderException; 077 078 079 /** 080 * Decorates an ExtendedResponse which may or may not be of the expected 081 * type. The factory implementor must check and handle appropriately. 082 * 083 * @param decoratedMessage the message to be decorated. 084 * @return The decorated message 085 */ 086 ExtendedResponseDecorator<P> decorate( ExtendedResponse decoratedMessage ); 087}