private JSONObject getCriteriaFromWebDriverSelector ( JSONObject payload ) throws JSONException { String using = payload . getString ( "using" ) ; String value = payload . getString ( "value" ) ; if ( "tag name" . equals ( using ) || "class name" . equals ( using ) ) { try { Package p = UIAElement . class . getPackage ( ) ; Criteria c = new TypeCriteria ( Class . forName ( p . getName ( ) + "." + value ) ) ; return c . stringify ( ) ; } catch ( ClassNotFoundException e ) { throw new InvalidSelectorException ( value + " is not a recognized type." ) ; } // http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAccessibilityIdentification_Protocol/Introduction/Introduction.html } else if ( "name" . equals ( using ) || "id" . equals ( using ) ) { Criteria c = new NameCriteria ( getAUT ( ) . applyL10N ( value ) ) ; return c . stringify ( ) ; } else if ( "link text" . equals ( using ) || "partial link text" . equals ( using ) ) { return createGenericCriteria ( using , value ) ; } else { throw new InvalidSelectorException ( using + "is not a valid selector for the native part of ios-driver." ) ; } }
handles the mapping from the webdriver using to a criteria .