private boolean isValidIpv4(String testDomain){
  boolean valid=false;
  if (testDomain.length() > 0) {
    if (_dots == 0) {
      try {
        long value;
        if (testDomain.length() > 2 && testDomain.charAt(0) == '0' && testDomain.charAt(1) == 'x') {
          value=Long.parseLong(testDomain.substring(2),16);
        }
 else         if (testDomain.charAt(0) == '0') {
          value=Long.parseLong(testDomain.substring(1),8);
        }
 else {
          value=Long.parseLong(testDomain);
        }
        valid=value <= MAX_NUMERIC_DOMAIN_VALUE && value >= MIN_NUMERIC_DOMAIN_VALUE;
      }
 catch (      NumberFormatException e) {
        valid=false;
      }
    }
 else     if (_dots == 3) {
      String[] parts=CharUtils.splitByDot(testDomain);
      valid=true;
      for (int i=0; i < parts.length && valid; i++) {
        String part=parts[i];
        if (part.length() > 0) {
          String parsedNum;
          int base;
          if (part.length() > 2 && part.charAt(0) == '0' && part.charAt(1) == 'x') {
            parsedNum=part.substring(2);
            base=16;
          }
 else           if (part.charAt(0) == '0') {
            parsedNum=part.substring(1);
            base=8;
          }
 else {
            parsedNum=part;
            base=10;
          }
          Integer section;
          if (parsedNum.length() == 0) {
            section=0;
          }
 else {
            try {
              section=Integer.parseInt(parsedNum,base);
            }
 catch (            NumberFormatException e) {
              return false;
            }
          }
          if (section < MIN_IP_PART || section > MAX_IP_PART) {
            valid=false;
          }
        }
 else {
          valid=false;
        }
      }
    }
  }
  return valid;
}

private boolean isValidIpv4 ( String testDomain ) { boolean valid = false ; if ( testDomain . length ( ) > 0 ) { if ( _dots == 0 ) { try { long value ; if ( testDomain . length ( ) > 2 && testDomain . charAt ( 0 ) == '0' && testDomain . charAt ( 1 ) == 'x' ) { value = Long . parseLong ( testDomain . substring ( 2 ) , 16 ) ; } else if ( testDomain . charAt ( 0 ) == '0' ) { value = Long . parseLong ( testDomain . substring ( 1 ) , 8 ) ; } else { value = Long . parseLong ( testDomain ) ; } valid = value <= MAX_NUMERIC_DOMAIN_VALUE && value >= MIN_NUMERIC_DOMAIN_VALUE ; } catch ( NumberFormatException e ) { valid = false ; } } else if ( _dots == 3 ) { String [ ] parts = CharUtils . splitByDot ( testDomain ) ; valid = true ; for ( int i = 0 ; i < parts . length && valid ; i ++ ) { String part = parts [ i ] ; if ( part . length ( ) > 0 ) { String parsedNum ; int base ; if ( part . length ( ) > 2 && part . charAt ( 0 ) == '0' && part . charAt ( 1 ) == 'x' ) { parsedNum = part . substring ( 2 ) ; base = 16 ; } else if ( part . charAt ( 0 ) == '0' ) { parsedNum = part . substring ( 1 ) ; base = 8 ; } else { parsedNum = part ; base = 10 ; } Integer section ; if ( parsedNum . length ( ) == 0 ) { section = 0 ; } else { try { section = Integer . parseInt ( parsedNum , base ) ; } catch ( NumberFormatException e ) { return false ; } } if ( section < MIN_IP_PART || section > MAX_IP_PART ) { valid = false ; } } else { valid = false ; } } } } return valid ; }
handles hexadecimal , octal , decimal , dotted decimal , dotted hex , dotted octal .
