AzureusTrackerTableModel.java

Index Score
org.xnap.plugin.azureus
XNap 3

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
/* * XNap - A P2P framework and client. * * See the file AUTHORS for copyright information. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.xnap.plugin.azureus; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.text.NumberFormat; import java.util.ArrayList; import javax.swing.SwingUtilities; import org.gudy.azureus2.core3.tracker.host.TRHostListener; import org.gudy.azureus2.core3.tracker.host.TRHostTorrent; import org.xnap.XNap; import org.xnap.gui.table.AbstractColumnTableModel; import org.xnap.gui.table.Column; import org.xnap.gui.table.FilesizeCellRenderer; /** * Table model for {@link } objects. */ public class AzureusTrackerTableModel extends AbstractColumnTableModel implements TRHostListener { //--- Data field(s) --- private ArrayList data = new ArrayList(); //--- Constructor(s) --- public AzureusTrackerTableModel() { Column columns[] = new Column[] { new Column("name", XNap.tr("Name"), String.class), new Column("tracker", XNap.tr("Tracker"), String.class), new Column("status", XNap.tr("Status"), String.class), new Column("seeds", XNap.tr("Seeds"), Integer.class), new Column("peers", XNap.tr("Peers"), Integer.class), new Column("announces", XNap.tr("Announces"), Integer.class), new Column("scrapes", XNap.tr("Scrapes"), Integer.class), new Column("completed", XNap.tr("Completed"), Integer.class), new Column("downloaded", XNap.tr("Downloaded"), Long.class, new FilesizeCellRenderer()), new Column("uploaded", XNap.tr("Uploaded"), Long.class, new FilesizeCellRenderer()), }; addColumns(columns); } //--- Method(s) --- public int getRowCount() { return data.size(); } public Object get(int i, int j) { TRHostTorrent t = (TRHostTorrent)data.get(i); // TRHostPeer[] peers = torrent.getPeers(); // // int peer_count = 0; // int seed_count = 0; // // long uploaded = 0; // long downloaded = 0; // long left = 0; // // for (int i=0;i<peers.length;i++){ // // TRHostPeer peer = peers[i]; // // if ( peer.isSeed()){ // // seed_count++; // }else{ // // peer_count++; // } // // uploaded += peer.getUploaded(); // downloaded += peer.getDownloaded(); // left += peer.getAmountLeft(); // } switch (j) { case 0: return new String(t.getTorrent().getName()); case 1: return t.getTorrent().getAnnounceURL().toString(); case 2: return getStatus(t.getStatus()); case 3: return new Integer(0); case 4: return new Integer(0); case 5: return new Integer(t.getAnnounceCount()); case 6: return new Integer(t.getScrapeCount()); case 7: return new Integer(t.getCompletedCount()); case 8: return new Long(t.getTotalBytesIn()); case 9: return new Long(t.getTotalBytesOut()); default: return null; } } public String getStatus(int status) { switch (status) { case TRHostTorrent.TS_FAILED: return XNap.tr("Failed"); case TRHostTorrent.TS_PUBLISHED: return XNap.tr("Published"); case TRHostTorrent.TS_STARTED: return XNap.tr("Started"); case TRHostTorrent.TS_STOPPED: return XNap.tr("Stopped"); default: return XNap.tr("Unknown status {0}", status); } } /** * @see org.gudy.azureus2.core3.tracker.host.TRHostListener#torrentAdded(org.gudy.azureus2.core3.tracker.host.TRHostTorrent) */ public void torrentAdded(final TRHostTorrent t) { Runnable runner = new Runnable() { public void run() { data.add(t); fireTableRowsInserted(data.size() - 1, data.size() - 1); } }; SwingUtilities.invokeLater(runner); } /** * @see org.gudy.azureus2.core3.tracker.host.TRHostListener#torrentChanged(org.gudy.azureus2.core3.tracker.host.TRHostTorrent) */ public void torrentChanged(final TRHostTorrent t) { Runnable runner = new Runnable() { public void run() { int i = data.indexOf(t); if (i != -1) { data.remove(i); fireTableRowsUpdated(i, i); } } }; SwingUtilities.invokeLater(runner); } /** * @see org.gudy.azureus2.core3.tracker.host.TRHostListener#torrentRemoved(org.gudy.azureus2.core3.tracker.host.TRHostTorrent) */ public void torrentRemoved(final TRHostTorrent t) { Runnable runner = new Runnable() { public void run() { int i = data.indexOf(t); if (i != -1) { data.remove(i); fireTableRowsDeleted(i, i); } } }; SwingUtilities.invokeLater(runner); } /** * @see org.gudy.azureus2.core3.tracker.host.TRHostListener#handleExternalRequest(java.lang.String, java.lang.String, java.lang.String, java.io.InputStream, java.io.OutputStream) */ public boolean handleExternalRequest(String client_address, String url, String header, InputStream is, OutputStream os) throws IOException { return false; } }

The table below shows all metrics for AzureusTrackerTableModel.java.

MetricValueDescription