@Test public void checkMacTest() throws Exception{ String macAddress1="11:22:33"; Assert.assertFalse(valuecheck.checkMac(macAddress1)); String macAddress2="11:222:33:44:55:66"; Assert.assertFalse(valuecheck.checkMac(macAddress2)); String macAddress3="1s:22:33:44:55:66"; Assert.assertFalse(valuecheck.checkMac(macAddress3)); String macAddress4="00:00:00:00:00:00"; Assert.assertTrue(valuecheck.checkMac(macAddress4)); }
public boolean checkMac(String macAddress){ Boolean legalValue = true; String[] value = macAddress.split(":"); if (value.length!=6){ legalValue = false; } else { for (int i=0; i<value.length;i++){ if (value[i].length()!=2){ legalValue= false; } else { for (int j=0;j<value[i].length();j++){ char cc = value[i].charAt(j); if(!(cc=='0'||cc=='1'||cc=='2'||cc=='3'||cc=='4'||cc=='5'||cc=='6'||cc=='7'||cc=='8'||cc=='9' ||cc=='A'||cc=='B'||cc=='C'||cc=='D'||cc=='E'||cc=='F' ||cc=='a'||cc=='b'||cc=='c'||cc=='c'||cc=='d'||cc=='e'||cc=='f')){ legalValue = false; } } } } } return legalValue; }
ValueCheck { public boolean checkMac(String macAddress){ Boolean legalValue = true; String[] value = macAddress.split(":"); if (value.length!=6){ legalValue = false; } else { for (int i=0; i<value.length;i++){ if (value[i].length()!=2){ legalValue= false; } else { for (int j=0;j<value[i].length();j++){ char cc = value[i].charAt(j); if(!(cc=='0'||cc=='1'||cc=='2'||cc=='3'||cc=='4'||cc=='5'||cc=='6'||cc=='7'||cc=='8'||cc=='9' ||cc=='A'||cc=='B'||cc=='C'||cc=='D'||cc=='E'||cc=='F' ||cc=='a'||cc=='b'||cc=='c'||cc=='c'||cc=='d'||cc=='e'||cc=='f')){ legalValue = false; } } } } } return legalValue; } }
ValueCheck { public boolean checkMac(String macAddress){ Boolean legalValue = true; String[] value = macAddress.split(":"); if (value.length!=6){ legalValue = false; } else { for (int i=0; i<value.length;i++){ if (value[i].length()!=2){ legalValue= false; } else { for (int j=0;j<value[i].length();j++){ char cc = value[i].charAt(j); if(!(cc=='0'||cc=='1'||cc=='2'||cc=='3'||cc=='4'||cc=='5'||cc=='6'||cc=='7'||cc=='8'||cc=='9' ||cc=='A'||cc=='B'||cc=='C'||cc=='D'||cc=='E'||cc=='F' ||cc=='a'||cc=='b'||cc=='c'||cc=='c'||cc=='d'||cc=='e'||cc=='f')){ legalValue = false; } } } } } return legalValue; }  }
ValueCheck { public boolean checkMac(String macAddress){ Boolean legalValue = true; String[] value = macAddress.split(":"); if (value.length!=6){ legalValue = false; } else { for (int i=0; i<value.length;i++){ if (value[i].length()!=2){ legalValue= false; } else { for (int j=0;j<value[i].length();j++){ char cc = value[i].charAt(j); if(!(cc=='0'||cc=='1'||cc=='2'||cc=='3'||cc=='4'||cc=='5'||cc=='6'||cc=='7'||cc=='8'||cc=='9' ||cc=='A'||cc=='B'||cc=='C'||cc=='D'||cc=='E'||cc=='F' ||cc=='a'||cc=='b'||cc=='c'||cc=='c'||cc=='d'||cc=='e'||cc=='f')){ legalValue = false; } } } } } return legalValue; }  boolean checkMac(String macAddress); Boolean checkIpPrefix(String ipPrefix); Boolean checkIpAddress(String ipAddress); Boolean checkTime(String time); }
ValueCheck { public boolean checkMac(String macAddress){ Boolean legalValue = true; String[] value = macAddress.split(":"); if (value.length!=6){ legalValue = false; } else { for (int i=0; i<value.length;i++){ if (value[i].length()!=2){ legalValue= false; } else { for (int j=0;j<value[i].length();j++){ char cc = value[i].charAt(j); if(!(cc=='0'||cc=='1'||cc=='2'||cc=='3'||cc=='4'||cc=='5'||cc=='6'||cc=='7'||cc=='8'||cc=='9' ||cc=='A'||cc=='B'||cc=='C'||cc=='D'||cc=='E'||cc=='F' ||cc=='a'||cc=='b'||cc=='c'||cc=='c'||cc=='d'||cc=='e'||cc=='f')){ legalValue = false; } } } } } return legalValue; }  boolean checkMac(String macAddress); Boolean checkIpPrefix(String ipPrefix); Boolean checkIpAddress(String ipAddress); Boolean checkTime(String time);  }