private static int parseSymbolicMode(CharSequenceScanner parse, int maskBits) {

    int mask = maskBits;
    int ugo = parseUGO(parse);
    char mode = parse.forceNext();
    int flags = 0;
    int template = -1;
    char c = parse.forceNext();
    if (c == 'u') {
      template = (mask & MASK_USER_FLAGS) >> 6;
    } else if (c == 'g') {
      template = (mask & MASK_GROUP_FLAGS) >> 3;
    } else if (c == 'o') {
      template = mask & MASK_OTHERS_FLAGS;
    } else {
      while (c != 0) {
        if (c == 'r') {
          flags = flags | (ugo << 2);
        } else if (c == 'w') {
          flags = flags | (ugo << 1);
        } else if (c == 'x') {
          flags = flags | ugo;
        } else if (c == 's') {
          flags = flags | MASK_SETUID;
        } else if (c == 'S') {
          flags = flags | MASK_SETGID;
        } else if (c == 't') {
          flags = flags | MASK_STICKY;
        } else {
          parse.stepBack();
          break;
        }
        c = parse.forceNext();
      }
    }
    if (template != -1) {
      if ((ugo & 0001) != 0) {
        flags = template;
      }
      if ((ugo & 0010) != 0) {
        flags = flags | (template << 3);
      }
      if ((ugo & 0100) != 0) {
        flags = flags | (template << 6);
      }
    }
    if (mode == '+') {
      mask = mask | flags;
    } else if (mode == '-') {
      mask = mask & ~flags;
    } else if (mode == '=') {
      int clear = ugo | (ugo << 1) | (ugo << 2);
      mask = mask & ~clear;
      mask = mask | flags;
    } else {
      throw new IllegalArgumentException("op: '" + mode + "'");
    }
    return mask;
  }
private static int parseSymbolicMode ( CharSequenceScanner parse , int maskBits ) { int mask = maskBits ; int ugo = parseUGO ( parse ) ; char mode = parse . forceNext ( ) ; int flags = 0 ; int template = - 1 ; char c = parse . forceNext ( ) ; if ( c == 'u' ) { template = ( mask & MASK_USER_FLAGS ) > > 6 ; } else if ( c == 'g' ) { template = ( mask & MASK_GROUP_FLAGS ) > > 3 ; } else if ( c == 'o' ) { template = mask & MASK_OTHERS_FLAGS ; } else { while ( c != 0 ) { if ( c == 'r' ) { flags = flags | ( ugo << 2 ) ; } else if ( c == 'w' ) { flags = flags | ( ugo << 1 ) ; } else if ( c == 'x' ) { flags = flags | ugo ; } else if ( c == 's' ) { flags = flags | MASK_SETUID ; } else if ( c == 'S' ) { flags = flags | MASK_SETGID ; } else if ( c == 't' ) { flags = flags | MASK_STICKY ; } else { parse . stepBack ( ) ; break ; } c = parse . forceNext ( ) ; } } if ( template != - 1 ) { if ( ( ugo & 0001 ) != 0 ) { flags = template ; } if ( ( ugo & 0010 ) != 0 ) { flags = flags | ( template << 3 ) ; } if ( ( ugo & 0100 ) != 0 ) { flags = flags | ( template << 6 ) ; } } if ( mode == '+' ) { mask = mask | flags ; } else if ( mode == '-' ) { mask = mask & ~ flags ; } else if ( mode == '=' ) { int clear = ugo | ( ugo << 1 ) | ( ugo << 2 ) ; mask = mask & ~ clear ; mask = mask | flags ; } else { throw new IllegalArgumentException ( "op: '" + mode + "'" ) ; } return mask ; }
This method parses a symbolic-mode segment from {@code parse}. It applies the {@link #chmod(String) chmod} of that
segment to the given {@code mask} and returns the result. The state of this object remains unchanged.

@param parse is the current state of the parser.
@param maskBits is the current modifier mask.
@return the changed {@code mask}.