package org.openqa.selenium.qtwebkit;

import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import org.openqa.selenium.qtwebkit.CISCO_Player.RemotePlayer;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.remote.internal.JsonToWebElementConverter;

import java.util.Collection;
import java.util.Map;

public class QtWebKitJsonToWebElementConverter extends JsonToWebElementConverter {

  public QtWebKitJsonToWebElementConverter(QtWebKitDriver driver) {
    super(driver);
  }

  public Object apply(Object result) {
    if (result instanceof Collection<?>) {
      Collection<?> results = (Collection<?>) result;
      return Lists.newArrayList(Iterables.transform(results, this));
    }

    if (result instanceof Map<?, ?>) {
      Map<?, ?> resultAsMap = (Map<?, ?>) result;
      if (resultAsMap.containsKey("ELEMENT")) {
        RemoteWebElement element = newRemoteWebElement();
        element.setId(String.valueOf(resultAsMap.get("ELEMENT")));
        element.setFileDetector(driver.getFileDetector());
        String tagName =  element.getTagName();
        System.out.println("###########!!!!Yeah!!! tagName!!! " + tagName);
        if(tagName.equals("video")){
          System.out.println("###########!!!!Yeah!!! PlayerElement!!!");
          RemotePlayer player = newRemotePlayerElement();
          player.setId(String.valueOf(resultAsMap.get("ELEMENT")));
          player.setFileDetector(driver.getFileDetector());
          return player;
        }
        return element;
      } else {
        return Maps.transformValues(resultAsMap, this);
      }
    }

    if (result instanceof Number) {
      if (result instanceof Float || result instanceof Double) {
        return ((Number) result).doubleValue();
      }
      return ((Number) result).longValue();
    }

    return result;
  }


  protected RemotePlayer newRemotePlayerElement() {
    RemotePlayer toReturn = new RemotePlayer();
    toReturn.setParent(driver);
    return toReturn;
  }

}

@@ -1163,185 +1163,36 @@
     
-System.out.println(%22###########!!!!Yeah!!! tagName!!! %22 + tagName);%0A        if(tagName.equals(%22video%22))%7B%0A          System.out.println(%22###########!!!!Yeah!!! PlayerElement!!!%22);
+if(tagName.equals(%22video%22))%7B
 %0A   

Delete useless comment in QtWebKitJsonToWebElementConverter