Query Cycle Simulator HEADER

qcsim.content.impl
Class PeerContentImpl

java.lang.Object
  |
  +--qcsim.content.impl.PeerContentImpl
All Implemented Interfaces:
java.lang.Cloneable, PeerContent

public class PeerContentImpl
extends java.lang.Object
implements PeerContent, java.lang.Cloneable

Represents the total content of a given peer.

Version:
1.0
Author:
unascribed

Constructor Summary
PeerContentImpl(PeerContentManager manager, java.util.ArrayList contentCategories)
          Constructor: Sets up supported content categories of peer.
 
Method Summary
 int categories()
          The number of content categories this peer contains.
 Content category(int category)
          Get the content category
 java.lang.Object clone()
          Create a copy of this peer content
 java.util.Iterator iterator()
          Iterator for all content categories owned by this peer.
 PeerContentManager manager()
          The manager of this PeerContent object.
 int randomCategory()
          Choose a random category to download from
 int randomFile(int category)
          Choose a random file to download.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeerContentImpl

public PeerContentImpl(PeerContentManager manager,
                       java.util.ArrayList contentCategories)
Constructor: Sets up supported content categories of peer.

Parameters:
manager - The content manager
contentCategories - A list of Content categories this peer owns.
Method Detail

clone

public java.lang.Object clone()
Create a copy of this peer content

Overrides:
clone in class java.lang.Object

manager

public PeerContentManager manager()
The manager of this PeerContent object.

Specified by:
manager in interface PeerContent
Returns:
The Peer Content Manager.

categories

public int categories()
The number of content categories this peer contains.

Specified by:
categories in interface PeerContent
Returns:
the number of content categories.

iterator

public java.util.Iterator iterator()
Iterator for all content categories owned by this peer.

Specified by:
iterator in interface PeerContent
Returns:
iterator of content categories.

category

public Content category(int category)
Get the content category

Specified by:
category in interface PeerContent

randomCategory

public int randomCategory()
Choose a random category to download from

Specified by:
randomCategory in interface PeerContent
Returns:
the category

randomFile

public int randomFile(int category)
Choose a random file to download. This will not pick a file already owned. It will also prefer highly ranked files.

Specified by:
randomFile in interface PeerContent
Parameters:
category - choose file from this content category
Returns:
the file choosen.

Query Cycle Simulator HEADER