in subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemPermission.java [223:326]
private static int parseActions(String actions) {
boolean seencomma = false;
int mask = ACTION_NONE;
if (actions == null) {
return mask;
}
char[] a = actions.toCharArray();
int i = a.length - 1;
if (i < 0)
return mask;
while (i != -1) {
char c;
// skip whitespace
while ((i != -1) && ((c = a[i]) == ' ' || c == '\r' || c == '\n' || c == '\f' || c == '\t'))
i--;
// check for the known strings
int matchlen;
if (i >= 6 && (a[i - 6] == 'e' || a[i - 6] == 'E')
&& (a[i - 5] == 'x' || a[i - 5] == 'X')
&& (a[i - 4] == 'e' || a[i - 4] == 'E')
&& (a[i - 3] == 'c' || a[i - 3] == 'C')
&& (a[i - 2] == 'u' || a[i - 2] == 'U')
&& (a[i - 1] == 't' || a[i - 1] == 'T')
&& (a[i] == 'e' || a[i] == 'E')) {
matchlen = 7;
mask |= ACTION_EXECUTE;
} else
if (i >= 8 && (a[i - 8] == 'l' || a[i - 8] == 'L')
&& (a[i - 7] == 'i' || a[i - 7] == 'I')
&& (a[i - 6] == 'f' || a[i - 6] == 'F')
&& (a[i - 5] == 'e' || a[i - 5] == 'E')
&& (a[i - 4] == 'c' || a[i - 4] == 'C')
&& (a[i - 3] == 'y' || a[i - 3] == 'Y')
&& (a[i - 2] == 'c' || a[i - 2] == 'C')
&& (a[i - 1] == 'l' || a[i - 1] == 'L')
&& (a[i] == 'e' || a[i] == 'E')) {
matchlen = 9;
mask |= ACTION_LIFECYCLE;
} else
if (i >= 7
&& (a[i - 7] == 'm' || a[i - 7] == 'M')
&& (a[i - 6] == 'e' || a[i - 6] == 'E')
&& (a[i - 5] == 't' || a[i - 5] == 'T')
&& (a[i - 4] == 'a' || a[i - 4] == 'A')
&& (a[i - 3] == 'd' || a[i - 3] == 'D')
&& (a[i - 2] == 'a' || a[i - 2] == 'A')
&& (a[i - 1] == 't' || a[i - 1] == 'T')
&& (a[i] == 'a' || a[i] == 'A')) {
matchlen = 8;
mask |= ACTION_METADATA;
} else
if (i >= 6
&& (a[i - 6] == 'c' || a[i - 6] == 'C')
&& (a[i - 5] == 'o' || a[i - 5] == 'O')
&& (a[i - 4] == 'n' || a[i - 4] == 'N')
&& (a[i - 3] == 't' || a[i - 3] == 'T')
&& (a[i - 2] == 'e' || a[i - 2] == 'E')
&& (a[i - 1] == 'x' || a[i - 1] == 'X')
&& (a[i] == 't' || a[i] == 'T')) {
matchlen = 7;
mask |= ACTION_CONTEXT;
} else {
// parse error
throw new IllegalArgumentException("invalid permission: " + actions);
}
// make sure we didn't just match the tail of a word
// like "ackbarfexecute". Also, skip to the comma.
seencomma = false;
while (i >= matchlen && !seencomma) {
switch (a[i - matchlen]) {
case ',' :
seencomma = true;
/* FALLTHROUGH */
case ' ' :
case '\r' :
case '\n' :
case '\f' :
case '\t' :
break;
default :
throw new IllegalArgumentException("invalid permission: " + actions);
}
i--;
}
// point i at the location of the comma minus one (or -1).
i -= matchlen;
}
if (seencomma) {
throw new IllegalArgumentException("invalid permission: " + actions);
}
return mask;
}