Methods Summary |
---|
public static java.util.Vector | getCommaSeparatedValues(java.lang.String input)Create a vector of values from a string containing comma separated
values. The values cannot contain a comma. The output values will be
trimmed of whitespace. The vector may contain zero length strings
where there are 2 commas in a row or a comma at the end of the input
string.
return getDelimSeparatedValues(input, ',");
|
public static java.util.Vector | getDelimSeparatedValues(java.lang.String input, char delim)Create a vector of values from a string containing delimiter separated
values. The values cannot contain the delimiter. The output values will
be trimmed of whitespace. The vector may contain zero length strings
where there are 2 delimiters in a row or a comma at the end of the input
string.
Vector output = new Vector(5, 5);
int len;
int start;
int end;
len = input.length();
if (len == 0) {
return output;
}
for (start = 0; ; ) {
end = input.indexOf(delim, start);
if (end == -1) {
break;
}
output.addElement(input.substring(start, end).trim());
start = end + 1;
}
end = len;
output.addElement(input.substring(start, end).trim());
return output;
|
public static java.lang.String | getHttpMediaType(java.lang.String contentType)Parses out the media-type from the given HTTP content-type field and
converts it to lower case.
The media-type everything for the ';' that marks the parameters.
int semiColon;
if (contentType == null) {
return null;
}
semiColon = contentType.indexOf(';");
if (semiColon < 0) {
return contentType.toLowerCase();
}
return contentType.substring(0, semiColon).toLowerCase();
|
public static byte[] | toCString(java.lang.String string)Converts string into a null terminated
byte array. Expects the characters in string
to be in th ASCII range (0-127 base 10).
int length = string.length();
byte[] cString = new byte[length + 1];
for (int i = 0; i < length; i++) {
cString[i] = (byte)string.charAt(i);
}
return cString;
|
public static java.lang.String | toJavaString(byte[] cString)Converts an ASCII null terminated byte array in to a
String . Expects the characters in byte array
to be in th Ascii range (0-127 base 10).
int i;
String jString;
// find the string length
for (i = 0; cString[i] != 0; i++);
try {
return new String(cString, 0, i, "ISO8859_1");
} catch (java.io.UnsupportedEncodingException e) {
return null;
}
|