mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
some code cleanup
This commit is contained in:
parent
34f410cda6
commit
c7d8135ea0
@ -41,7 +41,7 @@ public final class Labels {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
public static final Labels getInstance() {
|
||||
public static Labels getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ public class NamedListConfig implements Iterable<String> {
|
||||
* Stores the currently available named list
|
||||
*/
|
||||
public void store() {
|
||||
StringBuffer sb = new StringBuffer(32);
|
||||
StringBuilder sb = new StringBuilder(32);
|
||||
for (Map.Entry<String, Object> e : namedList.entrySet()) {
|
||||
sb.append(e.getKey()).append("###").append(e.getValue()).append("###");
|
||||
}
|
||||
@ -109,8 +109,8 @@ public class NamedListConfig implements Iterable<String> {
|
||||
public void update(String[] keys) {
|
||||
// rebuild the map (to recreate the new order of elements)
|
||||
Map<String, Object> newList = new LinkedHashMap<String, Object>();
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
newList.put(keys[i], namedList.get(keys[i]));
|
||||
for (String key : keys) {
|
||||
newList.put(key, namedList.get(key));
|
||||
}
|
||||
namedList = newList;
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ public class Platform {
|
||||
public static final boolean WINDOWS = OS_NAME.startsWith("Windows");
|
||||
|
||||
/** Crippled-down version of Windows (no RawSockets, TCP rate limiting, etc */
|
||||
public static final boolean CRIPPLED_WINDOWS = WINDOWS && OS_NAME.indexOf("Server") < 0 && Double.parseDouble(System.getProperty("os.version").substring(0, 3)) >= 5.1;
|
||||
public static final boolean CRIPPLED_WINDOWS = WINDOWS && !OS_NAME.contains("Server") && Double.parseDouble(System.getProperty("os.version").substring(0, 3)) >= 5.1;
|
||||
|
||||
/** GNU Java, based on GIJ/GCC and GNU Classpath projects */
|
||||
public static final boolean GNU_JAVA = System.getProperty("java.vm.vendor").contains("Free Software Foundation");
|
||||
|
||||
@ -5,13 +5,13 @@
|
||||
*/
|
||||
package net.azib.ipscan.core;
|
||||
|
||||
import net.azib.ipscan.fetchers.Fetcher;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.azib.ipscan.fetchers.Fetcher;
|
||||
|
||||
/**
|
||||
* The holder of scanning result for a single IP address.
|
||||
*
|
||||
@ -114,7 +114,7 @@ public class ScanningResult {
|
||||
// cross-platform newline :-)
|
||||
String newLine = System.getProperty("line.separator");
|
||||
|
||||
StringBuffer details = new StringBuffer(1024);
|
||||
StringBuilder details = new StringBuilder(1024);
|
||||
Iterator<?> iterator = getValues().iterator();
|
||||
List<Fetcher> fetchers = resultList.getFetchers();
|
||||
for (int i = 0; iterator.hasNext(); i++) {
|
||||
|
||||
@ -43,7 +43,7 @@ public class NumericRangeList implements Comparable<NumericRangeList> {
|
||||
* Outputs nice, human-friendly numeric list, displayed either as ranges or fully
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
int prevNumber = Integer.MAX_VALUE;
|
||||
int rangeStartNumber = 0;
|
||||
|
||||
@ -22,9 +22,9 @@ public class ExporterRegistry implements Iterable<Exporter> {
|
||||
|
||||
public ExporterRegistry(Exporter[] registeredExporters) {
|
||||
exporters = new LinkedHashMap<String, Exporter>();
|
||||
|
||||
for (int i = 0; i < registeredExporters.length; i++) {
|
||||
exporters.put(registeredExporters[i].getFilenameExtension(), registeredExporters[i]);
|
||||
|
||||
for (Exporter exporter : registeredExporters) {
|
||||
exporters.put(exporter.getFilenameExtension(), exporter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,19 +8,12 @@ package net.azib.ipscan.gui;
|
||||
import net.azib.ipscan.config.Labels;
|
||||
import net.azib.ipscan.config.Platform;
|
||||
import net.azib.ipscan.gui.util.LayoutHelper;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.FormAttachment;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.*;
|
||||
|
||||
/**
|
||||
* This is the base of a modal dialog window
|
||||
@ -193,10 +186,8 @@ public abstract class AbstractModalDialog {
|
||||
}
|
||||
|
||||
int[] selectedItems = list.getSelectionIndices();
|
||||
for (int i = 0; i < selectedItems.length; i++) {
|
||||
for (int index : selectedItems) {
|
||||
// here, index is always > 0
|
||||
int index = selectedItems[i];
|
||||
|
||||
list.deselect(index);
|
||||
String oldItem = list.getItem(index - 1);
|
||||
list.setItem(index - 1, list.getItem(index));
|
||||
|
||||
@ -84,9 +84,8 @@ public class ResultTable extends Table implements FetcherRegistryUpdateListener,
|
||||
removeAll();
|
||||
|
||||
// remove all columns
|
||||
TableColumn[] columns = getColumns();
|
||||
for (int i = 0; i < columns.length; i++) {
|
||||
columns[i].dispose();
|
||||
for (TableColumn column : getColumns()) {
|
||||
column.dispose();
|
||||
}
|
||||
|
||||
// add the new selected columns back
|
||||
|
||||
@ -5,26 +5,19 @@
|
||||
*/
|
||||
package net.azib.ipscan.gui;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import net.azib.ipscan.config.Labels;
|
||||
import net.azib.ipscan.fetchers.Fetcher;
|
||||
import net.azib.ipscan.fetchers.FetcherRegistry;
|
||||
import net.azib.ipscan.fetchers.IPFetcher;
|
||||
import net.azib.ipscan.gui.util.LayoutHelper;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.FormAttachment;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* SelectFetchersDialog
|
||||
@ -189,8 +182,8 @@ public class SelectFetchersDialog extends AbstractModalDialog {
|
||||
int[] selectedItems = fromList.getSelectionIndices();
|
||||
|
||||
// first, add items back to the registered list
|
||||
for (int i = 0; i < selectedItems.length; i++) {
|
||||
toList.add(fromList.getItem(selectedItems[i]));
|
||||
for (int selectedItem : selectedItems) {
|
||||
toList.add(fromList.getItem(selectedItem));
|
||||
}
|
||||
|
||||
// now, add remove the items
|
||||
|
||||
@ -178,7 +178,7 @@ public class CommandsMenuActions {
|
||||
}
|
||||
|
||||
menuItem.setText(name);
|
||||
menuItem.setData(new Integer(index));
|
||||
menuItem.setData(index);
|
||||
menuItem.addListener(SWT.Selection, openersSelectListener);
|
||||
}
|
||||
|
||||
|
||||
@ -7,12 +7,11 @@ package net.azib.ipscan.gui.actions;
|
||||
|
||||
import net.azib.ipscan.config.Labels;
|
||||
import net.azib.ipscan.core.ScanningResult;
|
||||
import net.azib.ipscan.core.ScanningResultList;
|
||||
import net.azib.ipscan.core.ScanningResult.ResultType;
|
||||
import net.azib.ipscan.core.ScanningResultList;
|
||||
import net.azib.ipscan.gui.InputDialog;
|
||||
import net.azib.ipscan.gui.ResultTable;
|
||||
import net.azib.ipscan.gui.StatusBar;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
@ -150,7 +149,7 @@ public class GotoMenuActions {
|
||||
}
|
||||
}
|
||||
|
||||
private final void findText(String text, Shell activeShell) {
|
||||
private void findText(String text, Shell activeShell) {
|
||||
ScanningResultList results = resultTable.getScanningResults();
|
||||
|
||||
int startIndex = resultTable.getSelectionIndex() + 1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user