public Server readServer() throws IOException {
String line;
while ((line = getIn().readLine()) != null) {
try {
QuotedStringTokenizer t
= new QuotedStringTokenizer(line, " :");
if (t.countTokens() < 2) {
continue;
}
String ip = t.nextToken();
int port = Integer.parseInt(t.nextToken());
if (port < PortRange.MIN_PORT || port > PortRange.MAX_PORT) {
throw new NumberFormatException();
}
String network = (t.countTokens() > 0) ? t.nextToken() : "";
Server s = new Server(ip, port, network);
if (t.countTokens() >= 3) {
String token = t.nextToken();
s.setUsername((token.length() > 0) ? token : null);
token = t.nextToken();
s.setPassword((token.length() > 0) ? token : null);
token = t.nextToken();
s.setEmail((token.length() > 0) ? token : null);
}
if (t.countTokens() >= 1) {
s.setRedirector(t.nextToken().equals("true"));
}
if (t.countTokens() >= 1) {
t.nextToken(); //s.setAutoJoinChannels();
}
return s;
}
catch (NumberFormatException e) {