@Test public void checkIpAddressTest() throws Exception{ String ipAdress1="1.1"; Assert.assertFalse(valuecheck.checkIpAddress(ipAdress1)); String ipAdress2="1111.1.1.1"; Assert.assertFalse(valuecheck.checkIpAddress(ipAdress2)); String ipAdress3="11.1.1.1"; Assert.assertTrue(valuecheck.checkIpAddress(ipAdress3)); }
public Boolean checkIpAddress(String ipAddress){ Boolean legalValue = true; String[] value = ipAddress.split("\\."); if (value.length!=4){ legalValue = false; } else { for (int i=0;i<value.length;i++){ if (Integer.parseInt(value[i])>255||Integer.parseInt(value[i])<0){ legalValue = false; } } } return legalValue; }
ValueCheck { public Boolean checkIpAddress(String ipAddress){ Boolean legalValue = true; String[] value = ipAddress.split("\\."); if (value.length!=4){ legalValue = false; } else { for (int i=0;i<value.length;i++){ if (Integer.parseInt(value[i])>255||Integer.parseInt(value[i])<0){ legalValue = false; } } } return legalValue; } }
ValueCheck { public Boolean checkIpAddress(String ipAddress){ Boolean legalValue = true; String[] value = ipAddress.split("\\."); if (value.length!=4){ legalValue = false; } else { for (int i=0;i<value.length;i++){ if (Integer.parseInt(value[i])>255||Integer.parseInt(value[i])<0){ legalValue = false; } } } return legalValue; }  }
ValueCheck { public Boolean checkIpAddress(String ipAddress){ Boolean legalValue = true; String[] value = ipAddress.split("\\."); if (value.length!=4){ legalValue = false; } else { for (int i=0;i<value.length;i++){ if (Integer.parseInt(value[i])>255||Integer.parseInt(value[i])<0){ legalValue = false; } } } return legalValue; }  boolean checkMac(String macAddress); Boolean checkIpPrefix(String ipPrefix); Boolean checkIpAddress(String ipAddress); Boolean checkTime(String time); }
ValueCheck { public Boolean checkIpAddress(String ipAddress){ Boolean legalValue = true; String[] value = ipAddress.split("\\."); if (value.length!=4){ legalValue = false; } else { for (int i=0;i<value.length;i++){ if (Integer.parseInt(value[i])>255||Integer.parseInt(value[i])<0){ legalValue = false; } } } return legalValue; }  boolean checkMac(String macAddress); Boolean checkIpPrefix(String ipPrefix); Boolean checkIpAddress(String ipAddress); Boolean checkTime(String time);  }