private GameInfo parseGameLine(String line) throws EndOfGameListException {
  int len=line.length();
  if (len == 0) {
    return null;
  }
  if (line.endsWith(END_MESSAGE)) {
    throw new EndOfGameListException(END_MESSAGE);
  }
  int i=0;
  while ((i < len) && (Character.isWhitespace(line.charAt(i)))) {
    ++i;
  }
  if (i >= len) {
    return null;
  }
  StringBuilder sb=new StringBuilder();
  int j=i;
  while ((j < len) && Character.isDigit(line.charAt(j))) {
    sb.append(line.charAt(j));
    ++j;
  }
  if (j >= len) {
    return null;
  }
  if (i == j) {
    return null;
  }
  GameInfo info=new GameInfo();
  info.setId(sb.toString());
  sb.delete(0,sb.length());
  i=j;
  while ((i < len) && Character.isWhitespace(line.charAt(i))) {
    ++i;
  }
  if (i >= len) {
    return null;
  }
  if (line.charAt(i) == '(') {
    return parseExamGame(line,len,++i,info,sb);
  }
 else {
    return parseRegularGame(line,len,i,info,sb);
  }
}

private GameInfo parseGameLine ( String line ) throws EndOfGameListException { int len = line . length ( ) ; if ( len == 0 ) { return null ; } if ( line . endsWith ( END_MESSAGE ) ) { throw new EndOfGameListException ( END_MESSAGE ) ; } int i = 0 ; while ( ( i < len ) && ( Character . isWhitespace ( line . charAt ( i ) ) ) ) { ++ i ; } if ( i >= len ) { return null ; } StringBuilder sb = new StringBuilder ( ) ; int j = i ; while ( ( j < len ) && Character . isDigit ( line . charAt ( j ) ) ) { sb . append ( line . charAt ( j ) ) ; ++ j ; } if ( j >= len ) { return null ; } if ( i == j ) { return null ; } GameInfo info = new GameInfo ( ) ; info . setId ( sb . toString ( ) ) ; sb . delete ( 0 , sb . length ( ) ) ; i = j ; while ( ( i < len ) && Character . isWhitespace ( line . charAt ( i ) ) ) { ++ i ; } if ( i >= len ) { return null ; } if ( line . charAt ( i ) == '(' ) { return parseExamGame ( line , len , ++ i , info , sb ) ; } else { return parseRegularGame ( line , len , i , info , sb ) ; } }
parse one single line in the " games " command output .
