📄 spotinfotable.java
字号:
e.printStackTrace(SpotSelector.infoOut); } SpotSelector.infoOut.println("Internal error occured. port " + spotInfo.serialPort + " is not a basestation"); return false; } public boolean checkIsOfType(int type, SpotInfo spotInfo) { if (type == SpotInfo.TYPE_BASESTATION) return checkIsBaseStation(spotInfo); if (type == SpotInfo.TYPE_NONBASESTATION) return !checkIsBaseStation(spotInfo); return false; } public void removeExceptTypePort(int type, String port) { if ((port != null) && (!port.equals(""))) { if (isVerbose) SpotSelector.infoOut .println("Verifying if is connected to default port " + port); SpotInfo portSpotInfo = getSpotInfoForPort(port); if (checkIsOfType(type, portSpotInfo)) { spotInfoTableVector.clear(); spotInfoTableVector.add(portSpotInfo); return; } else { if (isVerbose) SpotSelector.infoOut .println("No basestation connected to last port " + port); } } } public void removeExcept(int type, String lastPort) { if ((lastPort != null)) { if (isVerbose) SpotSelector.infoOut .println("Verifying if is connected to last port " + lastPort); SpotInfo lastSpotInfo = getSpotInfoForPort(lastPort); if (checkIsOfType(type, lastSpotInfo)) { spotInfoTableVector.clear(); spotInfoTableVector.add(lastSpotInfo); return; } else { if (isVerbose) SpotSelector.infoOut .println("No basestation connected to last port " + lastPort); } } removeExcept(type, false); } public void removeExcept(int type) { removeExcept(type, true); } public void removeExcept(int type, boolean scanAll) { /* * if ((port != null)&& (!port.equals(""))) { if (isVerbose) * SpotSelector.infoOut.println("Verifying if is connected to default * port " + port); SpotInfo portSpotInfo = getSpotInfoForPort(port); * * if (checkIsOfType(type, portSpotInfo)) { spotInfoTableVector.clear(); * spotInfoTableVector.add(portSpotInfo); return; } else { if * (isVerbose) SpotSelector.infoOut.println("No basestation connected to * last port " + port); } } * * if ((startPort != null) && (!scanAll)) { if (isVerbose) * SpotSelector.infoOut.println("Verifying if is connected to last port " + * startPort); SpotInfo lastSpotInfo = getSpotInfoForPort(startPort); * * if (checkIsOfType(type, lastSpotInfo)) { spotInfoTableVector.clear(); * spotInfoTableVector.add(lastSpotInfo); return; } else { if * (isVerbose) SpotSelector.infoOut.println("No basestation connected to * last port " + startPort); } } */ Iterator it = spotInfoTableVector.iterator(); while (it.hasNext()) { // TODO SpotInfo currentSpot = (SpotInfo) it.next(); if (isVerbose) SpotSelector.infoOut .println("Testing whether spot connected to port " + currentSpot.serialPort + " is a basestation"); if (checkIsOfType(type, currentSpot)) { if (isVerbose) SpotSelector.infoOut.println(currentSpot + " is a basestation.Keep in table"); if (!scanAll) { // if not scanallbasestations is enabled remove all // elements // except the first basestation found. This reduces // the number of (timeconsuming) base station // detections, // in the usual case that the user only has one base // station // connected if (isVerbose) SpotSelector.infoOut .println(currentSpot + " is a basestation. Scanallbasestations is false, thus remove everything execept thise one and return."); spotInfoTableVector.clear(); spotInfoTableVector.add(currentSpot); break; } } else { if (isVerbose) SpotSelector.infoOut.println(currentSpot + " is not a basestation. Removing from Table"); if ((removedDevicesString == null) || removedDevicesString.equals("")) removedDevicesString = currentSpot.toString(); else removedDevicesString += ", " + currentSpot.toString(); it.remove(); } } } public void removeNonBaseStations(String baseStationLastPort, boolean scanAllBaseStations) { // removeExcept(SpotInfo.TYPE_BASESTATION, null, baseStationLastPort, // scanAllBaseStations); if (scanAllBaseStations) removeExcept(SpotInfo.TYPE_BASESTATION); else removeExcept(SpotInfo.TYPE_BASESTATION, baseStationLastPort); } /* * public void removeNonBaseStations(String baseStationLastPort, boolean * scanAllBaseStations) { * * if ((baseStationLastPort != null) && (!scanAllBaseStations)) { if * (isVerbose) SpotSelector.infoOut.println("Verifying if is connected * to default port " + baseStationLastPort); SpotInfo lastBaseStation = * getSpotInfoForPort(baseStationLastPort); * * if (checkIsBaseStation(lastBaseStation)) { * spotInfoTableVector.clear(); * spotInfoTableVector.add(lastBaseStation); return; } else { if * (isVerbose) SpotSelector.infoOut.println("No basestation connected to * last port " + baseStationLastPort); } } * * Iterator it = spotInfoTableVector.iterator(); while (it.hasNext()) { // * TODO SpotInfo currentSpot = (SpotInfo) it.next(); if (isVerbose) * SpotSelector.infoOut.println("Testing whether spot connected to port " + * currentSpot.serialPort + " is a basestation"); * * if (checkIsBaseStation(currentSpot)) { if (isVerbose) * SpotSelector.infoOut.println(currentSpot + " is a basestation.Keep in * table"); if (!scanAllBaseStations) { // if not scanallbasestations is * enabled remove all elements // except the first basestation found. * This reduces // the number of (timeconsuming) base station * detections, // in the usual case that the user only has one base * station // connected if (isVerbose) SpotSelector.infoOut * .println(currentSpot + " is a basestation. Scanallbasestations is * false, thus remove everything execept thise one and return."); * spotInfoTableVector.clear(); spotInfoTableVector.add(currentSpot); * break; } } else { if (isVerbose) * SpotSelector.infoOut.println(currentSpot + " is not a basestation. * Removing from Table"); if ((removedDevicesString == null) || * removedDevicesString.equals("")) removedDevicesString = * currentSpot.toString(); else removedDevicesString += ", " + * currentSpot.toString(); * * it.remove(); } } } */ /** * Retrieves a string containing the devices stripped from the list It's * only intented for providing better error message to the user, and * thus it's only guaranteed to have meaningfull content if the non * appropriate was found when the list was stripped. * * @return removedDevices as a comma separated string */ public String getRemovedDevicesString() { return removedDevicesString; } public boolean containsPort(String serialPort) { if ((serialPort == null) || (serialPort == "")) return false; Iterator it = spotInfoTableVector.iterator(); while (it.hasNext()) { SpotInfo si = (SpotInfo) it.next(); if (si.serialPort.substring(0, 3).equalsIgnoreCase("COM")) { if (si.serialPort.equalsIgnoreCase(serialPort)) return true; } else { if (si.serialPort.equals(serialPort)) return true; } } return false; } public SpotInfo getSpotInfoForPort(String serialPort) { Iterator it = spotInfoTableVector.iterator(); while (it.hasNext()) { SpotInfo si = (SpotInfo) it.next(); if (si.serialPort.substring(0, 3).equalsIgnoreCase("COM")) { if (si.serialPort.equalsIgnoreCase(serialPort)) return si; } else { if (si.serialPort.equals(serialPort)) return si; } } return null; } public String toString() { Iterator it = spotInfoTableVector.iterator(); String s = ""; if (it.hasNext()) s = it.next() + ""; while (it.hasNext()) s += ", " + it.next(); return s; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -