private static String isValidU32(String text, String errorMessage) { String msg = null; if (text.trim().length() > 0) { try { StringUtils.parseU32(text); } catch (NumberFormatException e) { msg = errorMessage; } } return msg; }
private StackFilter createStackFilter() throws NumberFormatException { StackFilter filter; boolean exclude; String str; String strFrom; String strTo; int num; int from; int to; filter = new StackFilter(); str = stackOwnerIdText.getText().trim(); if (str.length() > 0) { exclude = stackOwnerIdCheckbox.getSelection(); num = StringUtils.parseU32(str); filter.filterOwnerId(exclude, num); } str = stackOwnerNameText.getText().trim(); if (str.length() > 0) { exclude = stackOwnerNameCheckbox.getSelection(); filter.filterOwnerName(exclude, str); } strFrom = stackSizeFromText.getText().trim(); strTo = stackSizeToText.getText().trim(); if ((strFrom.length() > 0) || (strTo.length() > 0)) { exclude = stackSizeCheckbox.getSelection(); from = (strFrom.length() > 0) ? StringUtils.parseU32(strFrom) : 0; to = (strTo.length() > 0) ? StringUtils.parseU32(strTo) : 0xFFFFFFFF; filter.filterSize(exclude, from, to); } strFrom = stackBufferSizeFromText.getText().trim(); strTo = stackBufferSizeToText.getText().trim(); if ((strFrom.length() > 0) || (strTo.length() > 0)) { exclude = stackBufferSizeCheckbox.getSelection(); from = (strFrom.length() > 0) ? StringUtils.parseU32(strFrom) : 0; to = (strTo.length() > 0) ? StringUtils.parseU32(strTo) : 0xFFFFFFFF; filter.filterBufferSize(exclude, from, to); } strFrom = stackAddressFromText.getText().trim(); strTo = stackAddressToText.getText().trim(); if ((strFrom.length() > 0) || (strTo.length() > 0)) { exclude = stackAddressCheckbox.getSelection(); from = (strFrom.length() > 0) ? StringUtils.parseU32(strFrom) : 0; to = (strTo.length() > 0) ? StringUtils.parseU32(strTo) : 0xFFFFFFFF; filter.filterAddress(exclude, from, to); } strFrom = stackUsedFromText.getText().trim(); strTo = stackUsedToText.getText().trim(); if ((strFrom.length() > 0) || (strTo.length() > 0)) { exclude = stackUsedCheckbox.getSelection(); from = (strFrom.length() > 0) ? StringUtils.parseU32(strFrom) : 0; to = (strTo.length() > 0) ? StringUtils.parseU32(strTo) : 0xFFFFFFFF; filter.filterUsed(exclude, from, to); } strFrom = stackUnusedFromText.getText().trim(); strTo = stackUnusedToText.getText().trim(); if ((strFrom.length() > 0) || (strTo.length() > 0)) { exclude = stackUnusedCheckbox.getSelection(); from = (strFrom.length() > 0) ? StringUtils.parseU32(strFrom) : 0; to = (strTo.length() > 0) ? StringUtils.parseU32(strTo) : 0xFFFFFFFF; filter.filterUnused(exclude, from, to); } return filter; }
private SignalFilter createSignalFilter() throws NumberFormatException { SignalFilter filter; boolean exclude; String str; String strFrom; String strTo; int num; int from; int to; filter = new SignalFilter(); strFrom = signalNumberFromText.getText().trim(); strTo = signalNumberToText.getText().trim(); if ((strFrom.length() > 0) || (strTo.length() > 0)) { exclude = signalNumberCheckbox.getSelection(); from = (strFrom.length() > 0) ? StringUtils.parseU32(strFrom) : 0; to = (strTo.length() > 0) ? StringUtils.parseU32(strTo) : 0xFFFFFFFF; filter.filterNumber(exclude, from, to); } str = signalOwnerIdText.getText().trim(); if (str.length() > 0) { exclude = signalOwnerIdCheckbox.getSelection(); num = StringUtils.parseU32(str); filter.filterOwnerId(exclude, num); } str = signalOwnerNameText.getText().trim(); if (str.length() > 0) { exclude = signalOwnerNameCheckbox.getSelection(); filter.filterOwnerName(exclude, str); } str = signalSenderIdText.getText().trim(); if (str.length() > 0) { exclude = signalSenderIdCheckbox.getSelection(); num = StringUtils.parseU32(str); filter.filterSenderId(exclude, num); } str = signalSenderNameText.getText().trim(); if (str.length() > 0) { exclude = signalSenderNameCheckbox.getSelection(); filter.filterSenderName(exclude, str); } str = signalAddresseeIdText.getText().trim(); if (str.length() > 0) { exclude = signalAddresseeIdCheckbox.getSelection(); num = StringUtils.parseU32(str); filter.filterAddresseeId(exclude, num); } str = signalAddresseeNameText.getText().trim(); if (str.length() > 0) { exclude = signalAddresseeNameCheckbox.getSelection(); filter.filterAddresseeName(exclude, str); } strFrom = signalSizeFromText.getText().trim(); strTo = signalSizeToText.getText().trim(); if ((strFrom.length() > 0) || (strTo.length() > 0)) { exclude = signalSizeCheckbox.getSelection(); from = (strFrom.length() > 0) ? StringUtils.parseU32(strFrom) : 0; to = (strTo.length() > 0) ? StringUtils.parseU32(strTo) : 0xFFFFFFFF; filter.filterSize(exclude, from, to); } strFrom = signalBufferSizeFromText.getText().trim(); strTo = signalBufferSizeToText.getText().trim(); if ((strFrom.length() > 0) || (strTo.length() > 0)) { exclude = signalBufferSizeCheckbox.getSelection(); from = (strFrom.length() > 0) ? StringUtils.parseU32(strFrom) : 0; to = (strTo.length() > 0) ? StringUtils.parseU32(strTo) : 0xFFFFFFFF; filter.filterBufferSize(exclude, from, to); } strFrom = signalAddressFromText.getText().trim(); strTo = signalAddressToText.getText().trim(); if ((strFrom.length() > 0) || (strTo.length() > 0)) { exclude = signalAddressCheckbox.getSelection(); from = (strFrom.length() > 0) ? StringUtils.parseU32(strFrom) : 0; to = (strTo.length() > 0) ? StringUtils.parseU32(strTo) : 0xFFFFFFFF; filter.filterAddress(exclude, from, to); } str = signalStatusCombo.getText(); if (str.length() > 0) { exclude = signalStatusCheckbox.getSelection(); if (str.equals(SIGNAL_STATUS_VALID_STR)) { num = SignalInfo.STATUS_VALID; } else if (str.equals(SIGNAL_STATUS_ENDMARK_STR)) { num = SignalInfo.STATUS_ENDMARK; } else if (str.equals(SIGNAL_STATUS_ADMINISTRATION_STR)) { num = SignalInfo.STATUS_ADMINISTRATION; } else if (str.equals(SIGNAL_STATUS_NOT_A_SIGNAL_STR)) { num = SignalInfo.STATUS_NOT_A_SIGNAL; } else if (str.equals(SIGNAL_STATUS_NOT_A_POOL_STR)) { num = SignalInfo.STATUS_NOT_A_POOL; } else if (str.equals(SIGNAL_STATUS_FREE_STR)) { num = SignalInfo.STATUS_FREE; } else { num = SignalInfo.STATUS_UNKNOWN; } filter.filterStatus(exclude, num); } return filter; }
private int createPoolId() throws NumberFormatException { String str = poolIdText.getText().trim(); int result = (str.length() > 0) ? StringUtils.parseU32(str) : 0; return result; }