Team 1 Branch Documentation - rsanchez-wsu/jfiles GitHub Wiki

#Packages

edu.wright.cs.jfiles.client - package edu.wright.cs.jfiles.client

edu.wright.cs.jfiles.common - package edu.wright.cs.jfiles.common

edu.wright.cs.jfiles.server - package edu.wright.cs.jfiles.server

edu.wright.cs.jfiles.socketmanagement - package edu.wright.cs.jfiles.socketmanagement


#Enums

PacketPriority - Enum in edu.wright.cs.jfiles.socketmanagement

A enum for the priority levels used in SocketManager.

TrafficTag - Enum in edu.wright.cs.jfiles.socketmanagement

A enum used to tag packets in SocketManager.


#Interface

ServerRMI - Interface in edu.wright.cs.jfiles.common

This interface is for the JFilesServer class and allows us to use Remote Objects.


#Classes

JFilesClient - Class in edu.wright.cs.jfiles.client

The main class of the JFiles client application.

Constructors used for this class: JFilesClient().


JFilesGui - Class in edu.wright.cs.jfiles.client

The main class of the JFiles client GUI application. This is a Java FX application.

Constructors used for this class: JFilesGui().


JFilesServer - Class in edu.wright.cs.jfiles.server

The main class of the JFiles server application.

Constructors used for this class: JFilesServer(Socket).


NetUtil - Class in edu.wright.cs.jfiles.common

The Network Util class, to be used by both client and server.

Constructors used in this class: NetUtil().


PacketAssembler - Class in edu.wright.cs.jfiles.socketmanagement

This class is used to reassemble packets generated by the SocketManager class.

Constructors used in this class: PacketAssembler(byte, int, byte[]).


SocketManager - Class in edu.wright.cs.jfiles.socketmanagement

This class is meant to be placed in front of and before a socket instance. It provides a means to get controlled access to and from a socket while also providing concurrency and flexibility in network traffic flow.

Constructors used in this class: SocketManager(Socket), SocketManager(Socket, int).


#Constructors

JFilesClient() - Constructor for class edu.wright.cs.jfiles.client.JFilesClient

No argument constructor.


JFilesGui() - Constructor for class edu.wright.cs.jfiles.client.JFilesGui

Handles allocating resources needed for the GUI. Creates a button.


JFilesServer(Socket sock) - Constructor for class edu.wright.cs.jfiles.server.JFilesServer

Handles allocating resources needed for the server.

Parameter sock - Socket


NetUtil() - Constructor for class edu.wright.cs.jfiles.common.NetUtil


PacketAssembler(byte tag, int idnum, byte[] packet) - Constructor for class edu.wright.cs.jfiles.socketmanagement.PacketAssembler

Constructs the PacketAssemble object with an assigned ID number and initial packet.

Parameter tag - TrafficTag byte value of the packet.

Parameter idnum - Identification number associated with every packet and this object.

Parameter packet - The initial packet to begin assembly process.


SocketManager(Socket mainSocket) - Constructor for class edu.wright.cs.jfiles.socketmanagement.SocketManager

This constructor will produce two Thread, one for incoming traffic and one for outgoing traffic. Default packet size is 1024 bytes.

Parameter mainSocket - The socket currently being managed.


SocketManager(Socket mainSocket, int packetSize) - Constructor for class edu.wright.cs.jfiles.socketmanagement.SocketManager

This constructor will produce two Thread, one for incoming traffic and one for outgoing traffic. This constructor sets the packet size to be used.

Parameter mainSocket - The socket to be used.

Parameter packetSize - The size, in bytes, of the packets being sent and received.


#Methods

addPacket(byte[] packet) - Method in class edu.wright.cs.jfiles.socketmanagement.PacketAssembler

This method is used by the Socket Manager to add a packet to the Packet Assembler object. This will also perform a notifyAll() call to wake the Packet Assembler if it became dormant.

Parameter packet - The packet to be added to the packet assembler build order.

Return type: void.


buttonClick() - Method in class edu.wright.cs.jfiles.client.JFilesGui

Handle the button click events.

No parameters.

Return type: void.


close() - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

Causes the SocketManager thread to die. Does NOT close the underlying socket.

No parameters.

Return type: Boolean - returns true once both threads are dead.


end() - Method in class edu.wright.cs.jfiles.socketmanagement.PacketAssembler

Ends the packet assembly process and finalizes file.

No parameters.

Return type: void.


fileCommand(String file, Socket sock) - Method in class edu.wright.cs.jfiles.client.JFilesClient

Method for the FILE command. Downloads a file from the server and compares checksums to verify file.

Parameter file - name of file that needs to be sent.

Parameter sock - an active Socket object connected to server.

Return type: void.


fileSendCommand(String filepath, Socket sock) - Method in class edu.wright.cs.jfiles.client.JFilesClient

Method to handle FILESEND command. Read bytes from file and sends to output stream.

Parameter filepath - the location of the file to send.

Parameter sock - the active socket on which the server connection resides.

Return type: void.


generateRandomId() - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

Generates a pseudorandom integer for use as an ID.

No parameters.

Return type: int - returns the psuedorandomly generated number.


getChecksum(File fileToCheck) - Method in class edu.wright.cs.jfiles.common.NetUtil

Method for producing a Checksum. Takes in a file type and converts it into an MD5 standard checksum which is returned in the form of a byte array.

Parameter fileToCheck - Name of the file to check.

Return type: String - byte array.


getCommandInput() - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

Used by the class that is getting it's socket managed to get a command from the other end. Blocks until a command is received.

No parameters.

Return type: String - The command input.


getFile(String file, Socket sock) - Method in interface edu.wright.cs.jfiles.common.ServerRMI

Handles the transfer of a file from client to server.

Parameter file - filename of received file.

Parameter sock - socket with active connection.

Return type: void.


getFile(String file, Socket sock) - Method in class edu.wright.cs.jfiles.server.JFilesServer

Handles the transfer of a file from client to server.

Parameter file - filename of received file.

Parameter sock - socket with active connection.

Return type: void.


getFile() - Method in class edu.wright.cs.jfiles.socketmanagement.PacketAssembler

Returns the finished file or null if the file is not finished.

No parameters.

Return type: File - returns the file if finished, returns null if not finished.


getFile(int fileID) - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

This method is used to obtain the completed file once it has been downloaded. Will return null when the file is not ready or doesn't exist.

Parameter fileID - The identification number associated with the file.

Return type: File - The completed file or null if the file doesn't exist or is not complete.


getFileName(int mode) - Method in class edu.wright.cs.jfiles.client.JFilesClient

This method gets the name of a file that the user wants to receive from the server or send to the server. This method also makes sure that the file name is valid.

Parameter mode - if mode = 0 gets the name of the file that is to be received from the server. if mode = 1 gets the name of the file that is to be sent to the server

Return type: String - the name of the file.


getId() - Method in class edu.wright.cs.jfiles.socketmanagement.PacketAssembler

Returns the ID number associated with this instance.

No parameters.

Return type: int - ID number.


isDone() - Method in class edu.wright.cs.jfiles.socketmanagement.PacketAssembler

Checks the status of this packet assembler.

No parameters.

Return type: Boolean - Returns true if the packet assembler is finished creating the file.


JFilesServer() - Method in interface edu.wright.cs.jfiles.common.ServerRMI

Handles allocating resources needed for the server.

No parameters.

Return type: void.


main(String[] args) - Static method in class edu.wright.cs.jfiles.client.JFilesClient

The main entry point to the program.

Parameter args - Command line arguments.

Return type: void.


main(String[] args) - Static method in class edu.wright.cs.jfiles.client.JFilesGui

The main entry point to the program.

Parameter args - Command line arguments.

Return type: void.


main() - Static method in interface edu.wright.cs.jfiles.common.ServerRMI

The main entry point to the program.

No parameters.

Return type: void.


main(String[] args) - Static method in class edu.wright.cs.jfiles.server.JFilesServer

The main entry point to the program.

Parameter args - Command line arguments.

Return type: void.


packId(int num) - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

Converts the ID number into a 4 byte array.

Parameter num - The integer being converted.

Return type: byte[] - 4 byte array.


rawInputStream() - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

Returns the direct and uncontrolled input stream for the socket. Should not be used ordinarily.

No parameters.

Return type: mainSocket.getInputStream() - the input stream.


rawOutputStream() - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

Returns the direct and uncontrolled output stream for the socket. Should not be used ordinarily.

No parameters.

Return type: mainSocket.getOutputStream() - the output stream.


sendCommand(String commandToSend) - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

Use to send a command to the other side. Used to request files or shutdown the connection.

Parameter commandToSend - the command to send.

Return type: void.


sendFile(String file, Socket servSock) - Method in interface edu.wright.cs.jfiles.common.ServerRMI

When FILE command is received from client, server calls this method to handle file transfer.

Parameter file - the file to send.

Parameter servSock - the socket where the server connection resides.

Return type: void.


sendFile(String file, Socket servSock) - Method in class edu.wright.cs.jfiles.server.JFilesServer

When FILE command is received from client, server calls this method to handle file transfer.

Parameter file - the file to send.

Parameter servSock - the socket where the server connection resides.

Return type: void.


sendFile(File file) - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

Sends a file in a controlled manner through the output stream.

Parameter file - the file to send.

Return type: void.


sendFileId(int identity, String filename, String checksum) - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

Sends the file ID number to the receiving end.

Parameter identity - The ID number to send.

Parameter filename - The name of the file being sent.

Return type: void.


sendOut(byte[] packet) - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

Takes a single byte array and sends it out with low priority. Default packet size is 1024 bytes. If the packet being sent is less then 1024 bytes then add a '\r' byte to then end to indicate an end to the packet.

Parameter packet - the byte array to send.

Return type: void.


sendOut(byte[] packet, PacketPriority pri) - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

Adds packets to a queue based on priority level to await transport through the output stream. Default packet size is 1024 bytes. If the packet being sent is less then 1024 bytes then add a '\r' byte to then end to indicate an end to the packet.

Parameter packet - packet to be added to the queue.

Parameter pri - the priority level of the packet.

Return type: void.


start(Stage) - Method in class edu.wright.cs.jfiles.client.JFilesGui


unpackId(byte[] idarr) - Method in class edu.wright.cs.jfiles.socketmanagement.SocketManager

Converts the ID number from a 4 byte array back into an integer.

Parameter idarr - The 4 byte array.

Return type: int - the Id as an integer.


value() - Method in enum edu.wright.cs.jfiles.socketmanagement.TrafficTag

Gets the byte value of the tag.

No parameters.

Return type: byte - returns the tag as a byte.