01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.directwebremoting.extend;
17:
18: import java.util.ArrayList;
19: import java.util.Iterator;
20: import java.util.List;
21:
22: /**
23: * The request made by the browser which consists of a number of function call
24: * requests and some associated information like the request mode (XHR or
25: * iframe).
26: * @author Joe Walker [joe at getahead dot ltd dot uk]
27: */
28: public class Replies implements Iterable<Reply> {
29: /**
30: * @param batchId The batchId to set.
31: */
32: public Replies(String batchId) {
33: this .batchId = batchId;
34: }
35:
36: /**
37: * How many replies are there is this request
38: * @return The total number of replies
39: */
40: public int getReplyCount() {
41: return replies.size();
42: }
43:
44: /**
45: * @param index The index (starts at 0) of the reply to fetch
46: * @return Returns the replies.
47: */
48: public Reply getReply(int index) {
49: return replies.get(index);
50: }
51:
52: /**
53: * Add a reply to the collection of replies we are about to make
54: * @param reply The reply to add
55: */
56: public void addReply(Reply reply) {
57: replies.add(reply);
58: }
59:
60: /**
61: * @param batchId The batchId to set.
62: */
63: public void setBatchId(String batchId) {
64: this .batchId = batchId;
65: }
66:
67: /**
68: * @return Returns the batchId.
69: */
70: public String getBatchId() {
71: return batchId;
72: }
73:
74: /* (non-Javadoc)
75: * @see java.lang.Iterable#iterator()
76: */
77: public Iterator<Reply> iterator() {
78: return replies.iterator();
79: }
80:
81: private String batchId = null;
82:
83: /**
84: * The collection of Replies that we should execute
85: */
86: private List<Reply> replies = new ArrayList<Reply>();
87: }
|