mapping.data
Class IDsQueue<Item>

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by mapping.data.IDsQueue<Item>
Type Parameters:
Item - The Type of objects stored in this Queue
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class IDsQueue<Item>
extends javax.swing.table.AbstractTableModel
implements java.io.Serializable

This class is an implementation of a queue (queue to hold the IDs of Servers). It also implements AbstractTableModel to be used by a JTable to show the servers that this queue has their IDs.

Author:
Majd Kokaly
See Also:
Serialized Form

Constructor Summary
IDsQueue()
          Default constructor
IDsQueue(Mapper mapper)
           
 
Method Summary
 void advanceInRoundRobinFashion()
          This method dequeue one element and enqueue it again.
 Item dequeue()
          remove and return the least recently added item
 void enqueue(Item item)
          This method is used to add nodes to the queue.
 int getColumnCount()
           
 java.lang.String getColumnName(int column)
           
 int getRowCount()
           
 Item getVal(int row)
           
 java.lang.Object getValueAt(int row, int column)
          This method is part of the implementation of the AbstractTableModel interface.
 boolean isEmpty()
           
static void main(java.lang.String[] args)
           
 Item peak()
           
 void print()
           
 void printServers()
           
 Item remove(Item item)
          This method remove the object Item if it exists
 void setValueAt(java.lang.Object value, int row, int column)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IDsQueue

public IDsQueue()
Default constructor


IDsQueue

public IDsQueue(Mapper mapper)
Parameters:
mapper - to set the mapper field
Method Detail

printServers

public void printServers()

enqueue

public void enqueue(Item item)
This method is used to add nodes to the queue.

Parameters:
item - is the item to be added

dequeue

public Item dequeue()
remove and return the least recently added item

Returns:
the the oldest item in the queue after removing it.

peak

public Item peak()
Returns:
the the oldest item in the queue.

getVal

public Item getVal(int row)

remove

public Item remove(Item item)
This method remove the object Item if it exists

Parameters:
item - the object to be deleted
Returns:
the item removed

isEmpty

public boolean isEmpty()
Returns:
true if this queue contains no objects, false otherwise

print

public void print()

advanceInRoundRobinFashion

public void advanceInRoundRobinFashion()
This method dequeue one element and enqueue it again.


getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface javax.swing.table.TableModel
See Also:
AbstractTableModel

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface javax.swing.table.TableModel
See Also:
AbstractTableModel

getColumnName

public java.lang.String getColumnName(int column)
Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
See Also:
AbstractTableModel

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
This method is part of the implementation of the AbstractTableModel interface. It shows the server hostname using its ID.

Specified by:
getValueAt in interface javax.swing.table.TableModel
See Also:
AbstractTableModel

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int column)
Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel

main

public static void main(java.lang.String[] args)