public java.lang.String[] | readSimpleList()Read a list of space-separated "flag_extension" sequences and
return the list as a array of Strings. An empty list is returned
as null. This is an IMAP-ism, and perhaps this method should
moved into the IMAP layer.
skipSpaces();
if (buffer[index] != '(") // not what we expected
return null;
index++; // skip '('
Vector v = new Vector();
int start;
for (start = index; buffer[index] != ')"; index++) {
if (buffer[index] == ' ") { // got one item
v.addElement(ASCIIUtility.toString(buffer, start, index));
start = index+1; // index gets incremented at the top
}
}
if (index > start) // get the last item
v.addElement(ASCIIUtility.toString(buffer, start, index));
index++; // skip ')'
int size = v.size();
if (size > 0) {
String[] s = new String[size];
v.copyInto(s);
return s;
} else // empty list
return null;
|