001    /*
002     * Copyright 2007-2015 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2008-2015 UnboundID Corp.
007     *
008     * This program is free software; you can redistribute it and/or modify
009     * it under the terms of the GNU General Public License (GPLv2 only)
010     * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011     * as published by the Free Software Foundation.
012     *
013     * This program is distributed in the hope that it will be useful,
014     * but WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     * GNU General Public License for more details.
017     *
018     * You should have received a copy of the GNU General Public License
019     * along with this program; if not, see <http://www.gnu.org/licenses>.
020     */
021    package com.unboundid.ldap.sdk;
022    
023    
024    
025    import java.io.Serializable;
026    
027    import com.unboundid.asn1.ASN1OctetString;
028    
029    
030    
031    /**
032     * This interface defines a method that may be implemented by controls that may
033     * be included in the response from a directory server.  The LDAP SDK will
034     * maintain a mapping between response control OIDs and the decodeable control
035     * classes that may be used to attempt to decode them.  If a control cannot be
036     * decoded using this interface and an exception is thrown, then it will be
037     * treated as a generic control.
038     */
039    public interface DecodeableControl
040           extends Serializable
041    {
042      /**
043       * Creates a new instance of this decodeable control from the provided
044       * information.
045       *
046       * @param  oid         The OID for the control.
047       * @param  isCritical  Indicates whether the control should be marked
048       *                     critical.
049       * @param  value       The encoded value for the control.  This may be
050       *                     {@code null} if no value was provided.
051       *
052       * @return  The decoded representation of this control.
053       *
054       * @throws  LDAPException  If the provided information cannot be decoded as a
055       *                         valid instance of this decodeable control.
056       */
057      Control decodeControl(final String oid, final boolean isCritical,
058                            final ASN1OctetString value)
059              throws LDAPException;
060    }