List of usage examples for android.net Uri getQueryParameterNames
public Set<String> getQueryParameterNames()
From source file:Main.java
public static List<String> getAllTables(Uri uri) { List<String> result = new ArrayList<String>(); String mainTable = uri.getLastPathSegment(); result.add(mainTable);//from ww w. j av a2 s . c om Set<String> queryParameterNames = uri.getQueryParameterNames(); Iterator<String> iterator = queryParameterNames.iterator(); while (iterator.hasNext()) { String table = iterator.next(); if (table.startsWith(TABLE)) { result.add(table.replaceFirst(TABLE, "")); } } return result; }
From source file:ly.count.android.api.ConnectionQueueTests.java
private Map<String, String> parseQueryParams(final String queryStr) { final String urlStr = "http://server?" + queryStr; final Uri uri = Uri.parse(urlStr); final Set<String> queryParameterNames = uri.getQueryParameterNames(); final Map<String, String> queryParams = new HashMap<String, String>(queryParameterNames.size()); for (String paramName : queryParameterNames) { queryParams.put(paramName, uri.getQueryParameter(paramName)); }//from ww w . j av a 2s . c o m return queryParams; }
From source file:com.freerdp.freerdpcore.services.LibFreeRDP.java
public static boolean setConnectionInfo(Context context, long inst, Uri openUri) { ArrayList<String> args = new ArrayList<>(); // Parse URI from query string. Same key overwrite previous one // freerdp://user@ip:port/connect?sound=&rfx=&p=password&clipboard=%2b&themes=- // Now we only support Software GDI args.add(TAG);//from w w w. ja v a2 s . c o m args.add("/gdi:sw"); final String clientName = ApplicationSettingsActivity.getClientName(context); if (!clientName.isEmpty()) { args.add("/client-hostname:" + clientName); } // Parse hostname and port. Set to 'v' argument String hostname = openUri.getHost(); int port = openUri.getPort(); if (hostname != null) { hostname = hostname + ((port == -1) ? "" : (":" + String.valueOf(port))); args.add("/v:" + hostname); } String user = openUri.getUserInfo(); if (user != null) { args.add("/u:" + user); } for (String key : openUri.getQueryParameterNames()) { String value = openUri.getQueryParameter(key); if (value.isEmpty()) { // Query: key= // To freerdp argument: /key args.add("/" + key); } else if (value.equals("-") || value.equals("+")) { // Query: key=- or key=+ // To freerdp argument: -key or +key args.add(value + key); } else { // Query: key=value // To freerdp argument: /key:value if (key.equals("drive") && value.equals("sdcard")) { // Special for sdcard redirect String path = android.os.Environment.getExternalStorageDirectory().getPath(); value = "sdcard," + path; } args.add("/" + key + ":" + value); } } String[] arrayArgs = args.toArray(new String[args.size()]); return freerdp_parse_arguments(inst, arrayArgs); }
From source file:net.openid.appauth.AuthorizationRequestTest.java
@Test public void testToUri() throws Exception { AuthorizationRequest request = mRequestBuilder.build(); Uri uri = request.toUri(); assertThat(uri.getQueryParameterNames()) .isEqualTo(new HashSet<>(Arrays.asList(AuthorizationRequest.PARAM_CLIENT_ID, AuthorizationRequest.PARAM_RESPONSE_TYPE, AuthorizationRequest.PARAM_REDIRECT_URI, AuthorizationRequest.PARAM_STATE, AuthorizationRequest.PARAM_CODE_CHALLENGE, AuthorizationRequest.PARAM_CODE_CHALLENGE_METHOD))); assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_CLIENT_ID)).isEqualTo(TEST_CLIENT_ID); assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_RESPONSE_TYPE)) .isEqualTo(ResponseTypeValues.CODE); assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_REDIRECT_URI)) .isEqualTo(TEST_APP_REDIRECT_URI.toString()); assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_STATE)).isEqualTo(request.state); assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_CODE_CHALLENGE)) .isEqualTo(request.codeVerifierChallenge); assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_CODE_CHALLENGE_METHOD)) .isEqualTo(request.codeVerifierChallengeMethod); }
From source file:net.openid.appauth.AuthorizationRequestTest.java
@Test public void testToUri_stateParam() { Uri uri = mRequestBuilder.setState(TEST_STATE).build().toUri(); assertThat(uri.getQueryParameterNames()).contains(AuthorizationRequest.PARAM_STATE); assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_STATE)).isEqualTo(TEST_STATE); }
From source file:net.openid.appauth.AuthorizationRequestTest.java
@Test public void testToUri_loginHint() { Uri uri = mRequestBuilder.setLoginHint(TEST_EMAIL_ADDRESS).build().toUri(); assertThat(uri.getQueryParameterNames()).contains(AuthorizationRequest.PARAM_LOGIN_HINT); assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_LOGIN_HINT)).isEqualTo(TEST_EMAIL_ADDRESS); }
From source file:net.openid.appauth.AuthorizationRequestTest.java
@Test public void testToUri_scopeParam() { Uri uri = mRequestBuilder.setScope(AuthorizationRequest.Scope.EMAIL).build().toUri(); assertThat(uri.getQueryParameterNames()).contains(AuthorizationRequest.PARAM_SCOPE); assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_SCOPE)) .isEqualTo(AuthorizationRequest.Scope.EMAIL); }
From source file:net.openid.appauth.AuthorizationRequestTest.java
@Test public void testToUri_displayParam() { Uri uri = mRequestBuilder.setDisplay(AuthorizationRequest.Display.PAGE).build().toUri(); assertThat(uri.getQueryParameterNames()).contains(AuthorizationRequest.PARAM_DISPLAY); assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_DISPLAY)) .isEqualTo(AuthorizationRequest.Display.PAGE); }
From source file:net.openid.appauth.AuthorizationRequestTest.java
@Test public void testToUri_promptParam() { Uri uri = mRequestBuilder.setPrompt(AuthorizationRequest.Prompt.CONSENT).build().toUri(); assertThat(uri.getQueryParameterNames()).contains(AuthorizationRequest.PARAM_PROMPT); assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_PROMPT)) .isEqualTo(AuthorizationRequest.Prompt.CONSENT); }
From source file:net.openid.appauth.AuthorizationRequestTest.java
@Test public void testToUri_responseModeParam() { Uri uri = mRequestBuilder.setResponseMode(AuthorizationRequest.ResponseMode.QUERY).build().toUri(); assertThat(uri.getQueryParameterNames()).contains(AuthorizationRequest.PARAM_RESPONSE_MODE); assertThat(uri.getQueryParameter(AuthorizationRequest.PARAM_RESPONSE_MODE)) .isEqualTo(AuthorizationRequest.ResponseMode.QUERY); }