byte dirTypeBackward(){
  lastChar=text.charAt(charIndex - 1);
  if (Character.isLowSurrogate(lastChar)) {
    int codePoint=Character.codePointBefore(text,charIndex);
    charIndex-=Character.charCount(codePoint);
    return Character.getDirectionality(codePoint);
  }
  charIndex--;
  byte dirType=getCachedDirectionality(lastChar);
  if (isHtml) {
    if (lastChar == '>') {
      dirType=skipTagBackward();
    }
 else     if (lastChar == ';') {
      dirType=skipEntityBackward();
    }
  }
  return dirType;
}

byte dirTypeBackward ( ) { lastChar = text . charAt ( charIndex - 1 ) ; if ( Character . isLowSurrogate ( lastChar ) ) { int codePoint = Character . codePointBefore ( text , charIndex ) ; charIndex -= Character . charCount ( codePoint ) ; return Character . getDirectionality ( codePoint ) ; } charIndex -- ; byte dirType = getCachedDirectionality ( lastChar ) ; if ( isHtml ) { if ( lastChar == '>' ) { dirType = skipTagBackward ( ) ; } else if ( lastChar == ';' ) { dirType = skipEntityBackward ( ) ; } } return dirType ; }
returns the character . directionality_ . . . value of the preceding codepoint and advances charindex backwards . if ishtml , and the codepoint is the end of a complete html tag or entity , advances over the whole tag / entity and returns character . directionality_whitespace . for an entity , it would be best to figure out the actual character , and return its dirtype , but treating it as whitespace is good enough for our purposes .
