1 /************************************************************
2 * Copyright *
3 * Portions of this software are Copyright (c) 1993 - 2002, *
4 * Chad Z. Hower (Kudzu) and the Indy Pit Crew *
5 * - http://www.nevrona.com/Indy/ *
6 ************************************************************/
7 package org.indy;
8
9 import java.util.ArrayList;
10
11
12 /***
13 * This is not synced.
14 *
15 *@author owen
16 */
17 public class RFCReplies {
18 private ArrayList replies = new ArrayList();
19
20 /***
21 * Description of the Method
22 *
23 *@param reply Description of the Parameter
24 *@param index Description of the Parameter
25 */
26 public void set(RFCReply reply, int index) {
27 boundsCheck(index);
28 replies.set(index, reply);
29 }
30
31 /***
32 * Description of the Method
33 *
34 *@param index Description of the Parameter
35 *@return Description of the Return Value
36 */
37 public RFCReply get(int index) {
38 boundsCheck(index);
39
40 return (RFCReply) replies.get(index);
41 }
42
43 /***
44 * Description of the Method
45 *
46 *@param numericCode Description of the Parameter
47 *@return Description of the Return Value
48 */
49 public final RFCReply findByNumber(int numericCode) {
50 for (int i = 0, n = replies.size(); i < n; i++) {
51 if (get(i).getNumericCode() == numericCode) {
52 return get(i);
53 }
54 }
55
56 return null;
57 }
58
59 /***
60 * Description of the Method
61 *
62 *@return Description of the Return Value
63 */
64 public RFCReply add() {
65 RFCReply reply = new RFCReply();
66
67 replies.add(reply);
68
69 return reply;
70 }
71
72 /***
73 * Description of the Method
74 *
75 *@param numericCode Description of the Parameter
76 *@param text Description of the Parameter
77 *@return Description of the Return Value
78 */
79 public RFCReply add(int numericCode, String text) {
80 RFCReply result = null;
81
82 if (null == findByNumber(numericCode)) {
83 result = add();
84 result.setNumericCode(numericCode);
85 result.setReply(numericCode, text);
86 }
87
88 return result;
89 }
90
91 /***
92 * Description of the Method
93 *
94 *@param index Description of the Parameter
95 */
96 public void boundsCheck(int index) {
97 if ((index < 0) || (index > replies.size())) {
98 throw new IndexOutOfBoundsException();
99 }
100 }
101
102 /***
103 * Description of the Method
104 *
105 *@param numericCode Description of the Parameter
106 *@param text Description of the Parameter
107 *@return Description of the Return Value
108 */
109 public RFCReply updateReply(int numericCode, String text) {
110 RFCReply result = findByNumber(numericCode);
111
112 if (null == result) {
113 result = add();
114 }
115
116 result.setReply(numericCode, text);
117
118 return result;
119 }
120
121 /***
122 * Description of the Method
123 *
124 *@param reply Description of the Parameter
125 */
126 public void updateText(RFCReply reply) {
127 if (0 == reply.getText().size()) {
128 RFCReply tmpReply = findByNumber(reply.getNumericCode());
129
130 if (tmpReply != null) {
131 reply.getText().copy(tmpReply.getText());
132 }
133 }
134 }
135 }
This page was automatically generated by Maven