public int previous ( ) { if ( dir_ < 0 ) { // Continue backwards iteration. Test this first. if ( otherHalf_ != 0 ) { int oh = otherHalf_ ; otherHalf_ = 0 ; return oh ; } } else if ( dir_ == 0 ) { iter_ . resetToOffset ( string_ . length ( ) ) ; dir_ = - 1 ; } else if ( dir_ == 1 ) { // previous() after setOffset() dir_ = - 1 ; } else /* dir_ > 1 */ { // illegal change of direction throw new IllegalStateException ( "Illegal change of direction" ) ; // Java porting note: ICU4C sets U_INVALID_STATE_ERROR to the return status. } if ( offsets_ == null ) { offsets_ = new UVector32 ( ) ; } // If we already have expansion CEs, then we also have offsets. // Otherwise remember the trailing offset in case we need to // write offsets for an artificial expansion. int limitOffset = iter_ . getCEsLength ( ) == 0 ? iter_ . getOffset ( ) : 0 ; long ce = iter_ . previousCE ( offsets_ ) ; if ( ce == Collation . NO_CE ) { return NULLORDER ; } // Turn the 64-bit CE into two old-style 32-bit CEs, without quaternary bits. long p = ce >>> 32 ; int lower32 = ( int ) ce ; int firstHalf = getFirstHalf ( p , lower32 ) ; int secondHalf = getSecondHalf ( p , lower32 ) ; if ( secondHalf != 0 ) { if ( offsets_ . isEmpty ( ) ) { // When we convert a single 64-bit CE into two 32-bit CEs, // we need to make this artificial expansion behave like a normal expansion. // See CollationIterator.previousCE(). offsets_ . addElement ( iter_ . getOffset ( ) ) ; offsets_ . addElement ( limitOffset ) ; } otherHalf_ = firstHalf ; return secondHalf | 0xc0 ; // continuation CE } return firstHalf ; }
Get the previous collation element in the source string .