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.api.ldap.extras.controls.ad;
021
022
023import org.apache.directory.api.asn1.ber.AbstractContainer;
024import org.apache.directory.api.ldap.codec.api.LdapApiService;
025
026
027/**
028 * 
029 * ASN.1 container for AD DirSync control.
030 *
031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032 */
033public class AdDirSyncContainer extends AbstractContainer
034{
035    /** adDirSync */
036    private AdDirSync control;
037
038    private LdapApiService codec;
039
040
041    /**
042     * 
043     * Creates a new AdDirSyncControl Container object.
044     *
045     */
046    public AdDirSyncContainer( LdapApiService codec )
047    {
048        super();
049        this.codec = codec;
050        this.control = new AdDirSyncDecorator( codec );
051        grammar = AdDirSyncGrammar.getInstance();
052        setTransition( AdDirSyncStatesEnum.START_STATE );
053    }
054
055
056    /**
057     * 
058     * Creates a new AdDirSyncControl object.
059     *
060     */
061    public AdDirSyncContainer( LdapApiService codec, AdDirSync control )
062    {
063        super();
064        this.codec = codec;
065        this.control = control;
066        grammar = AdDirSyncGrammar.getInstance();
067        setTransition( AdDirSyncStatesEnum.START_STATE );
068    }
069
070
071    /**
072     * @return the AdDirSyncControlCodec object
073     */
074    public AdDirSync getAdDirSyncControl()
075    {
076        return control;
077    }
078
079
080    /**
081     * Set a AdDirSyncControlCodec Object into the container. It will be completed
082     * by the ldapDecoder.
083     * 
084     * @param control the AdDirSyncControlCodec to set.
085     */
086    public void setAdDirSyncControl( AdDirSync control )
087    {
088        this.control = control;
089    }
090
091
092    public LdapApiService getCodecService()
093    {
094        return codec;
095    }
096
097
098    /**
099     * clean the container
100     */
101    @Override
102    public void clean()
103    {
104        super.clean();
105        control = null;
106    }
107}