final void parseRange ( String range ) { if ( range == null ) { throw new IllegalArgumentException ( "Invalid IP range" ) ; } int index = range . indexOf ( ' ' ) ; String subnetStr = null ; if ( index == - 1 ) { ipAddress = new IPAddress ( range ) ; } else { ipAddress = new IPAddress ( range . substring ( 0 , index ) ) ; subnetStr = range . substring ( index + 1 ) ; } // try to convert the remaining part of the range into a decimal // value. try { if ( subnetStr != null ) { extendedNetworkPrefix = Integer . parseInt ( subnetStr ) ; if ( ( extendedNetworkPrefix < 0 ) || ( extendedNetworkPrefix > 32 ) ) { throw new IllegalArgumentException ( "Invalid IP range [" + range + "]" ) ; } ipSubnetMask = computeMaskFromNetworkPrefix ( extendedNetworkPrefix ) ; } } catch ( NumberFormatException ex ) { // the remaining part is not a valid decimal value. // Check if it's a decimal-dotted notation. ipSubnetMask = new IPAddress ( subnetStr ) ; // create the corresponding subnet decimal extendedNetworkPrefix = computeNetworkPrefixFromMask ( ipSubnetMask ) ; if ( extendedNetworkPrefix == - 1 ) { throw new IllegalArgumentException ( "Invalid IP range [" + range + "]" , ex ) ; } } }
Parse the IP range string representation .