Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- imports
- */
- public class GWebDriver extends SimpleExpression<GWebDriver>{
- public WebDriver driver;
- public String name;
- public Object type;
- public static Map<String, GWebDriver> GWebDrivers = new HashMap<String, GWebDriver>();
- public static void register() {
- Classes.registerClass(new ClassInfo<GWebDriver>(GWebDriver.class, "browser").user("browser").name("browser")
- .parser(new Parser<GWebDriver>() {
- @Override
- public GWebDriver parse(String s, ParseContext context) {
- return null;
- }
- @Override
- public String getVariableNamePattern() {
- // TODO Auto-generated method stub
- return ".+";
- }
- @Override
- public String toString(GWebDriver locDriver, int flags) {
- // TODO Auto-generated method stub
- return getKey(locDriver);
- }
- @Override
- public String toVariableNameString(GWebDriver locDriver) {
- // TODO Auto-generated method stub
- return getKey(locDriver);
- }
- }
- ));
- }
- public static String getKey(GWebDriver locDriver){
- for(Entry<String, GWebDriver> entry : GWebDrivers.entrySet()){
- if (locDriver.equals(entry.getValue())){
- return entry.getKey();
- }
- }
- return locDriver.toString();
- }
- public static GWebDriver getWindow(String s){
- GWebDriver locDriver = GWebDrivers.get(s);
- return locDriver;
- }
- public static String[] getAllKeys(){
- String[] strings = GWebDriver.GWebDrivers.keySet().toArray(new String[GWebDriver.GWebDrivers.size()]);
- return strings;
- }
- //99 lines of irrelevent stuff
- private Expression<String> objname;
- @Override
- public Class<? extends GWebDriver> getReturnType() {
- // TODO Auto-generated method stub
- return GWebDriver.class;
- }
- @Override
- public boolean isSingle() {
- // TODO Auto-generated method stub
- return true;
- }
- @Override
- public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
- // TODO Auto-generated method stub
- objname = (Expression<String>) expr[0];
- return true;
- }
- @Override
- public String toString(Event arg0, boolean arg1) {
- // TODO Auto-generated method stub
- return "browser";
- }
- @Override
- protected GWebDriver[] get(Event e) {
- // TODO Auto-generated method stub
- return new GWebDriver[]{GWebDriver.getWindow(objname.getSingle(e))};
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement