public int getLeadingBitCount ( boolean network ) { int count = getDivisionCount ( ) ; if ( count == 0 ) { return 0 ; } long front = network ? getDivision ( 0 ) . getMaxValue ( ) : 0 ; int prefixLen = 0 ; for ( int i = 0 ; i < count ; i ++ ) { IPAddressDivision seg = getDivision ( i ) ; long value = seg . getDivisionValue ( ) ; if ( value != front ) { return prefixLen + seg . getLeadingBitCount ( network ) ; } prefixLen += seg . getBitCount ( ) ; } return prefixLen ; }
Returns the number of consecutive leading one or zero bits . If network is true returns the number of consecutive leading one bits . Otherwise returns the number of consecutive leading zero bits .