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   *    http://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.extras.controls.ad_impl;
21  
22  
23  import org.apache.directory.api.asn1.ber.AbstractContainer;
24  import org.apache.directory.api.ldap.codec.api.LdapApiService;
25  import org.apache.directory.api.ldap.extras.controls.ad.AdDirSync;
26  
27  
28  /**
29   * 
30   * ASN.1 container for AD DirSync control.
31   *
32   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33   */
34  public class AdDirSyncContainer extends AbstractContainer
35  {
36      /** adDirSync */
37      private AdDirSync control;
38  
39      private LdapApiService codec;
40  
41  
42      /**
43       * Creates a new AdDirSyncControl Container object.
44       *
45       * @param codec The LDAP Service to use
46       */
47      public AdDirSyncContainer( LdapApiService codec )
48      {
49          super();
50          this.codec = codec;
51          this.control = new AdDirSyncDecorator( codec );
52          setGrammar( AdDirSyncGrammar.getInstance() );
53          setTransition( AdDirSyncStatesEnum.START_STATE );
54      }
55  
56  
57      /**
58       * Creates a new AdDirSyncControl object.
59       *
60       * @param codec The LDAP Service to use
61       * @param control The AdDirSync control to decorate
62       */
63      public AdDirSyncContainer( LdapApiService codec, AdDirSync control )
64      {
65          super();
66          this.codec = codec;
67          this.control = control;
68          setGrammar( AdDirSyncGrammar.getInstance() );
69          setTransition( AdDirSyncStatesEnum.START_STATE );
70      }
71  
72  
73      /**
74       * @return the AdDirSyncControlCodec object
75       */
76      public AdDirSync getAdDirSyncControl()
77      {
78          return control;
79      }
80  
81  
82      /**
83       * Set a AdDirSyncControlCodec Object into the container. It will be completed
84       * by the ldapDecoder.
85       * 
86       * @param control the AdDirSyncControlCodec to set.
87       */
88      public void setAdDirSyncControl( AdDirSync control )
89      {
90          this.control = control;
91      }
92  
93  
94      /**
95       * @return The LdapAPi service instance
96       */
97      public LdapApiService getCodecService()
98      {
99          return codec;
100     }
101 
102 
103     /**
104      * clean the container
105      */
106     @Override
107     public void clean()
108     {
109         super.clean();
110         control = null;
111     }
112 }