public String getContext ( int wordsLeft , int wordsRight ) { final String text = home_cc . getText ( ) ; int temp ; // get the left start position int posLeft = pos . getStart ( ) ; temp = posLeft - 1 ; while ( posLeft != 0 && wordsLeft > 0 ) { while ( temp > 0 && text . charAt ( temp ) < 48 ) { temp -- ; } while ( temp > 0 && text . charAt ( temp ) >= 48 ) { temp -- ; } posLeft = ( temp > 0 ? temp + 1 : 0 ) ; wordsLeft -- ; } // get the right end position int posRight = pos . getEnd ( ) ; temp = posRight ; while ( posRight != text . length ( ) && wordsRight > 0 ) { while ( temp < text . length ( ) && text . charAt ( temp ) < 48 ) { temp ++ ; } while ( temp < text . length ( ) && text . charAt ( temp ) >= 48 ) { temp ++ ; } posRight = temp ; wordsRight -- ; } // retrun a string... return text . substring ( posLeft , pos . getStart ( ) ) + text . substring ( pos . getEnd ( ) , posRight ) ; }
Returns the Number of Words left and right of the Link in the Bounds of the HomeElement of this Link .