org.xnap.plugin.opennap.net
Class OpenNapSegment

java.lang.Object
  extended by org.xnap.plugin.opennap.net.OpenNapSegment
All Implemented Interfaces:
java.lang.Cloneable, Segment

public class OpenNapSegment
extends java.lang.Object
implements java.lang.Cloneable, Segment

The end of the segment can change through a split.


Field Summary
static long MIN_SEGEMENT_SIZE
          The minimun size for a single segment.
 
Constructor Summary
OpenNapSegment(long start, long end, long total)
           
OpenNapSegment(OpenNapSegmentData data, long total)
          Creates a new segment based on resume data.
 
Method Summary
 java.lang.Object clone()
           
 int getAvailability()
           
 OpenNapDownload getDownload()
          Returns the download currently downloading the segment.
 long getDownloadOffset()
          Returns the download offset that should be sent to the peer.
 long getEnd()
           
 java.io.File getFile()
           
 long getFileOffset()
          Returns the file offset to seek to when matching the overlap
 OpenNapSegment getNext()
           
 int getOverlap()
          Returns the number of bytes that need to be matched.
 OpenNapSegment getPrevious()
           
 long getStart()
           
 long getTotal()
           
 long getTransferred()
           
 boolean isFinished()
           
 void setDownload(OpenNapDownload download)
           
 void setFile(java.io.File file)
          Modifies: file
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_SEGEMENT_SIZE

public static final long MIN_SEGEMENT_SIZE
The minimun size for a single segment.

See Also:
Constant Field Values
Constructor Detail

OpenNapSegment

public OpenNapSegment(long start,
                      long end,
                      long total)

OpenNapSegment

public OpenNapSegment(OpenNapSegmentData data,
                      long total)
Creates a new segment based on resume data. The segment spans from data.start to total.

Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getAvailability

public int getAvailability()
Specified by:
getAvailability in interface Segment
Returns:
a number between 0 (= not available) and 255 (= high availability)

getEnd

public long getEnd()
Specified by:
getEnd in interface Segment
Returns:
the end offset

getDownload

public OpenNapDownload getDownload()
Returns the download currently downloading the segment.

Returns:
null, if this segment is currently idle

getDownloadOffset

public long getDownloadOffset()
Returns the download offset that should be sent to the peer.


getFileOffset

public long getFileOffset()
Returns the file offset to seek to when matching the overlap


getFile

public java.io.File getFile()

getNext

public OpenNapSegment getNext()

getOverlap

public int getOverlap()
Returns the number of bytes that need to be matched.


getPrevious

public OpenNapSegment getPrevious()

getStart

public long getStart()
Specified by:
getStart in interface Segment
Returns:
the start offset

getTotal

public long getTotal()
Specified by:
getTotal in interface Segment
Returns:
the total size

getTransferred

public long getTransferred()
Specified by:
getTransferred in interface Segment
Returns:
the number of bytes transferred

isFinished

public boolean isFinished()

setDownload

public void setDownload(OpenNapDownload download)

setFile

public void setFile(java.io.File file)

Modifies: file



Copyright © 2001-2005 XNap Team. All Rights Reserved.