private void processCommands()
   {
      int index = 0;
      while (true)
      {
         if (index == events.size())
         {
            throw new RuntimeException("UPR command: structure not recognised");
         }
         IParserEvent event = events.get(index);
         if (event.getType() == ParserEventType.COMMAND_EVENT)
         {
            CommandEvent command = (CommandEvent) event;
            if (command.getCommand() == Command.ud)
            {
               break;
            }
         }
         ++index;
      }

      if (index == events.size())
      {
         throw new RuntimeException("UPR command: structure not recognised: unable to locate UD command");
      }

      ++index;
      if (events.get(index).getType() != ParserEventType.GROUP_START_EVENT)
      {
         throw new RuntimeException("UPR command: expecting group start, found: " + events.get(index).getType());
      }

      ++index;
      int endIndex = index;
      int groupCount = 1;
      while (true)
      {
         if (endIndex == events.size())
         {
            break;
         }

         IParserEvent event = events.get(endIndex);
         switch (event.getType())
         {
            case GROUP_START_EVENT:
            {
               ++groupCount;
               break;
            }

            case GROUP_END_EVENT:
            {
               --groupCount;
               break;
            }

            default:
               break;
         }

         if (groupCount == 0)
         {
            break;
         }
         ++endIndex;
      }

      if (index == events.size())
      {
         throw new RuntimeException("UPR command: structure not recognised: unable to locate UD group end");
      }

      while (index <= endIndex)
      {
         handler.handleEvent(events.get(index));
         ++index;
      }

      complete = true;
   }