public PluralRules getRulesForRulesId ( String rulesId ) { // synchronize on the map. release the lock temporarily while we build the rules. PluralRules rules = null ; boolean hasRules ; // Separate boolean because stored rules can be null. synchronized ( rulesIdToRules ) { hasRules = rulesIdToRules . containsKey ( rulesId ) ; if ( hasRules ) { rules = rulesIdToRules . get ( rulesId ) ; // can be null } } if ( ! hasRules ) { try { UResourceBundle pluralb = getPluralBundle ( ) ; UResourceBundle rulesb = pluralb . get ( "rules" ) ; UResourceBundle setb = rulesb . get ( rulesId ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < setb . getSize ( ) ; ++ i ) { UResourceBundle b = setb . get ( i ) ; if ( i > 0 ) { sb . append ( "; " ) ; } sb . append ( b . getKey ( ) ) ; sb . append ( ": " ) ; sb . append ( b . getString ( ) ) ; } rules = PluralRules . parseDescription ( sb . toString ( ) ) ; } catch ( ParseException e ) { } catch ( MissingResourceException e ) { } synchronized ( rulesIdToRules ) { if ( rulesIdToRules . containsKey ( rulesId ) ) { rules = rulesIdToRules . get ( rulesId ) ; } else { rulesIdToRules . put ( rulesId , rules ) ; // can be null } } } return rules ; }
Gets the rule from the rulesId . If there is no rule for this rulesId return null .