public static int getOptions ( CollationData data , CollationSettings settings , char [ ] primaries ) { char [ ] header = data . fastLatinTableHeader ; if ( header == null ) { return - 1 ; } assert ( ( header [ 0 ] >> 8 ) == VERSION ) ; if ( primaries . length != LATIN_LIMIT ) { assert false ; return - 1 ; } int miniVarTop ; if ( ( settings . options & CollationSettings . ALTERNATE_MASK ) == 0 ) { // No mini primaries are variable, set a variableTop just below the // lowest long mini primary. miniVarTop = MIN_LONG - 1 ; } else { int headerLength = header [ 0 ] & 0xff ; int i = 1 + settings . getMaxVariable ( ) ; if ( i >= headerLength ) { return - 1 ; // variableTop >= digits, should not occur } miniVarTop = header [ i ] ; } boolean digitsAreReordered = false ; if ( settings . hasReordering ( ) ) { long prevStart = 0 ; long beforeDigitStart = 0 ; long digitStart = 0 ; long afterDigitStart = 0 ; for ( int group = Collator . ReorderCodes . FIRST ; group < Collator . ReorderCodes . FIRST + CollationData . MAX_NUM_SPECIAL_REORDER_CODES ; ++ group ) { long start = data . getFirstPrimaryForGroup ( group ) ; start = settings . reorder ( start ) ; if ( group == Collator . ReorderCodes . DIGIT ) { beforeDigitStart = prevStart ; digitStart = start ; } else if ( start != 0 ) { if ( start < prevStart ) { // The permutation affects the groups up to Latin. return - 1 ; } // In the future, there might be a special group between digits & Latin. if ( digitStart != 0 && afterDigitStart == 0 && prevStart == beforeDigitStart ) { afterDigitStart = start ; } prevStart = start ; } } long latinStart = data . getFirstPrimaryForGroup ( UScript . LATIN ) ; latinStart = settings . reorder ( latinStart ) ; if ( latinStart < prevStart ) { return - 1 ; } if ( afterDigitStart == 0 ) { afterDigitStart = latinStart ; } if ( ! ( beforeDigitStart < digitStart && digitStart < afterDigitStart ) ) { digitsAreReordered = true ; } } char [ ] table = data . fastLatinTable ; // skip the header for ( int c = 0 ; c < LATIN_LIMIT ; ++ c ) { int p = table [ c ] ; if ( p >= MIN_SHORT ) { p &= SHORT_PRIMARY_MASK ; } else if ( p > miniVarTop ) { p &= LONG_PRIMARY_MASK ; } else { p = 0 ; } primaries [ c ] = ( char ) p ; } if ( digitsAreReordered || ( settings . options & CollationSettings . NUMERIC ) != 0 ) { // Bail out for digits. for ( int c = 0x30 ; c <= 0x39 ; ++ c ) { primaries [ c ] = 0 ; } } // Shift the miniVarTop above other options. return ( miniVarTop << 16 ) | settings . options ; }
Computes the options value for the compare functions and writes the precomputed primary weights . Returns - 1 if the Latin fastpath is not supported for the data and settings . The capacity must be LATIN_LIMIT .