FsPermission implements Writable, Serializable,
    ObjectInputValidation { private FsPermission() {} private  FsPermission();  FsPermission(FsAction u, FsAction g, FsAction o);  FsPermission(FsAction u, FsAction g, FsAction o, boolean sb);  FsPermission(short mode);  FsPermission(int mode);  FsPermission(FsPermission other);  FsPermission(String mode); static FsPermission createImmutable(short permission); FsAction getUserAction(); FsAction getGroupAction(); FsAction getOtherAction(); void fromShort(short n); @Override @Deprecated void write(DataOutput out); @Override @Deprecated void readFields(DataInput in); FsPermission getMasked(); FsPermission getUnmasked(); static FsPermission read(DataInput in); short toShort(); @Deprecated short toExtendedShort(); short toOctal(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); FsPermission applyUMask(FsPermission umask); static FsPermission getUMask(Configuration conf); boolean getStickyBit(); @Deprecated boolean getAclBit(); @Deprecated boolean getEncryptedBit(); @Deprecated boolean getErasureCodedBit(); static void setUMask(Configuration conf, FsPermission umask); static FsPermission getDefault(); static FsPermission getDirDefault(); static FsPermission getFileDefault(); static FsPermission getCachePoolDefault(); static FsPermission valueOf(String unixSymbolicPermission); @Override void validateObject(); static final int MAX_PERMISSION_LENGTH; static final String UMASK_LABEL; static final int DEFAULT_UMASK; }
@Test public void testFsPermission() { String symbolic = "-rwxrwxrwx"; for(int i = 0; i < (1 << 10); i++) { StringBuilder b = new StringBuilder("----------"); String binary = String.format("%11s", Integer.toBinaryString(i)); String permBinary = binary.substring(2, binary.length()); int len = permBinary.length(); for(int j = 0; j < len; j++) { if (permBinary.charAt(j) == '1') { int k = 9 - (len - 1 - j); b.setCharAt(k, symbolic.charAt(k)); } } if (binary.charAt(1) == '1') { char replacement = b.charAt(9) == 'x' ? 't' : 'T'; b.setCharAt(9, replacement); } assertEquals(i, FsPermission.valueOf(b.toString()).toShort()); } }