jBittorrentAPI
Class Peer

java.lang.Object
  extended by jBittorrentAPI.Peer

public class Peer
extends java.lang.Object

Class representing a bittorrent peer


Field Summary
private  boolean choked
           
private  boolean choking
           
private  float dlrate
           
private  int downloaded
           
private  java.util.BitSet hasPiece
           
private  java.lang.String id
           
private  boolean interested
           
private  boolean interesting
           
private  java.lang.String ip
           
private  long lastDL
           
private  long lastUL
           
private  int port
           
private  float ulrate
           
private  int uploaded
           
 
Constructor Summary
Peer()
           
Peer(java.lang.String id, java.lang.String ip, int port)
           
 
Method Summary
 boolean equals(Peer p)
          Compares if this peer is equal to the peer in parameter
 int getDL()
          Returns the total number of bytes downloaded from this peer
 float getDLRate(boolean reset)
          Returns the number of bytes downloaded since the last reset
 java.util.BitSet getHasPiece()
          Returns the pieces availability of this peer
 java.lang.String getID()
          Returns the id of this peer
 java.lang.String getIP()
          Returns the IP address of this peer
 int getPort()
          Returns the listening port of this peer
 int getUL()
          Returns the total number of bytes uploaded to this peer
 float getULRate(boolean reset)
          Returns the number of bytes uploaded since the last reset.
 boolean isChoked()
          Returns if this peer is choked or not
 boolean isChoking()
          Returns if this peer is choking or not
 boolean isInterested()
          Returns if this peer is interested or not
 boolean isInteresting()
          Returns if this peer is interesting or not
 void resetDL()
           
 void resetUL()
           
 void setChoked(boolean c)
          Sets if this peer is choked or not
 void setChoking(boolean c)
          Sets if this peer is choking or not
 void setDLRate(int dl)
          Updates the downloaded values
 void setHasPiece(byte[] bitfield)
          Updates this peer availability according to the received bitfield
 void setHasPiece(int piece, boolean has)
          Updates the availability of the piece in parameter
 void setID(java.lang.String id)
          Sets the id of this peer
 void setInterested(boolean i)
          Sets if this peer is intereseted or not
 void setInteresting(boolean i)
          Sets if this peer is interesting or not
 void setIP(java.lang.String ip)
          Sets the IP address of this peer
 void setPort(int port)
          Sets the listening port of this peer
 void setULRate(int ul)
          Updates the uploaded values
 java.lang.String toString()
          Returns this peer characteristics in the form :
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

choked

private boolean choked

choking

private boolean choking

dlrate

private float dlrate

downloaded

private int downloaded

hasPiece

private java.util.BitSet hasPiece

id

private java.lang.String id

interested

private boolean interested

interesting

private boolean interesting

ip

private java.lang.String ip

lastDL

private long lastDL

lastUL

private long lastUL

port

private int port

ulrate

private float ulrate

uploaded

private int uploaded
Constructor Detail

Peer

public Peer()

Peer

public Peer(java.lang.String id,
            java.lang.String ip,
            int port)
Method Detail

equals

public boolean equals(Peer p)
Compares if this peer is equal to the peer in parameter

Parameters:
p - Peer
Returns:
boolean

getDL

public int getDL()
Returns the total number of bytes downloaded from this peer

Returns:
int

getDLRate

public float getDLRate(boolean reset)
Returns the number of bytes downloaded since the last reset

Parameters:
reset - true if the download rate should be reset
Returns:
float

getHasPiece

public java.util.BitSet getHasPiece()
Returns the pieces availability of this peer

Returns:
BitSet

getID

public java.lang.String getID()
Returns the id of this peer

Returns:
String

getIP

public java.lang.String getIP()
Returns the IP address of this peer

Returns:
String

getPort

public int getPort()
Returns the listening port of this peer

Returns:
int

getUL

public int getUL()
Returns the total number of bytes uploaded to this peer

Returns:
int

getULRate

public float getULRate(boolean reset)
Returns the number of bytes uploaded since the last reset.

Parameters:
reset - true if the download rate should be reset
Returns:
float

isChoked

public boolean isChoked()
Returns if this peer is choked or not

Returns:
boolean

isChoking

public boolean isChoking()
Returns if this peer is choking or not

Returns:
boolean

isInterested

public boolean isInterested()
Returns if this peer is interested or not

Returns:
boolean

isInteresting

public boolean isInteresting()
Returns if this peer is interesting or not

Returns:
boolean

resetDL

public void resetDL()

resetUL

public void resetUL()

setChoked

public void setChoked(boolean c)
Sets if this peer is choked or not

Parameters:
c - boolean

setChoking

public void setChoking(boolean c)
Sets if this peer is choking or not

Parameters:
c - boolean

setDLRate

public void setDLRate(int dl)
Updates the downloaded values

Parameters:
dl - int

setHasPiece

public void setHasPiece(byte[] bitfield)
Updates this peer availability according to the received bitfield

Parameters:
bitfield - byte[]

setHasPiece

public void setHasPiece(int piece,
                        boolean has)
Updates the availability of the piece in parameter

Parameters:
piece - int
has - boolean

setID

public void setID(java.lang.String id)
Sets the id of this peer

Parameters:
id - String

setInterested

public void setInterested(boolean i)
Sets if this peer is intereseted or not

Parameters:
i - boolean

setInteresting

public void setInteresting(boolean i)
Sets if this peer is interesting or not

Parameters:
i - boolean

setIP

public void setIP(java.lang.String ip)
Sets the IP address of this peer

Parameters:
ip - String

setPort

public void setPort(int port)
Sets the listening port of this peer

Parameters:
port - int

setULRate

public void setULRate(int ul)
Updates the uploaded values

Parameters:
ul - int

toString

public java.lang.String toString()
Returns this peer characteristics in the form :

Overrides:
toString in class java.lang.Object
Returns:
String