/*
 * Copyright 2011-2012 WebDriver committers
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.uiautomation.ios.wkrdp.internal;

import org.apache.commons.io.IOUtils;
import org.openqa.selenium.WebDriverException;

import java.io.StringWriter;

/**
 * The WebDriver atoms are used to ensure consistent behaviour cross-browser.
 */
public enum IosAtoms {

  BACK("back_ios.js"),
  CLEAR("clear_ios.js"),
  CLICK("click_ios.js"),
  FORWARD("forward_ios.js"),
  GET_ATTRIBUTE("get_attribute_ios.js"),
  GET_EFFECTIVE_STYLE("get_effective_style_ios.js"),
  GET_INTERACTABLE_SIZE("get_interactable_size_ios.js"),
  GET_LOCATION_IN_VIEW("get_location_in_view_ios.js"),
  GET_VISIBLE_TEXT("get_visible_text_ios.js"),
  IS_ENABLED("is_enabled_ios.js"),
  IS_SELECTED("is_selected_ios.js"),
  IS_SHOWN("is_shown_ios.js"),
  LINK_TEXT("link_text_ios.js"),
  LINK_TEXTS("link_texts_ios.js"),
  PARTIAL_LINK_TEXT("partial_link_text_ios.js"),
  PARTIAL_LINK_TEXTS("partial_link_texts_ios.js"),
  SCROLL_INTO_VIEW("scroll_into_view_ios.js"),
  STRINGIFY("stringify_ios.js"),
  SUBMIT("submit_ios.js"),
  TYPE("type_ios.js"),
  XPATH("xpath_ios.js"),
  XPATHS("xpaths_ios.js"),
  GET_SIZE("getElementSize_ios.js"),
  ;

  private final String value;

  public String getValue() {
    return value;
  }

  @Override
  public String toString() {
    return getValue();
  }

  private IosAtoms(String fileLocation) {
    StringWriter sw = new StringWriter();
    String resource = "atoms/" + fileLocation;
    try {
      IOUtils.copy(getClass().getClassLoader().getResourceAsStream(resource), sw);
    } catch (Exception e) {
      throw new WebDriverException("cannot copy " + resource, e);
    }
    this.value = sw.toString();
  }
}

@@ -691,44 +691,26 @@
 ls;%0A
+%0A
 import 
-org.openqa.selenium.WebDriver
+java.io.IO
 Exce
@@ -716,17 +716,16 @@
 eption;%0A
-%0A
 import j
@@ -1683,16 +1683,18 @@
 %22get
-E
+_e
 lement
-S
+_s
 ize_
@@ -1795,20 +1795,8 @@
  %7D%0A%0A
-  @Override%0A
   pu
@@ -1850,24 +1850,16 @@
 %0A  %7D%0A%0A  
-private 
 IosAtoms
@@ -1932,57 +1932,10 @@
     
-S
 tr
-ing resource = %22atoms/%22 + fileLocation;%0A    tr
 y %7B%0A
@@ -1951,14 +1951,30 @@
 tils
+%0A          
 .copy(
+this.
 getC
@@ -2017,24 +2017,39 @@
 sStream(
-resource
+%22atoms/%22 + fileLocation
 ), sw);%0A
@@ -2061,16 +2061,18 @@
  catch (
+IO
 Exceptio
@@ -2088,65 +2088,26 @@
     
-throw new WebDriverException(%22cannot copy %22 + resource, e
+e.printStackTrace(
 );%0A 
@@ -2147,10 +2147,11 @@
 ();%0A  %7D%0A
+%0A
 %7D%0A

Revert "Fixed GET_SIZE in IosAtoms.java"