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 */ 020 021 package org.apache.directory.shared.dsmlv2.reponse; 022 023 024 import java.util.ArrayList; 025 import java.util.List; 026 027 import org.apache.directory.shared.ldap.codec.LdapResponseCodec; 028 029 030 /** 031 * This class represents the Batch Response of a DSML Response 032 * 033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 034 * @version $Rev$, $Date$ 035 */ 036 public class BatchResponse 037 { 038 039 /** 040 * The responses contained in the Batch Response 041 */ 042 private List<LdapResponseCodec> responses; 043 044 /** 045 * The ID of the response 046 */ 047 private int requestID; 048 049 050 /** 051 * Creates a new instance of BatchResponse. 052 */ 053 public BatchResponse() 054 { 055 responses = new ArrayList<LdapResponseCodec>(); 056 } 057 058 059 /** 060 * Adds a reponse 061 * 062 * @param response 063 * the response to add 064 * @return 065 * true (as per the general contract of the Collection.add method) 066 */ 067 public boolean addResponse( LdapResponseCodec response ) 068 { 069 return responses.add( response ); 070 } 071 072 073 /** 074 * Gets the current reponse 075 * 076 * @return 077 * the current response 078 */ 079 public LdapResponseCodec getCurrentResponse() 080 { 081 return responses.get( responses.size() - 1 ); 082 } 083 084 085 /** 086 * Gets the ID of the response 087 * @return 088 * the ID of the response 089 */ 090 public int getRequestID() 091 { 092 return requestID; 093 } 094 095 096 /** 097 * Sets the ID of the response 098 * 099 * @param requestID 100 * the ID to set 101 */ 102 public void setRequestID( int requestID ) 103 { 104 this.requestID = requestID; 105 } 106 107 108 /** 109 * Gets the List of all the reponses 110 * 111 * @return 112 * the List of all the responses 113 */ 114 public List getResponses() 115 { 116 return responses; 117 } 118 }