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.codec.controls.sort;
021
022
023import org.apache.directory.api.asn1.ber.AbstractContainer;
024import org.apache.directory.api.ldap.codec.api.ControlContainer;
025import org.apache.directory.api.ldap.model.message.Control;
026import org.apache.directory.api.ldap.model.message.controls.SortKey;
027import org.apache.directory.api.ldap.model.message.controls.SortRequest;
028
029
030/**
031 * Container for SortRequestControl.
032 *
033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
034 */
035public class SortRequestContainer extends AbstractContainer implements ControlContainer
036{
037    /** the sort request control decorator */
038    private Control control;
039
040    /** current key that is being decoded */
041    private SortKey currentKey;
042
043    /**
044     * Creates a new instance of SortRequestContainer.
045     *
046     * @param control the sort request control
047     */
048    public SortRequestContainer( Control control )
049    {
050        super();
051        setGrammar( SortRequestGrammar.getInstance() );
052        setTransition( SortRequestStates.START_STATE );
053        this.control = control;
054    }
055
056
057    /**
058     * @return the control
059     */
060    public SortRequest getControl()
061    {
062        return ( SortRequest ) control;
063    }
064
065
066    /**
067     * @param control the control to set
068     */
069    public void setControl( Control
070        control )
071    {
072        this.control = control;
073    }
074
075
076    /**
077     * Clean the container
078     */
079    @Override
080    public void clean()
081    {
082        super.clean();
083        control = null;
084    }
085
086
087    /**
088     * @return the currentKey
089     */
090    public SortKey getCurrentKey()
091    {
092        return currentKey;
093    }
094
095
096    /**
097     * @param currentKey the currentKey to set
098     */
099    public void setCurrentKey( SortKey currentKey )
100    {
101        this.currentKey = currentKey;
102    }
103}