Map a MIME content-type to an equivalent string
of class-name components.
The MIME type is mapped to a string by:
- Replacing all slashes with a period.
- Converting all alphabetic characters to lower case.
- Converting all non-alpha-numeric characters other than periods
to underscores (_).
For example, "text/html" would
be converted to "text.html"
if (mimeType == null)
return null;
// All to lower case ...
mimeType = mimeType.toLowerCase();
// ... run through each char and convert
// '/' -> '.'
// !([A-Za-z0--9]) -> '_'
int len = mimeType.length();
char nm[] = new char[len];
mimeType.getChars(0, len, nm, 0);
for (int i = 0; i < len; i++) {
char c = nm[i];
if (c == '/") {
nm[i] = '.";
} else if (!(c == '." ||
'A" <= c && c <= 'Z" ||
'a" <= c && c <= 'z" ||
'0" <= c && c <= '9")) {
nm[i] = '_";
}
}
return new String(nm);