[cooja] plugins/analyzers: Added @Override annotations

This commit is contained in:
Enrico Joerns 2014-07-11 02:14:46 +02:00
parent 3e9a780721
commit e16a5d65df
5 changed files with 41 additions and 0 deletions

View file

@ -187,6 +187,7 @@ public class RadioLogger extends VisPlugin {
private static final long serialVersionUID = 1692207305977527004L; private static final long serialVersionUID = 1692207305977527004L;
@Override
public String getColumnName(int col) { public String getColumnName(int col) {
if (col == COLUMN_TIME && formatTimeString) { if (col == COLUMN_TIME && formatTimeString) {
return "Time"; return "Time";
@ -194,14 +195,17 @@ public class RadioLogger extends VisPlugin {
return COLUMN_NAMES[col]; return COLUMN_NAMES[col];
} }
@Override
public int getRowCount() { public int getRowCount() {
return connections.size(); return connections.size();
} }
@Override
public int getColumnCount() { public int getColumnCount() {
return COLUMN_NAMES.length; return COLUMN_NAMES.length;
} }
@Override
public Object getValueAt(int row, int col) { public Object getValueAt(int row, int col) {
if (row < 0 || row >= connections.size()) { if (row < 0 || row >= connections.size()) {
return ""; return "";
@ -247,6 +251,7 @@ public class RadioLogger extends VisPlugin {
return null; return null;
} }
@Override
public boolean isCellEditable(int row, int col) { public boolean isCellEditable(int row, int col) {
if (col == COLUMN_FROM) { if (col == COLUMN_FROM) {
/* Highlight source */ /* Highlight source */
@ -265,6 +270,7 @@ public class RadioLogger extends VisPlugin {
return false; return false;
} }
@Override
public Class<?> getColumnClass(int c) { public Class<?> getColumnClass(int c) {
return getValueAt(0, c).getClass(); return getValueAt(0, c).getClass();
} }
@ -274,6 +280,7 @@ public class RadioLogger extends VisPlugin {
private static final long serialVersionUID = -2199726885069809686L; private static final long serialVersionUID = -2199726885069809686L;
@Override
public String getToolTipText(MouseEvent e) { public String getToolTipText(MouseEvent e) {
java.awt.Point p = e.getPoint(); java.awt.Point p = e.getPoint();
int rowIndex = rowAtPoint(p); int rowIndex = rowAtPoint(p);
@ -328,6 +335,7 @@ public class RadioLogger extends VisPlugin {
/* Toggle time format */ /* Toggle time format */
dataTable.getTableHeader().addMouseListener(new MouseAdapter() { dataTable.getTableHeader().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
int colIndex = dataTable.columnAtPoint(e.getPoint()); int colIndex = dataTable.columnAtPoint(e.getPoint());
int columnIndex = dataTable.convertColumnIndexToModel(colIndex); int columnIndex = dataTable.convertColumnIndexToModel(colIndex);
@ -342,6 +350,7 @@ public class RadioLogger extends VisPlugin {
}); });
dataTable.addKeyListener(new KeyAdapter() { dataTable.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SPACE) { if (e.getKeyCode() == KeyEvent.VK_SPACE) {
showInAllAction.actionPerformed(null); showInAllAction.actionPerformed(null);
@ -366,6 +375,7 @@ public class RadioLogger extends VisPlugin {
dataTable.setRowSorter(logFilter); dataTable.setRowSorter(logFilter);
dataTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { dataTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) { public void valueChanged(ListSelectionEvent e) {
int row = dataTable.getSelectedRow(); int row = dataTable.getSelectedRow();
if (row < 0) { if (row < 0) {
@ -394,11 +404,13 @@ public class RadioLogger extends VisPlugin {
payloadMenu.add(new JMenuItem(aliasAction)); payloadMenu.add(new JMenuItem(aliasAction));
payloadMenu.add(new JCheckBoxMenuItem(showDuplicatesAction) { payloadMenu.add(new JCheckBoxMenuItem(showDuplicatesAction) {
@Override
public boolean isSelected() { public boolean isSelected() {
return showDuplicates; return showDuplicates;
} }
}); });
payloadMenu.add(new JCheckBoxMenuItem(hideNoDestinationAction) { payloadMenu.add(new JCheckBoxMenuItem(hideNoDestinationAction) {
@Override
public boolean isSelected() { public boolean isSelected() {
return hideNoDestinationPackets; return hideNoDestinationPackets;
} }
@ -469,6 +481,7 @@ public class RadioLogger extends VisPlugin {
/* Search text field */ /* Search text field */
searchField.setVisible(false); searchField.setVisible(false);
searchField.addKeyListener(new KeyAdapter() { searchField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) { if (e.getKeyCode() == KeyEvent.VK_ENTER) {
searchSelectNext( searchSelectNext(
@ -494,6 +507,7 @@ public class RadioLogger extends VisPlugin {
adjuster.packColumns(); adjuster.packColumns();
radioMedium.addRadioMediumObserver(radioMediumObserver = new Observer() { radioMedium.addRadioMediumObserver(radioMediumObserver = new Observer() {
@Override
public void update(Observable obs, Object obj) { public void update(Observable obs, Object obj) {
RadioConnection conn = radioMedium.getLastConnection(); RadioConnection conn = radioMedium.getLastConnection();
if (conn == null) { if (conn == null) {
@ -505,6 +519,7 @@ public class RadioLogger extends VisPlugin {
loggedConn.connection = conn; loggedConn.connection = conn;
loggedConn.packet = conn.getSource().getLastPacketTransmitted(); loggedConn.packet = conn.getSource().getLastPacketTransmitted();
java.awt.EventQueue.invokeLater(new Runnable() { java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
int lastSize = connections.size(); int lastSize = connections.size();
// Check if the last row is visible // Check if the last row is visible
@ -536,6 +551,7 @@ public class RadioLogger extends VisPlugin {
} }
} }
@Override
public void startPlugin() { public void startPlugin() {
super.startPlugin(); super.startPlugin();
rebuildAllEntries(); rebuildAllEntries();
@ -583,6 +599,7 @@ public class RadioLogger extends VisPlugin {
*/ */
public void trySelectTime(final long time) { public void trySelectTime(final long time) {
java.awt.EventQueue.invokeLater(new Runnable() { java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
if (dataTable.getRowCount() == 0) { if (dataTable.getRowCount() == 0) {
return; return;
@ -614,6 +631,7 @@ public class RadioLogger extends VisPlugin {
try { try {
logFilter.setRowFilter(null); logFilter.setRowFilter(null);
RowFilter<Object, Object> filter = new RowFilter<Object, Object>() { RowFilter<Object, Object> filter = new RowFilter<Object, Object>() {
@Override
public boolean include(RowFilter.Entry<? extends Object, ? extends Object> entry) { public boolean include(RowFilter.Entry<? extends Object, ? extends Object> entry) {
int row = (Integer) entry.getIdentifier(); int row = (Integer) entry.getIdentifier();
RadioConnectionLog current = connections.get(row); RadioConnectionLog current = connections.get(row);
@ -760,12 +778,14 @@ public class RadioLogger extends VisPlugin {
} }
} }
@Override
public void closePlugin() { public void closePlugin() {
if (radioMediumObserver != null) { if (radioMediumObserver != null) {
radioMedium.deleteRadioMediumObserver(radioMediumObserver); radioMedium.deleteRadioMediumObserver(radioMediumObserver);
} }
} }
@Override
public Collection<Element> getConfigXML() { public Collection<Element> getConfigXML() {
ArrayList<Element> config = new ArrayList<Element>(); ArrayList<Element> config = new ArrayList<Element>();
@ -812,6 +832,7 @@ public class RadioLogger extends VisPlugin {
return config; return config;
} }
@Override
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) { public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
for (Element element : configXML) { for (Element element : configXML) {
String name = element.getName(); String name = element.getName();
@ -835,6 +856,7 @@ public class RadioLogger extends VisPlugin {
final Action action; final Action action;
if (analyzerName != null && ((action = analyzerMap.get(analyzerName)) != null)) { if (analyzerName != null && ((action = analyzerMap.get(analyzerName)) != null)) {
java.awt.EventQueue.invokeLater(new Runnable() { java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
action.putValue(Action.SELECTED_KEY, Boolean.TRUE); action.putValue(Action.SELECTED_KEY, Boolean.TRUE);
action.actionPerformed(null); action.actionPerformed(null);
@ -862,6 +884,7 @@ public class RadioLogger extends VisPlugin {
String data = null; String data = null;
String tooltip = null; String tooltip = null;
@Override
public String toString() { public String toString() {
if (data == null) { if (data == null) {
RadioLogger.this.prepareDataString(this); RadioLogger.this.prepareDataString(this);
@ -906,6 +929,7 @@ public class RadioLogger extends VisPlugin {
Action action = new AbstractAction(name) { Action action = new AbstractAction(name) {
private static final long serialVersionUID = -608913700422638454L; private static final long serialVersionUID = -608913700422638454L;
@Override
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
if (analyzers != analyzerList) { if (analyzers != analyzerList) {
analyzers = analyzerList; analyzers = analyzerList;
@ -922,6 +946,7 @@ public class RadioLogger extends VisPlugin {
private Action clearAction = new AbstractAction("Clear") { private Action clearAction = new AbstractAction("Clear") {
private static final long serialVersionUID = -6135583266684643117L; private static final long serialVersionUID = -6135583266684643117L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int size = connections.size(); int size = connections.size();
if (size > 0) { if (size > 0) {
@ -935,6 +960,7 @@ public class RadioLogger extends VisPlugin {
private Action copyAction = new AbstractAction("Copy selected") { private Action copyAction = new AbstractAction("Copy selected") {
private static final long serialVersionUID = 8412062977916108054L; private static final long serialVersionUID = 8412062977916108054L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
@ -954,6 +980,7 @@ public class RadioLogger extends VisPlugin {
private Action copyAllAction = new AbstractAction("Copy all") { private Action copyAllAction = new AbstractAction("Copy all") {
private static final long serialVersionUID = 1905586689441157304L; private static final long serialVersionUID = 1905586689441157304L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
@ -970,6 +997,7 @@ public class RadioLogger extends VisPlugin {
private Action saveAction = new AbstractAction("Save to file...") { private Action saveAction = new AbstractAction("Save to file...") {
private static final long serialVersionUID = -3942984643211482179L; private static final long serialVersionUID = -3942984643211482179L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser(); JFileChooser fc = new JFileChooser();
int returnVal = fc.showSaveDialog(Cooja.getTopParentContainer()); int returnVal = fc.showSaveDialog(Cooja.getTopParentContainer());
@ -1014,6 +1042,7 @@ public class RadioLogger extends VisPlugin {
private Action timeLineAction = new AbstractAction("Timeline") { private Action timeLineAction = new AbstractAction("Timeline") {
private static final long serialVersionUID = -4035633464748224192L; private static final long serialVersionUID = -4035633464748224192L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int selectedRow = dataTable.getSelectedRow(); int selectedRow = dataTable.getSelectedRow();
if (selectedRow < 0) return; if (selectedRow < 0) return;
@ -1038,6 +1067,7 @@ public class RadioLogger extends VisPlugin {
private Action logListenerAction = new AbstractAction("Mote output") { private Action logListenerAction = new AbstractAction("Mote output") {
private static final long serialVersionUID = 1985006491187878651L; private static final long serialVersionUID = 1985006491187878651L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int selectedRow = dataTable.getSelectedRow(); int selectedRow = dataTable.getSelectedRow();
if (selectedRow < 0) return; if (selectedRow < 0) return;
@ -1066,6 +1096,7 @@ public class RadioLogger extends VisPlugin {
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true)); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true));
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
timeLineAction.actionPerformed(null); timeLineAction.actionPerformed(null);
logListenerAction.actionPerformed(null); logListenerAction.actionPerformed(null);
@ -1076,6 +1107,7 @@ public class RadioLogger extends VisPlugin {
private Action aliasAction = new AbstractAction("Payload alias...") { private Action aliasAction = new AbstractAction("Payload alias...") {
private static final long serialVersionUID = -1678771087456128721L; private static final long serialVersionUID = -1678771087456128721L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int selectedRow = dataTable.getSelectedRow(); int selectedRow = dataTable.getSelectedRow();
if (selectedRow < 0) return; if (selectedRow < 0) return;
@ -1127,6 +1159,7 @@ public class RadioLogger extends VisPlugin {
private boolean showDuplicates = false; private boolean showDuplicates = false;
private AbstractAction showDuplicatesAction = new AbstractAction("Show duplicates") { private AbstractAction showDuplicatesAction = new AbstractAction("Show duplicates") {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
showDuplicates = !showDuplicates; showDuplicates = !showDuplicates;
rebuildAllEntries(); rebuildAllEntries();
@ -1135,6 +1168,7 @@ public class RadioLogger extends VisPlugin {
private boolean hideNoDestinationPackets = false; private boolean hideNoDestinationPackets = false;
private AbstractAction hideNoDestinationAction = new AbstractAction("Hide airshots") { private AbstractAction hideNoDestinationAction = new AbstractAction("Hide airshots") {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
hideNoDestinationPackets = !hideNoDestinationPackets; hideNoDestinationPackets = !hideNoDestinationPackets;
rebuildAllEntries(); rebuildAllEntries();

View file

@ -38,6 +38,7 @@ public class ICMPv6Analyzer extends PacketAnalyzer {
"NEIGHBOR_SOLICITATION", "NEIGHBOR_ADVERTISEMENT", "REDIRECT", "NEIGHBOR_SOLICITATION", "NEIGHBOR_ADVERTISEMENT", "REDIRECT",
"ROUTER RENUMBER", "NODE INFORMATION QUERY", "NODE INFORMATION RESPONSE"}; "ROUTER RENUMBER", "NODE INFORMATION QUERY", "NODE INFORMATION RESPONSE"};
@Override
public int analyzePacket(Packet packet, StringBuffer brief, public int analyzePacket(Packet packet, StringBuffer brief,
StringBuffer verbose) { StringBuffer verbose) {
int type = packet.get(0) & 0xff; int type = packet.get(0) & 0xff;

View file

@ -47,6 +47,7 @@ public class IEEE802154Analyzer extends PacketAnalyzer {
} }
} }
@Override
public boolean matchPacket(Packet packet) { public boolean matchPacket(Packet packet) {
return packet.level == MAC_LEVEL; return packet.level == MAC_LEVEL;
} }
@ -59,6 +60,7 @@ public class IEEE802154Analyzer extends PacketAnalyzer {
* next handler * next handler
*/ */
@Override
public int analyzePacket(Packet packet, StringBuffer brief, StringBuffer verbose) { public int analyzePacket(Packet packet, StringBuffer brief, StringBuffer verbose) {
if (pcapExporter != null) { if (pcapExporter != null) {

View file

@ -61,10 +61,12 @@ public class IPHCPacketAnalyzer extends PacketAnalyzer {
private static final int IPHC_DISPATCH = 0x60; private static final int IPHC_DISPATCH = 0x60;
/* packet must be on network level && have a IPHC dispatch */ /* packet must be on network level && have a IPHC dispatch */
@Override
public boolean matchPacket(Packet packet) { public boolean matchPacket(Packet packet) {
return packet.level == NETWORK_LEVEL && (packet.get(0) & 0xe0) == IPHC_DISPATCH; return packet.level == NETWORK_LEVEL && (packet.get(0) & 0xe0) == IPHC_DISPATCH;
} }
@Override
public int analyzePacket(Packet packet, StringBuffer brief, public int analyzePacket(Packet packet, StringBuffer brief,
StringBuffer verbose) { StringBuffer verbose) {

View file

@ -13,10 +13,12 @@ public class IPv6PacketAnalyzer extends PacketAnalyzer {
private static final int IPV6_DISPATCH = 0x41; private static final int IPV6_DISPATCH = 0x41;
@Override
public boolean matchPacket(Packet packet) { public boolean matchPacket(Packet packet) {
return packet.level == NETWORK_LEVEL && packet.get(0) == IPV6_DISPATCH; return packet.level == NETWORK_LEVEL && packet.get(0) == IPV6_DISPATCH;
} }
@Override
public int analyzePacket(Packet packet, StringBuffer brief, public int analyzePacket(Packet packet, StringBuffer brief,
StringBuffer verbose) { StringBuffer verbose) {