{
List<ServerAddress> serverAddrs = new ArrayList();
if (remains.length() == 0)
{
// "mongodb:"
serverAddrs.add(new ServerAddress());
}
else
{
StringTokenizer tokeniser = new StringTokenizer(remains, ",");
while (tokeniser.hasMoreTokens())
{
String token = tokeniser.nextToken();
String serverName = "localhost";
if (token.charAt(0) != '/')
{
// server name (and optional port)
int serverEndPos = remains.indexOf('/');
if (serverEndPos > 0)
{
serverName = token.substring(0, serverEndPos);
token = token.substring(serverEndPos);
}
else
{
serverName = token;
remains = "";
}
}
// Create a ServerAddress for this specification
ServerAddress addr = null;
int portSeparatorPos = serverName.indexOf(':');
if (portSeparatorPos > 0)
{
addr = new ServerAddress(serverName.substring(0, portSeparatorPos),
Integer.valueOf(serverName.substring(portSeparatorPos+1)).intValue());
}
else
{
addr = new ServerAddress(serverName);
}
serverAddrs.add(addr);
if (token.charAt(0) == '/' && token.length() > 1)
{