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   *    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.extras.extended.ads_impl.endTransaction.controls;
21  
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  import org.apache.directory.api.asn1.ber.AbstractContainer;
26  import org.apache.directory.api.ldap.codec.api.ControlFactory;
27  import org.apache.directory.api.ldap.codec.api.LdapApiService;
28  import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory;
29  import org.apache.directory.api.ldap.model.message.Control;
30  
31  /**
32   * A container storing decoded controls for a EndTransactionResponse extended operation
33   *  
34   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
35   */
36  public class ControlsContainer extends AbstractContainer
37  {
38      /** The list of decoded controls */
39      private List<Control> controls = new ArrayList<>();
40      
41      /** The current control */
42      private Control currentControl;
43      
44      /** The control factory */
45      private ControlFactory<?> factory;
46  
47      /** The codec service */
48      private final LdapApiService codec;
49  
50      /**
51       * A constructor for this container
52       */
53      public ControlsContainer()
54      {
55          super();
56          setGrammar( ControlsGrammar.getInstance() );
57          setTransition( ControlsStates.START_STATE );
58          this.codec = LdapApiServiceFactory.getSingleton();
59      }
60  
61  
62      /**
63       * Gets the {@link LdapApiService} associated with this Container.
64       *
65       * @return The LDAP service instance
66       */
67      public LdapApiService getLdapCodecService()
68      {
69          return codec;
70      }
71  
72      
73      /**
74       * @return the currentControl
75       */
76      public Control getCurrentControl()
77      {
78          return currentControl;
79      }
80  
81  
82      /**
83       * @param currentControl the currentControl to set
84       */
85      public void setCurrentControl( Control currentControl )
86      {
87          this.currentControl = currentControl;
88      }
89  
90  
91      /**
92       * @return the controls
93       */
94      public List<Control> getControls()
95      {
96          return controls;
97      }
98      
99  
100     /**
101      * @param control the controls to add to the list of controls
102      */
103     public void addControl( Control control )
104     {
105         controls.add( control );
106     }
107 
108 
109     /**
110      * @return the factory
111      */
112     public ControlFactory<?> getFactory()
113     {
114         return factory;
115     }
116 
117 
118     /**
119      * @param factory the factory to set
120      */
121     public void setFactory( ControlFactory<?> factory )
122     {
123         this.factory = factory;
124     }
125 }