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.Control; 26 27 28 /** 29 * Implementors of new codec control extensions must implement a factory using 30 * this factory interface, Factory implementations for specific controls are 31 * then registered with the codec and used by the codec to encode and decode 32 * those controls. 33 * 34 * @param <C> The Control to create 35 * 36 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 37 */ 38 public interface ControlFactory<C extends Control> 39 { 40 /** 41 * @return The OID of the Control this factory creates. 42 */ 43 String getOid(); 44 45 46 /** 47 * Creates and returns a version of the Control. 48 * 49 * @return The {@link CodecControl} decorated version of the Control. 50 */ 51 Control newControl(); 52 53 54 /** 55 * Encode the value part of the control. 56 * 57 * @param buffer The buffer into which to put the encoded value 58 * @param control The control to encode 59 */ 60 void encodeValue( Asn1Buffer buffer, Control control ); 61 62 63 64 65 /** 66 * Decode a Control's value. It will feed the Control. 67 * 68 * @param container The Asn1Container containing the control to feed 69 * @param control The control to feed 70 * @param controlBytes The data to decode 71 * @throws DecoderException If the value can't be decoded 72 */ 73 void decodeValue( ControlContainer container, Control control, byte[] controlBytes ) throws DecoderException; 74 75 76 /** 77 * Decode a Control's value. It will feed the Control. 78 * 79 * @param control The control to feed 80 * @param controlBytes The data to decode 81 * @throws DecoderException If the value can't be decoded 82 */ 83 void decodeValue( Control control, byte[] controlBytes ) throws DecoderException; 84 }