View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     https://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  package org.apache.directory.api.ldap.codec.api;
21  
22  
23  import org.apache.directory.api.asn1.DecoderException;
24  import org.apache.directory.api.asn1.util.Asn1Buffer;
25  import org.apache.directory.api.ldap.model.message.ExtendedRequest;
26  import org.apache.directory.api.ldap.model.message.ExtendedResponse;
27  
28  
29  /**
30   * The factory interface, defined by the codec API, for creating new 
31   * requests/responses for extended operations.
32   *
33   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
34   * @version $Rev$, $Date$
35   */
36  public interface ExtendedOperationFactory
37  {
38      /**
39       * Gets the OID of the extended requests this factory generates.
40       *
41       * @return the extended request OID
42       */
43      String getOid();
44  
45  
46      /**
47       * Returns a new {@link ExtendedRequest} with no value
48       * 
49       * @return the decorator for the extended request type
50       */
51      ExtendedRequest newRequest();
52  
53  
54      /**
55       * Returns a new {@link ExtendedRequest} with the following encoded value.
56       * 
57       * @param value the encoded value
58       * @return the decorator for the extended request type
59       * @throws DecoderException If we can't decode the response
60       */
61      ExtendedRequest newRequest( byte[] value ) throws DecoderException;
62  
63  
64      /**
65       * Creates a new ExtendedResponse, for the ExtendedRequest with no value
66       * 
67       * @return The new ExtendedResponse.
68       * @throws DecoderException If the response cannot be decoded
69       */
70      ExtendedResponse newResponse() throws DecoderException;
71  
72  
73      /**
74       * Creates a new ExtendedResponse, for the ExtendedRequest with a specific
75       * encoded value.
76       * 
77       * @param encodedValue The encoded value for the ExtendedResponse instance.
78       * @return The new ExtendedResponse.
79       * @throws DecoderException If we can't decode the response
80       */
81      ExtendedResponse newResponse( byte[] encodedValue ) throws DecoderException;
82  
83  
84      /**
85       * Encode the value part of the extended request operation.
86       *
87       * @param buffer The buffer into which to put the encoded value
88       * @param extendedRequest The ExtendedRequest Operation to encode
89       */
90      void encodeValue( Asn1Buffer buffer, ExtendedRequest extendedRequest );
91  
92  
93      /**
94       * Decode the value part of the extended request operation.
95       *
96       * @param extendedRequest The ExtendedRequest Operation to feed
97       * @param requestValue The request value to decode
98       * @throws DecoderException If the value cannot be decoded
99       */
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 }