public static final short getMode(CharSequence perms)
    {
        if (perms.length() != 10)
        {
            throw new IllegalArgumentException(perms+" not permission");
        }
        short mode = 0;
        for (int ii=0;ii<10;ii++)
        {
            int shift = 9-ii;
            switch (perms.charAt(ii))
            {
                case 'c':   // character device
                    if (ii != 0)
                    {
                        throw new IllegalArgumentException(perms+" illegal");
                    }
                    mode |= 0020000;
                    break;
                case 'b':   // block device
                    if (ii != 0)
                    {
                        throw new IllegalArgumentException(perms+" illegal");
                    }
                    mode |= 0060000;
                    break;
                case 'p':   // FIFO (pipe)
                    if (ii != 0)
                    {
                        throw new IllegalArgumentException(perms+" illegal");
                    }
                    mode |= 0010000;
                    break;
                case 'l':
                    if (ii != 0)
                    {
                        throw new IllegalArgumentException(perms+" illegal");
                    }
                    mode |= 0120000;
                    break;
                case 'd':
                    if (ii != 0)
                    {
                        throw new IllegalArgumentException(perms+" illegal");
                    }
                    mode |= 0040000;
                    break;
                case '-':
                    if (ii == 0)
                    {
                        mode |= 0100000;
                    }
                    break;
                case 'r':
                    switch (ii)
                    {
                        case 7:
                        case 4:
                        case 1:
                            mode |= (1<<shift);
                            break;
                        default:
                            throw new IllegalArgumentException(perms+" illegal");
                    }
                    break;
                case 'w':
                    switch (ii)
                    {
                        case 8:
                        case 5:
                        case 2:
                            mode |= (1<<shift);
                            break;
                        default:
                            throw new IllegalArgumentException(perms+" illegal");
                    }
                    break;
                case 'x':
                    switch (ii)
                    {
                        case 9:
                        case 6:
                        case 3:
                            mode |= (1<<shift);
                            break;
                        default:
                            throw new IllegalArgumentException(perms+" illegal");
                    }
                    break;
                case 's':
                    switch (ii)
                    {
                        case 0:
                            mode |= 0140000;
                            break;
                        case 6:
                            mode |= 0002000;
                            mode |= (1<<shift);
                            break;
                        case 3:
                            mode |= 0004000;
                            mode |= (1<<shift);
                            break;
                        default:
                            throw new IllegalArgumentException(perms+" illegal");
                    }
                    break;
                case 't':
                    switch (ii)
                    {
                        case 9:
                            mode |= 0001001;
                            break;
                        default:
                            throw new IllegalArgumentException(perms+" illegal");
                    }
                    break;
                case 'T':
                    switch (ii)
                    {
                        case 9:
                            mode |= 0001000;
                            break;
                        default:
                            throw new IllegalArgumentException(perms+" illegal");
                    }
                    break;
            }
        }
        return mode;
    }
public static final short getMode ( CharSequence perms ) { if ( perms . length ( ) != 10 ) { throw new IllegalArgumentException ( perms + " not permission" ) ; } short mode = 0 ; for ( int ii = 0 ; ii < 10 ; ii ++ ) { int shift = 9 - ii ; switch ( perms . charAt ( ii ) ) { case 'c' : if ( ii != 0 ) { throw new IllegalArgumentException ( perms + " illegal" ) ; } mode |= 0020000 ; break ; case 'b' : if ( ii != 0 ) { throw new IllegalArgumentException ( perms + " illegal" ) ; } mode |= 0060000 ; break ; case 'p' : if ( ii != 0 ) { throw new IllegalArgumentException ( perms + " illegal" ) ; } mode |= 0010000 ; break ; case 'l' : if ( ii != 0 ) { throw new IllegalArgumentException ( perms + " illegal" ) ; } mode |= 0120000 ; break ; case 'd' : if ( ii != 0 ) { throw new IllegalArgumentException ( perms + " illegal" ) ; } mode |= 0040000 ; break ; case '-' : if ( ii == 0 ) { mode |= 0100000 ; } break ; case 'r' : switch ( ii ) { case 7 : case 4 : case 1 : mode |= ( 1 << shift ) ; break ; default : throw new IllegalArgumentException ( perms + " illegal" ) ; } break ; case 'w' : switch ( ii ) { case 8 : case 5 : case 2 : mode |= ( 1 << shift ) ; break ; default : throw new IllegalArgumentException ( perms + " illegal" ) ; } break ; case 'x' : switch ( ii ) { case 9 : case 6 : case 3 : mode |= ( 1 << shift ) ; break ; default : throw new IllegalArgumentException ( perms + " illegal" ) ; } break ; case 's' : switch ( ii ) { case 0 : mode |= 0140000 ; break ; case 6 : mode |= 0002000 ; mode |= ( 1 << shift ) ; break ; case 3 : mode |= 0004000 ; mode |= ( 1 << shift ) ; break ; default : throw new IllegalArgumentException ( perms + " illegal" ) ; } break ; case 't' : switch ( ii ) { case 9 : mode |= 0001001 ; break ; default : throw new IllegalArgumentException ( perms + " illegal" ) ; } break ; case 'T' : switch ( ii ) { case 9 : mode |= 0001000 ; break ; default : throw new IllegalArgumentException ( perms + " illegal" ) ; } break ; } } return mode ; }
Returns mode from String. E.g. "-rwxr--r--" = 0100744.
@param perms
@return