private RestrictionLevel getRestrictionLevel ( String input ) { // Section 5.2 step 1: if ( ! fAllowedCharsSet . containsAll ( input ) ) { return RestrictionLevel . UNRESTRICTIVE ; } // Section 5.2 step 2: if ( ASCII . containsAll ( input ) ) { return RestrictionLevel . ASCII ; } // Section 5.2 steps 3: ScriptSet resolvedScriptSet = new ScriptSet ( ) ; getResolvedScriptSet ( input , resolvedScriptSet ) ; // Section 5.2 step 4: if ( ! resolvedScriptSet . isEmpty ( ) ) { return RestrictionLevel . SINGLE_SCRIPT_RESTRICTIVE ; } // Section 5.2 step 5: ScriptSet resolvedNoLatn = new ScriptSet ( ) ; getResolvedScriptSetWithout ( input , UScript . LATIN , resolvedNoLatn ) ; // Section 5.2 step 6: if ( resolvedNoLatn . get ( UScript . HAN_WITH_BOPOMOFO ) || resolvedNoLatn . get ( UScript . JAPANESE ) || resolvedNoLatn . get ( UScript . KOREAN ) ) { return RestrictionLevel . HIGHLY_RESTRICTIVE ; } // Section 5.2 step 7: if ( ! resolvedNoLatn . isEmpty ( ) && ! resolvedNoLatn . get ( UScript . CYRILLIC ) && ! resolvedNoLatn . get ( UScript . GREEK ) && ! resolvedNoLatn . get ( UScript . CHEROKEE ) ) { return RestrictionLevel . MODERATELY_RESTRICTIVE ; } // Section 5.2 step 8: return RestrictionLevel . MINIMALLY_RESTRICTIVE ; }
Computes the restriction level of a string according to UTS 39 section 5 . 2 .