frontend
Class LinkedFENodeList

java.lang.Object
  extended byfrontend.LinkedFENodeList

public class LinkedFENodeList
extends Object

This class will link together each nodes which is represented using the FENode class. The FENode class acts as the storing medium for the frontEnd ADT, while this class actus as the operational tool for the frontEnd to interact with it's ADT.

See Also:
FENode frontEnd

Constructor Summary
LinkedFENodeList()
          This will create an empty list.
 
Method Summary
 boolean add(String sInputIP, LanNode inputLanNode, JLabel inputLabel, int updateStatus, String hostName)
          This method will take in as it's arguments the essential data needed to create a new link in this linked structure.
 int compare(int[] insertingIP, int[] comparingIP)
          This method will compare two IP addresses.
 LinkedList delete(String sInputIP)
          This method will delete a node from this linked list structure.
 LinkedList getAllLabels()
          This method will simply extract all the JLabels for each node in the list.
 FENode getAllNodes()
          This method will return the first FENode (ie the header) for this list.
 String[] getAllStringIPs()
          This method will return all the IP addresses, in string format for all the node in this list.
 FENode getFENode(JLabel inputLabel)
          This method will simply return the corresponding FENode for the given input.
 FENode getFENode(LanNode inputLanNode)
          This method will simply return the corresponding FENode for the given input.
 FENode getFENode(String sInputIP)
          This method will simply return the corresponding FENode for the given input.
 int getNodePosition(String sInputIP)
          This method is used for obtaining the position of a node in this linked structure.
 int size()
          This method will return the size of this list.
 int[] StringToIntIp(String sInputIP)
          This method will take in a 32-bit IP address represented in String format, and convert each of the 8-bit integers so they may be placed in an int array.
 void updateLastUpdateForNode(JLabel inputLabel, int inNewUpdate)
          This method will update the last update status for a particular node.
 void updateLastUpdateForNode(String inputIP, int inNewUpdate)
          This method will update the last update status for a particular node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkedFENodeList

public LinkedFENodeList()
This will create an empty list. This empty list will consist of two dummy nodes which will represent the starting FENode and terminating FENode of this list.

Method Detail

add

public boolean add(String sInputIP,
                   LanNode inputLanNode,
                   JLabel inputLabel,
                   int updateStatus,
                   String hostName)
This method will take in as it's arguments the essential data needed to create a new link in this linked structure.

Parameters:
sInputIP - is the value of the IP in String format of a node to be added
inputLanNode - is the correponding LanNode object for this particular node
inputLabel - is the corresponding JLabel in which the frontEnd will use to convey a graphical representation of the status of this particular node
updateStatus - is the current status of the node. See FENode.getLastUpdateStatus() for more details
hostName - is the value derived from the DNS value for this particular node
Returns:
If the information does not already exist in this linked structure, true will be returned indicating that this node was successfully created and added to the structure. Otherwise, false will be returned.

getAllLabels

public LinkedList getAllLabels()
This method will simply extract all the JLabels for each node in the list.

Returns:
A LinkedList which will hold all the JLabels in this list.

getAllNodes

public FENode getAllNodes()
This method will return the first FENode (ie the header) for this list. This may be useful in case one wishes to traverse through the linked structure manually. Because all of these FENodes exist in a linked fashion, only the header needs to be returned.

Returns:
the header FENode of this list.

delete

public LinkedList delete(String sInputIP)
This method will delete a node from this linked list structure.

Parameters:
sInputIP - the string IP value of the node to be deleted.
Returns:
A LinkedList will be returned indicating the status of the deletion process.If the node was not found which corresponded to this input IP value, then the LinkedList returned would just contain one element, which would be a string value "FALSE". However, if the node to be deleted was found, then the LinkedList returned would contain 3 elements:
  • a string value "TRUE"
  • the corresponding JLabel of the node
  • the corresponding LanNode of the node
The reason this information is returned is the following: the frontEnd may delete a node in it's mapping by just supplying this method with a string value of the node's IP address. From here, if it's deleted, the frontEnd will now obtain the nodes corresponding LanNode and JLabel. Thus, the frontEnd has to just delete the returned LanNode from the blackBoard, and remove the JLabel from it's main panel.

getFENode

public FENode getFENode(String sInputIP)
This method will simply return the corresponding FENode for the given input.

Parameters:
sInputIP - the string value IP of the node to be found
Returns:
The corresponding FENode will be returned

getFENode

public FENode getFENode(JLabel inputLabel)
This method will simply return the corresponding FENode for the given input.

Parameters:
inputLabel - the JLabel of the node to be returned
Returns:
The corresponding FENode will be returned

getFENode

public FENode getFENode(LanNode inputLanNode)
This method will simply return the corresponding FENode for the given input.

Parameters:
inputLanNode - the LanNode of the node to be found.
Returns:
The corresponding FENode will be returned

getNodePosition

public int getNodePosition(String sInputIP)
This method is used for obtaining the position of a node in this linked structure. This method is used mainly by the frontEnd to determine where a particular lies in regards to the frontEnd's main panel. The reason this is needed is for the following example: if a user decides to search for a node in the current mapping on the frontEnd, the frontEnd must highlight the node requested by the user and bring focus to this node. Using this method, the frontEnd may determine (using mathematical manipulation) where the particular node lies.

Parameters:
sInputIP - the string value of the IP address in which one is searching for.
Returns:
In the case where the node is successfully found, the position of the node in the list (which is non-zero) is returned. If the node is not found, 0 is returned.

getAllStringIPs

public String[] getAllStringIPs()
This method will return all the IP addresses, in string format for all the node in this list.

Returns:
An array of string values, holding all the IP addresses, of the nodes in this mapping

size

public int size()
This method will return the size of this list.

Returns:
The number of nodes in this current list.

compare

public int compare(int[] insertingIP,
                   int[] comparingIP)
This method will compare two IP addresses. To use this method, first supply the String value of the IP address to the the method StringToIntIp(String sInputIP), and then pass the return values from that method to this one. This method will then compare each of the 4 cells from both the inserting int arrays in this method.

The way this method compares two IP addresses is as follows:

if insertingIP contained the values 1,2,3,4 and comparingIP contained the value 1,2,4,4; then the return value would indicate that comparingIP is larger than insertingIP. The reasoning, insertingIP[2] = 3 < comparingIP[2] = 4.

Parameters:
insertingIP - this is the first int array, representing a 32-bit IP address
comparingIP - this is the second int array, representing a 32-bit IP address
Returns:
  • 1 if insertingIP < comparingIP
  • 0 if insertingIP > comparingIP
  • -1 if comparingIP = insertingIP

StringToIntIp

public int[] StringToIntIp(String sInputIP)
This method will take in a 32-bit IP address represented in String format, and convert each of the 8-bit integers so they may be placed in an int array. This will be used in conjunction with the method compare.

Here is an example:

Input is 1.2.3.4 in String format. The return value will be an int array with the following:

Parameters:
sInputIP - is the String value representing a 32-bit IP address.
Returns:
an int array containing all the 8-bit integer values from the String value input. If parsin errors occur, each cell of the return int array will contain the values -1.

updateLastUpdateForNode

public void updateLastUpdateForNode(String inputIP,
                                    int inNewUpdate)
This method will update the last update status for a particular node.

Parameters:
inputIP - represents the node which is to be updated
inNewUpdate - is the update status for the node. See FENode.getLastUpdateStatus() for more details.

updateLastUpdateForNode

public void updateLastUpdateForNode(JLabel inputLabel,
                                    int inNewUpdate)
This method will update the last update status for a particular node.

Parameters:
inputLabel - represents the node which is being updated.
inNewUpdate - is the update status for the node. See FENode.getLastUpdateStatus() for more details.