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.controls.search.subentries;
021
022
023import org.apache.directory.shared.asn1.ber.AbstractContainer;
024
025
026/**
027 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
028 */
029public class SubentriesContainer extends AbstractContainer
030{
031    /** PSearchControl */
032    private SubentriesDecorator decorator;
033
034
035    /**
036     * Creates a new SubEntryControlContainer object.
037     */
038    public SubentriesContainer()
039    {
040        super();
041        stateStack = new int[1];
042        grammar = SubentriesGrammar.getInstance();
043        setTransition( SubentriesStates.START_STATE );
044    }
045
046
047    /**
048     * Creates a new SubEntryControlContainer object, pre-populating it with the
049     * supplied Subentries control, and optionally wrapping it with a decorator
050     * if it is not a decorator instance.
051     *
052     * @param control The Subentries Control to decorate and add to this
053     * container, or if the Control already is a ControlDecorator it is directly
054     * added.
055     */
056    public SubentriesContainer( SubentriesDecorator control )
057    {
058        this();
059        this.decorator = control;
060    }
061
062
063    /**
064     * @return Returns the persistent search control.
065     */
066    public SubentriesDecorator getSubentriesControl()
067    {
068        return decorator;
069    }
070
071
072    /**
073     * Set a SubEntryControl Object into the container. It will be completed by
074     * the ldapDecoder.
075     * 
076     * @param decorator the SubEntryControl to set.
077     */
078    public void setSubentriesDecorator( SubentriesDecorator decorator )
079    {
080        this.decorator = decorator;
081    }
082
083
084    /**
085     * Clean the current container
086     */
087    public void clean()
088    {
089        super.clean();
090        decorator = null;
091    }
092}