Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

konspire.common
Class FileHost  view FileHost download FileHost.java

java.lang.Object
  extended bykonspire.common.FileHost
All Implemented Interfaces:
Message, java.io.Serializable

public class FileHost
extends java.lang.Object
implements Message

Message containing a description of a network host that is sharing files.

Contains the host address and a collection of FileDescriptors, one for each file that the host is sharing.

Includes functionality for building the collection of FileDescriptors from a shared files directory with subdirectories.


Field Summary
protected  Host address
          Address of this FileHost.
private  boolean dirExists
           
protected  Vector fileVector
          Vector of FileDescriptors for files on this host.
protected  Host mServer
          Server that this FileHost is connected to.
protected  Vector oldFileVector
           
 
Constructor Summary
FileHost(Host addr, FileDirectoryPath inFilesPath)
          Constructs a FileHost from a host address and a shared file directory.
FileHost(Host addr, Vector fVector)
          Constructs a FileHostVector of FileDescriptors.
 
Method Summary
 boolean downloadDirectoryExists()
          Gets whether the download directory specified by the file directory path exists on this host.
 boolean equals(java.lang.Object o)
          Determine whether this Object is semantically equal to another Object.
 long getAmountOffered()
           
 Vector getFileVector()
          Gets the Vector of FileDescriptors contained in this message.
 Host getHost()
          Gets the address of this host.
 Vector getOldFileVector()
           
 Host getServer()
          Gets the server that this FileHost is connnected to.
 void rescanFileList(FileDirectoryPath inFilesPath)
          Rescans the file list on this host given a shared file directory.
static void scanDir(Host inAddress, java.io.File dirFile, Vector destVector)
          Recursively scans a directory, adding all files to a Vector as FileDescriptors.
 void setFileVector(Vector fVector)
          Sets the Vector of FileDescriptors contained in this message.
 void setHost(Host addr)
          Replaces the host address for all FileDescriptors in this message.
 void setOldFileVector(Vector fVector)
           
 void setServer(Host inServer)
          Sets the server that this FileHost is connnected to.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

address

protected Host address
Address of this FileHost.


mServer

protected Host mServer
Server that this FileHost is connected to.


fileVector

protected Vector fileVector
Vector of FileDescriptors for files on this host.


oldFileVector

protected Vector oldFileVector

dirExists

private boolean dirExists
Constructor Detail

FileHost

public FileHost(Host addr,
                Vector fVector)
Constructs a FileHostVector of FileDescriptors.


FileHost

public FileHost(Host addr,
                FileDirectoryPath inFilesPath)
Constructs a FileHost from a host address and a shared file directory.

Method Detail

rescanFileList

public void rescanFileList(FileDirectoryPath inFilesPath)
Rescans the file list on this host given a shared file directory.

Note that this method only works if it's called on this host.


downloadDirectoryExists

public boolean downloadDirectoryExists()
Gets whether the download directory specified by the file directory path exists on this host.


getHost

public Host getHost()
Gets the address of this host.


setHost

public void setHost(Host addr)
Replaces the host address for all FileDescriptors in this message.


getServer

public Host getServer()
Gets the server that this FileHost is connnected to.


setServer

public void setServer(Host inServer)
Sets the server that this FileHost is connnected to.


getFileVector

public Vector getFileVector()
Gets the Vector of FileDescriptors contained in this message.


getOldFileVector

public Vector getOldFileVector()

setFileVector

public void setFileVector(Vector fVector)
Sets the Vector of FileDescriptors contained in this message.


setOldFileVector

public void setOldFileVector(Vector fVector)

equals

public boolean equals(java.lang.Object o)
Description copied from class: java.lang.Object
Determine whether this Object is semantically equal to another Object.

There are some fairly strict requirements on this method which subclasses must follow:

  • It must be transitive. If a.equals(b) and b.equals(c), then a.equals(c) must be true as well.
  • It must be symmetric. a.equals(b) and b.equals(a) must have the same value.
  • It must be reflexive. a.equals(a) must always be true.
  • It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
  • a.equals(null) must be false.
  • It must be consistent with hashCode(). That is, a.equals(b) must imply a.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.

This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for a.equals(b) to be true even though a.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.

In general, the Collections API (java.util) use the equals method rather than the == operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.

The default implementation returns this == o.


scanDir

public static void scanDir(Host inAddress,
                           java.io.File dirFile,
                           Vector destVector)
Recursively scans a directory, adding all files to a Vector as FileDescriptors.


getAmountOffered

public long getAmountOffered()

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).