FsPermission implements Writable, Serializable,
    ObjectInputValidation { public short toShort() { int s = (stickyBit ? 1 << 9 : 0) | (useraction.ordinal() << 6) | (groupaction.ordinal() << 3) | otheraction.ordinal(); return (short)s; } 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 testConvertingPermissions() { for(short s = 0; s <= 01777; s++) { assertEquals(s, new FsPermission(s).toShort()); assertEquals(s, new FsPermission(String.format("%03o", s)).toShort()); } short s = 0; for(boolean sb : new boolean [] { false, true }) { for(FsAction u : FsAction.values()) { for(FsAction g : FsAction.values()) { for(FsAction o : FsAction.values()) { FsPermission f = new FsPermission(u, g, o, sb); assertEquals(s, f.toShort()); FsPermission f2 = new FsPermission(f); assertEquals(s, f2.toShort()); s++; } } } } assertEquals(02000, s); }