1 /* 2 * Copyright (C) Azureus Software, Inc, All Rights Reserved. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details ( see the LICENSE file ). 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 19 package org.gudy.azureus2.ui.swt.views.clientstats; 20 21 import java.util.HashMap; 22 import java.util.Map; 23 24 import org.gudy.azureus2.core3.util.BEncodableObject; 25 26 import com.aelitis.azureus.util.MapUtils; 27 28 public class ClientStatsDataSource 29 implements BEncodableObject 30 { 31 32 public String client; 33 34 public int count; 35 36 public int current; 37 38 public long bytesReceived; 39 40 public long bytesDiscarded; 41 42 public long bytesSent; 43 44 public Map<String, Map<String, Object>> perNetworkStats; 45 46 public ClientStatsOverall overall; 47 ClientStatsDataSource()48 public ClientStatsDataSource() { 49 perNetworkStats = new HashMap<String, Map<String, Object>>(); 50 } 51 ClientStatsDataSource(Map loadMap)52 public ClientStatsDataSource(Map loadMap) { 53 client = MapUtils.getMapString(loadMap, "client", "?"); 54 count = MapUtils.getMapInt(loadMap, "count", 0); 55 bytesReceived = MapUtils.getMapLong(loadMap, "bytesReceived", 0); 56 bytesDiscarded = MapUtils.getMapLong(loadMap, "bytesDiscarded", 0); 57 bytesSent = MapUtils.getMapLong(loadMap, "bytesSent", 0); 58 perNetworkStats = MapUtils.getMapMap(loadMap, "perNetworkStats", 59 new HashMap<String, Map<String, Object>>()); 60 } 61 toBencodeObject()62 public Object toBencodeObject() { 63 Map<String, Object> map = new HashMap<String, Object>(); 64 map.put("client", client); 65 map.put("count", Long.valueOf(count)); 66 map.put("bytesReceived", Long.valueOf(bytesReceived)); 67 map.put("bytesDiscarded", Long.valueOf(bytesDiscarded)); 68 map.put("bytesSent", Long.valueOf(bytesSent)); 69 map.put("perNetworkStats", perNetworkStats); 70 return map; 71 } 72 } 73