private static int compareLocales(Locale primary,Locale other){
  final String lang=primary.getLanguage();
  if ((lang == null) || !lang.equals(other.getLanguage())) {
    return 0;
  }
  final String country=primary.getCountry();
  if ((country == null) || !country.equals(other.getCountry())) {
    return 1;
  }
  final String variant=primary.getVariant();
  if ((variant == null) || !variant.equals(other.getVariant())) {
    return 2;
  }
  return 3;
}

private static int compareLocales ( Locale primary , Locale other ) { final String lang = primary . getLanguage ( ) ; if ( ( lang == null ) || ! lang . equals ( other . getLanguage ( ) ) ) { return 0 ; } final String country = primary . getCountry ( ) ; if ( ( country == null ) || ! country . equals ( other . getCountry ( ) ) ) { return 1 ; } final String variant = primary . getVariant ( ) ; if ( ( variant == null ) || ! variant . equals ( other . getVariant ( ) ) ) { return 2 ; } return 3 ; }
compares a locale against a primary locale . returns higher values for closer matches . a return value of 3 indicates that the locale is an exact match for the primary locale ' s language , country , and variant .
