View Javadoc
1   //////////////////////////////////////////////////////////////////////////////
2   // dexterIM - Instant Messaging Framework
3   // Copyright (C) 2003  Christoph Walcher
4   //
5   // This program is free software; you can redistribute it and/or modify
6   // it under the terms of the GNU General Public License as published by
7   // the Free Software Foundation; either version 2 of the License, or
8   // (at your option) any later version.
9   //
10  // This program is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  // GNU General Public License for more details.
14  //
15  // You should have received a copy of the GNU General Public License
16  // along with this program; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  //////////////////////////////////////////////////////////////////////////////
19  package net.sf.dexterim.oscar.server;
20  
21  import java.util.ArrayList;
22  import java.util.Collections;
23  import java.util.List;
24  
25  import net.sf.dexterim.oscar.OscarByteBuffer;
26  import net.sf.dexterim.oscar.entity.DWord;
27  import net.sf.dexterim.oscar.entity.Snac;
28  import net.sf.dexterim.oscar.entity.Word;
29  
30  
31  /***
32   * @author christoph
33   */
34  public class RateInfoResponse implements Response, UnkownMessage {
35  	private List rateIds;
36  	
37  	private RateInfoResponse() {
38  		this.rateIds = new ArrayList();
39  	}
40  	
41  	public static RateInfoResponse create(Snac snac) {
42  		RateInfoResponse message = new RateInfoResponse();
43  		
44  		OscarByteBuffer buffer = OscarByteBuffer.wrap(snac.getData());
45  		
46  		int count = buffer.getWord().getValue();
47  		
48  		for (int i=0; i< count; i++) {
49  			message.rateIds.add(RateClass.create(buffer));
50  		}
51  		
52  		return message;
53  	}
54  
55  	public List getRateIds() {
56  		return Collections.unmodifiableList(rateIds);
57  	}
58  	
59  	public static class RateClass {
60  		
61  		private DWord windowSize;
62  		private DWord clearAvg;
63  		private DWord warnAvg;
64  		private DWord limitedAvg;
65  		private DWord disconnectAvg;
66  		private DWord currentAvg;
67  		private DWord maxAvg;
68  		private Word id;
69  		
70  		private RateClass() {
71  			
72  		}
73  		
74  		public int getIdValue() {
75  			return id.getValue();
76  		}
77  		
78  		public Word getId() {
79  			return id;
80  		}
81  		
82  		public static RateClass create(OscarByteBuffer buffer) {
83  			RateClass rateClass = new RateClass();
84  			
85  			rateClass.id = buffer.getWord();
86  			rateClass.windowSize = buffer.getDWord();
87  			rateClass.clearAvg = buffer.getDWord();
88  			rateClass.warnAvg = buffer.getDWord();
89  			rateClass.limitedAvg = buffer.getDWord();
90  			rateClass.disconnectAvg = buffer.getDWord();
91  			rateClass.currentAvg = buffer.getDWord();
92  			rateClass.maxAvg = buffer.getDWord();
93  			
94  			return rateClass;
95  		}
96  		/***
97  		 * @return Returns the clearAvg.
98  		 */
99  		public DWord getClearAvg() {
100 			return clearAvg;
101 		}
102 		/***
103 		 * @return Returns the currentAvg.
104 		 */
105 		public DWord getCurrentAvg() {
106 			return currentAvg;
107 		}
108 		/***
109 		 * @return Returns the disconnectAvg.
110 		 */
111 		public DWord getDisconnectAvg() {
112 			return disconnectAvg;
113 		}
114 		/***
115 		 * @return Returns the limitedAvg.
116 		 */
117 		public DWord getLimitedAvg() {
118 			return limitedAvg;
119 		}
120 		/***
121 		 * @return Returns the maxAvg.
122 		 */
123 		public DWord getMaxAvg() {
124 			return maxAvg;
125 		}
126 		/***
127 		 * @return Returns the warnAvg.
128 		 */
129 		public DWord getWarnAvg() {
130 			return warnAvg;
131 		}
132 		/***
133 		 * @return Returns the windowSize.
134 		 */
135 		public DWord getWindowSize() {
136 			return windowSize;
137 		}
138 	}
139 }