public List<ScannerResult> data() { List<ScannerResult> returnData = new ArrayList<ScannerResult>(); List<String> protocolList = getProtocolList(); for (IpAddressPortTuple tuple : ipAddressPortTuples) { for (String protocol : protocolList) { ScannerResult result = new ScannerResult(); result.setPort(tuple.getPort()); result.setProtocol(protocol); result.setIpAddress(tuple.getIpAddress()); result.setService(commonServicesMap.get(tuple.getPort())); returnData.add(result); } } return returnData; }
private List<String> getProtocolList() { List<String> protocolStringSet = new ArrayList<String>(); switch (this.protocol) { case TCP_ONLY: { protocolStringSet.add("TCP"); break; } case UDP_ONLY: { protocolStringSet.add("UDP"); break; } case BOTH: { protocolStringSet.add("TCP"); protocolStringSet.add("UDP"); break; } } return protocolStringSet; }