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.codec.controls.sort;
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.model.message.controls.SortResponse;
26  
27  
28  /**
29   * Container for SortResponseControl.
30   *
31   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
32   */
33  public class SortResponseContainer extends AbstractContainer
34  {
35      /** the decorator instance of sort response control */
36      private SortResponseDecorator control;
37  
38      /** LDAP codec */
39      private LdapApiService codec;
40  
41      /**
42       * Creates a new instance of SortResponseContainer.
43       *
44       * @param codec the LDAP codec
45       */
46      public SortResponseContainer( LdapApiService codec )
47      {
48          super();
49          this.codec = codec;
50          grammar = SortResponseGrammar.getInstance();
51          setTransition( SortResponseStates.START_STATE );
52      }
53  
54  
55      /**
56       * Creates a new instance of SortResponseContainer.
57       *
58       * @param codec the LDAP codec
59       * @param control the sort response control
60       */
61      public SortResponseContainer( LdapApiService codec, SortResponse control )
62      {
63          this( codec );
64          decorate( control );
65      }
66  
67  
68      /**
69       * {@inheritDoc} 
70       */
71      public void decorate( SortResponse control )
72      {
73          if ( control instanceof SortResponseDecorator )
74          {
75              this.control = ( SortResponseDecorator ) control;
76          }
77          else
78          {
79              this.control = new SortResponseDecorator( codec, control );
80          }
81      }
82  
83  
84      /**
85       * @return the control
86       */
87      public SortResponseDecorator getControl()
88      {
89          return control;
90      }
91  
92  
93      /**
94       * @param control the control to set
95       */
96      public void setControl( SortResponseDecorator control )
97      {
98          this.control = control;
99      }
100 
101 
102     /**
103      * Clean the container
104      */
105     public void clean()
106     {
107         super.clean();
108         control = null;
109     }
110 
111 }