AzureusDownload.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.File; import javax.swing.Action; import org.apache.log4j.Logger; import org.gudy.azureus2.core3.disk.DiskManagerFileInfo; import org.xnap.XNap; import org.xnap.peer.Peer; import org.xnap.plugin.Plugin; import org.xnap.transfer.AbstractTransfer; import org.xnap.transfer.Download; import org.xnap.transfer.Segment; /** * Downloads a file. */ public class AzureusDownload extends AbstractTransfer implements Download { //--- Constant(s) --- //--- Data field(s) --- private static Logger logger = Logger.getLogger(AzureusDownload.class); private AzureusDownloadContainer parent; private DiskManagerFileInfo file; private AzureusDownloadSegment[] segments; //--- Constructor(s) --- public AzureusDownload(AzureusDownloadContainer parent, DiskManagerFileInfo file) { this.parent = parent; this.file = file; long pieceLength = parent.getManager().getDiskManager().getPieceLength(); Segment[] parentSegments = parent.getSegments(); this.segments = new AzureusDownloadSegment[file.getNbPieces()]; for (int i = 0; i < segments.length; i++) { long start = i * pieceLength; segments[i] = new AzureusDownloadSegment (getFilesize(), start, start + pieceLength, parentSegments[file.getFirstPieceNumber() + i]); } } //--- Method(s) --- public long getBytesTransferred() { return file.getDownloaded(); } public Action[] getActions() { return parent.getActions(); } public File getFile() { return new File(file.getPath() + file.getName()); } public String getFilename() { return file.getName(); } public long getFilesize() { return file.getLength(); } public Peer getPeer() { return null; } public Plugin getPlugin() { return AzureusPlugin.getInstance(); } public Segment[] getSegments() { return segments; } public String getStatus() { if (!isRunning()) { return null; } switch (file.getAccessMode()) { case DiskManagerFileInfo.READ: return XNap.tr("Read"); case DiskManagerFileInfo.WRITE: return XNap.tr("Write"); default: return XNap.tr("Unknown State {0}", file.getAccessMode()); } } public long getTotalBytesTransferred() { return getBytesTransferred(); } public boolean isDone() { return parent.isDone(); } public boolean isRunning() { return parent.isRunning(); } /** * Redeclare in order to make it accessible to AzureusDownloadContainer. * @see org.xnap.transfer.AbstractTransfer#transferStarted() */ protected void transferStarted() { super.transferStarted(); } /** * Redeclare in order to make it accessible to AzureusDownloadContainer. * @see org.xnap.transfer.AbstractTransfer#transferStarted() */ protected void transferStopped() { super.transferStopped(); } //--- Inner Class(es) --- }

The table below shows all metrics for AzureusDownload.java.

MetricValueDescription