decode static method
Decodes string access mode to integer
Implementation
static int? decode(dynamic mode) {
if (mode == null) {
return null;
} else if (mode is int) {
return mode & AccessModePermissionsBITMASK;
} else if (mode == 'N' || mode == 'n') {
return NONE;
}
var bitmask = {
'J': JOIN,
'R': READ,
'W': WRITE,
'P': PRES,
'A': APPROVE,
'S': SHARE,
'D': DELETE,
'O': OWNER,
};
var m0 = NONE;
if (mode != null) {
for (var i = 0; i < mode.length; i++) {
var bit = bitmask[mode[i].toUpperCase()];
if (bit == null) {
// Unrecognized bit, skip.
continue;
}
m0 |= bit;
}
}
return m0;
}