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 * https://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.extended.ads_impl.endTransaction.controls; 021 022import java.util.ArrayList; 023import java.util.List; 024 025import org.apache.directory.api.asn1.ber.AbstractContainer; 026import org.apache.directory.api.ldap.codec.api.ControlFactory; 027import org.apache.directory.api.ldap.codec.api.LdapApiService; 028import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory; 029import org.apache.directory.api.ldap.model.message.Control; 030 031/** 032 * A container storing decoded controls for a EndTransactionResponse extended operation 033 * 034 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 035 */ 036public class ControlsContainer extends AbstractContainer 037{ 038 /** The list of decoded controls */ 039 private List<Control> controls = new ArrayList<>(); 040 041 /** The current control */ 042 private Control currentControl; 043 044 /** The control factory */ 045 private ControlFactory<?> factory; 046 047 /** The codec service */ 048 private final LdapApiService codec; 049 050 /** 051 * A constructor for this container 052 */ 053 public ControlsContainer() 054 { 055 super(); 056 setGrammar( ControlsGrammar.getInstance() ); 057 setTransition( ControlsStates.START_STATE ); 058 this.codec = LdapApiServiceFactory.getSingleton(); 059 } 060 061 062 /** 063 * Gets the {@link LdapApiService} associated with this Container. 064 * 065 * @return The LDAP service instance 066 */ 067 public LdapApiService getLdapCodecService() 068 { 069 return codec; 070 } 071 072 073 /** 074 * @return the currentControl 075 */ 076 public Control getCurrentControl() 077 { 078 return currentControl; 079 } 080 081 082 /** 083 * @param currentControl the currentControl to set 084 */ 085 public void setCurrentControl( Control currentControl ) 086 { 087 this.currentControl = currentControl; 088 } 089 090 091 /** 092 * @return the controls 093 */ 094 public List<Control> getControls() 095 { 096 return controls; 097 } 098 099 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}