private static int combine ( String compositions , int list , int trail ) { int key1 , firstUnit ; if ( trail < COMP_1_TRAIL_LIMIT ) { // trail character is 0..33FF // result entry may have 2 or 3 units key1 = ( trail << 1 ) ; while ( key1 > ( firstUnit = compositions . charAt ( list ) ) ) { list += 2 + ( firstUnit & COMP_1_TRIPLE ) ; } if ( key1 == ( firstUnit & COMP_1_TRAIL_MASK ) ) { if ( ( firstUnit & COMP_1_TRIPLE ) != 0 ) { return ( compositions . charAt ( list + 1 ) << 16 ) | compositions . charAt ( list + 2 ) ; } else { return compositions . charAt ( list + 1 ) ; } } } else { // trail character is 3400..10FFFF // result entry has 3 units key1 = COMP_1_TRAIL_LIMIT + ( ( ( trail >> COMP_1_TRAIL_SHIFT ) ) & ~ COMP_1_TRIPLE ) ; int key2 = ( trail << COMP_2_TRAIL_SHIFT ) & 0xffff ; int secondUnit ; for ( ; ; ) { if ( key1 > ( firstUnit = compositions . charAt ( list ) ) ) { list += 2 + ( firstUnit & COMP_1_TRIPLE ) ; } else if ( key1 == ( firstUnit & COMP_1_TRAIL_MASK ) ) { if ( key2 > ( secondUnit = compositions . charAt ( list + 1 ) ) ) { if ( ( firstUnit & COMP_1_LAST_TUPLE ) != 0 ) { break ; } else { list += 3 ; } } else if ( key2 == ( secondUnit & COMP_2_TRAIL_MASK ) ) { return ( ( secondUnit & ~ COMP_2_TRAIL_MASK ) << 16 ) | compositions . charAt ( list + 2 ) ; } else { break ; } } else { break ; } } } return - 1 ; }
Finds the recomposition result for a forward - combining lead character specified with a pointer to its compositions list and a backward - combining trail character .