code: private byte checkExplicitLevels() {
          byte dirProp;
          int i;
          int isolateCount = 0;
  
          this.flags = 0;     /* collect all directionalities in the text */
          byte level;
          this.isolateCount = 0;
  
          for (i = 0; i < length; ++i) {
              level = levels[i];
              dirProp = dirProps[i];
              if (dirProp == LRI || dirProp == RLI) {
                  isolateCount++;
                  if (isolateCount > this.isolateCount)
                      this.isolateCount = isolateCount;
              }
              else if (dirProp == PDI)
                  isolateCount--;
              else if (dirProp == B)
                  isolateCount = 0;
              if ((level & LEVEL_OVERRIDE) != 0) {
                  /* keep the override flag in levels[i] but adjust the flags */
                  level &= ~LEVEL_OVERRIDE;     /* make the range check below simpler */
                  flags |= DirPropFlagO(level);
              } else {
                  /* set the flags */
                  flags |= DirPropFlagE(level) | DirPropFlag(dirProp);
              }
              if ((level < GetParaLevelAt(i) &&
                      !((0 == level) && (dirProp == B))) ||
                      (MAX_EXPLICIT_LEVEL < level)) {
                  /* level out of bounds */
                  throw new IllegalArgumentException("level " + level +
                                                     " out of bounds at " + i);
              }
          }
          if ((flags & MASK_EMBEDDING) != 0)
              flags |= DirPropFlagLR(paraLevel);
          /* determine if the text is mixed-directional or single-directional */
          return directionFromFlags();
      }
docs: /*
  Use a pre-specified embedding levels array:
  
  Adjust the directional properties for overrides (->LEVEL_OVERRIDE),
  ignore all explicit codes (X9),
  and check all the preset levels.
  
  Recalculate the flags to have them reflect the real properties
  after taking the explicit embeddings into account.