当前位置: 首页>>代码示例>>Java>>正文


Java URLEncodedUtils.parse方法代码示例

本文整理汇总了Java中org.apache.http.client.utils.URLEncodedUtils.parse方法的典型用法代码示例。如果您正苦于以下问题:Java URLEncodedUtils.parse方法的具体用法?Java URLEncodedUtils.parse怎么用?Java URLEncodedUtils.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.client.utils.URLEncodedUtils的用法示例。


在下文中一共展示了URLEncodedUtils.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decodeExtras

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
private Map<String, String> decodeExtras(String extras) {
    Map<String, String> results = new HashMap<String, String>();
    try {
        URI rawExtras = new URI("?" + extras);
        List<NameValuePair> extraList = URLEncodedUtils.parse(rawExtras, "UTF-8");
        for (NameValuePair item : extraList) {
            String name = item.getName();
            int i = 0;
            while (results.containsKey(name)) {
                name = item.getName() + ++i;
            }
            results.put(name, item.getValue());
        }
    } catch (URISyntaxException e) {
        Log.w(TAG, "Invalid syntax error while decoding extras data from server.");
    }
    return results;
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:19,代码来源:APKExpansionPolicy.java

示例2: getExpectedParams

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
/**
 * Get list of expected query parameters.
 * 
 * @param pageUrl page URL annotation
 * @param expectUri expected landing page URI
 * @return list of expected query parameters
 */
private static List<NameValuePair> getExpectedParams(PageUrl pageUrl, URI expectUri) {
    List<NameValuePair> expectParams = new ArrayList<>();
    String[] params = pageUrl.params();
    if (params.length > 0) {
        for (String param : params) {
            String[] nameValueBits = param.split("=");
            if (nameValueBits.length == 2) {
                String name = nameValueBits[0].trim();
                String value = nameValueBits[1].trim();
                expectParams.add(new BasicNameValuePair(name, value));
            } else {
                throw new IllegalArgumentException("Format of PageUrl parameter '" + param
                        + "' does not conform to template [name]=[pattern]");
            }
        }
    } else if (expectUri != null) {
        expectParams = URLEncodedUtils.parse(expectUri, "UTF-8");
    }
    return expectParams;
}
 
开发者ID:Nordstrom,项目名称:Selenium-Foundation,代码行数:28,代码来源:ComponentContainer.java

示例3: getParameter

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
/**
 * Extract a query string parameter without triggering http parameters
 * processing by the servlet container.
 *
 * @param request the request
 * @param name the parameter to get the value.
 * @return the parameter value, or <code>NULL</code> if the parameter is not
 * defined.
 * @throws IOException thrown if there was an error parsing the query string.
 */
public static String getParameter(HttpServletRequest request, String name)
    throws IOException {
  List<NameValuePair> list = URLEncodedUtils.parse(request.getQueryString(),
      UTF8_CHARSET);
  if (list != null) {
    for (NameValuePair nv : list) {
      if (name.equals(nv.getName())) {
        return nv.getValue();
      }
    }
  }
  return null;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:24,代码来源:ServletUtils.java

示例4: getDoAs

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
@VisibleForTesting
static String getDoAs(HttpServletRequest request) {
  List<NameValuePair> list = URLEncodedUtils.parse(request.getQueryString(),
      UTF8_CHARSET);
  if (list != null) {
    for (NameValuePair nv : list) {
      if (DelegationTokenAuthenticatedURL.DO_AS.
          equalsIgnoreCase(nv.getName())) {
        return nv.getValue();
      }
    }
  }
  return null;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:DelegationTokenAuthenticationFilter.java

示例5: getProperty

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
/**
 * MSSQL driver do not return password, so we need to parse it manually
 * @param property
 * @param connectionString
 * @return
 */
protected static String getProperty(String property, String connectionString) {
  String ret = null;
  if (property != null && !property.isEmpty() && connectionString != null && !connectionString.isEmpty()) {
    for (NameValuePair param : URLEncodedUtils.parse(connectionString, StandardCharsets.UTF_8, SEPARATORS)) {
      if(property.equals(param.getName())){
        ret = param.getValue();
        break;
      }
    }
  }
  return ret;
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:19,代码来源:ConnectionStringHolder.java

示例6: getMacAccessTokenSignatureString

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
protected static String getMacAccessTokenSignatureString(String nonce, String method, String
        host, String uriPath, String query, String macKey, String macAlgorithm) throws
        InvalidKeyException, NoSuchAlgorithmException, UnsupportedEncodingException {
    if ("HmacSHA1".equalsIgnoreCase(macAlgorithm)) {
        StringBuilder joined = new StringBuilder("");
        joined.append(new StringBuilder(String.valueOf(nonce)).append("\n").toString());
        joined.append(method.toUpperCase() + "\n");
        joined.append(new StringBuilder(String.valueOf(host)).append("\n").toString());
        joined.append(new StringBuilder(String.valueOf(uriPath)).append("\n").toString());
        if (!TextUtils.isEmpty(query)) {
            StringBuffer sb = new StringBuffer();
            List<NameValuePair> paramList = new ArrayList();
            URLEncodedUtils.parse(paramList, new Scanner(query), "UTF-8");
            Collections.sort(paramList, new Comparator<NameValuePair>() {
                public int compare(NameValuePair p1, NameValuePair p2) {
                    return p1.getName().compareTo(p2.getName());
                }
            });
            sb.append(URLEncodedUtils.format(paramList, "UTF-8"));
            joined.append(sb.toString() + "\n");
        }
        return encodeSign(encryptHMACSha1(joined.toString().getBytes("UTF-8"), macKey
                .getBytes("UTF-8")));
    }
    throw new NoSuchAlgorithmException("error mac algorithm : " + macAlgorithm);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:AuthorizeHelper.java

示例7: getURLField

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
public String getURLField(String u, String which) throws URISyntaxException {
    for (NameValuePair nvp : URLEncodedUtils.parse(new URI(u), "UTF-8")) {
        LOG.info(nvp.getName() + "=" + nvp.getValue());

        if (nvp.getName().equals(which)) {
            return nvp.getValue();
        }
    }
    return null;
}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:11,代码来源:AudibleScraper.java

示例8: getParams

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
public JSONArray getParams(ResourceTimings e) {
    JSONArray paramList = new JSONArray();
    try {
        List<NameValuePair> params = URLEncodedUtils.parse(new URI(e.name), "UTF-8");
        for (NameValuePair pair : params) {
            JSONObject jsonPair = new JSONObject();
            jsonPair.put("name", pair.getName());
            jsonPair.put("value", pair.getValue());
            paramList.add(jsonPair);
        }

    } catch (Exception ex) {
        return paramList;
    }
    return paramList;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:17,代码来源:Entry.java

示例9: getUserName

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
private String getUserName(HttpServletRequest request) {
  List<NameValuePair> list = URLEncodedUtils.parse(request.getQueryString(), UTF8_CHARSET);
  if (list != null) {
    for (NameValuePair nv : list) {
      if (PseudoAuthenticator.USER_NAME.equals(nv.getName())) {
        return nv.getValue();
      }
    }
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:PseudoAuthenticationHandler.java

示例10: params

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
public static Map<String, String> params(String jdbcUrl) {
  Map<String, String> results = new HashMap<>();

  if (Validations.empty(jdbcUrl)) return results;
  if (!jdbcUrl.matches("jdbc:.*")) return results;

  String url = jdbcUrl.substring(5);

  URI dbUri;
  try {
    dbUri = new URI(url);
  } catch (URISyntaxException ex) {
    logger.warn("Invalid database url: " + jdbcUrl);
    return results;
  }

  results.put("database", dbUri.getPath());
  results.put("type", dbUri.getScheme());
  results.put("host", dbUri.getHost());
  results.put("port", String.valueOf(dbUri.getPort()));

  List<NameValuePair> queryParams = URLEncodedUtils.parse(dbUri, "UTF-8");
  queryParams.forEach(p -> results.put(p.getName(), p.getValue()));

  return results;
}
 
开发者ID:saslani,项目名称:sparkler,代码行数:27,代码来源:DatabaseUrl.java

示例11: buildUri

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
protected URI buildUri( ServletRequest request, String relativeUrl ) throws URISyntaxException {
    int questionMarkIndex = relativeUrl.indexOf( '?' );
    String path = questionMarkIndex != -1
            ? relativeUrl.substring( 0, relativeUrl.indexOf( '?' ) )
            : relativeUrl;
    List<NameValuePair> params = URLEncodedUtils.parse(
            new URI( relativeUrl ),
            Charset.forName( "UTF-8" )
    );

    return new URIBuilder()
            .setScheme( request.getScheme() )
            .setHost( request.getLocalName() )
            .setPort( request.getLocalPort() )
            .setPath( path )
            .setParameters( params )
            .build();
}
 
开发者ID:alexeytokar,项目名称:rainbow-rest,代码行数:19,代码来源:RainbowRestOncePerRequestFilter.java

示例12: getAccessToken

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
@Override
public String getAccessToken(String code) {
	Assert.hasText(code);
	Map<String, Object> parameterMap = new HashMap<>();
	parameterMap.put("grant_type", "authorization_code");
	parameterMap.put("client_id", getClientId());
	parameterMap.put("client_secret", getClientSecret());
	parameterMap.put("code", code);
	parameterMap.put("redirect_uri", getRedirectUri());
	String responseString = get("https://graph.qq.com/oauth2.0/token", parameterMap);

	List<NameValuePair> nameValuePairs = URLEncodedUtils.parse(responseString, Charset.forName("utf-8"));
	Map<String, Object> result = new HashMap<>();
	for (NameValuePair nameValuePair : nameValuePairs) {
		result.put(nameValuePair.getName(), nameValuePair.getValue());
	}

	return getParameter(nameValuePairs, "access_token");
}
 
开发者ID:xiangxik,项目名称:java-platform,代码行数:20,代码来源:QQOauthPlugin.java

示例13: getMacAccessTokenSignatureString

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
protected static String getMacAccessTokenSignatureString(String s, String s1, String s2, String s3, String s4, String s5, String s6)
{
    if ("HmacSHA1".equalsIgnoreCase(s6))
    {
        StringBuilder stringbuilder = new StringBuilder("");
        stringbuilder.append((new StringBuilder(String.valueOf(s))).append("\n").toString());
        stringbuilder.append((new StringBuilder(String.valueOf(s1.toUpperCase()))).append("\n").toString());
        stringbuilder.append((new StringBuilder(String.valueOf(s2))).append("\n").toString());
        stringbuilder.append((new StringBuilder(String.valueOf(s3))).append("\n").toString());
        if (!TextUtils.isEmpty(s4))
        {
            StringBuffer stringbuffer = new StringBuffer();
            ArrayList arraylist = new ArrayList();
            URLEncodedUtils.parse(arraylist, new Scanner(s4), "UTF-8");
            Collections.sort(arraylist, new b());
            stringbuffer.append(URLEncodedUtils.format(arraylist, "UTF-8"));
            stringbuilder.append((new StringBuilder(String.valueOf(stringbuffer.toString()))).append("\n").toString());
        }
        return encodeSign(encryptHMACSha1(stringbuilder.toString().getBytes("UTF-8"), s5.getBytes("UTF-8")));
    } else
    {
        throw new NoSuchAlgorithmException((new StringBuilder("error mac algorithm : ")).append(s6).toString());
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:25,代码来源:AuthorizeHelper.java

示例14: getNextCursorFromDocument

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
public String getNextCursorFromDocument(JSONAPIDocument document) {
    Links links = document.getLinks();
    if (links == null) {
        return null;
    }
    Link nextLink = links.getNext();
    if (nextLink == null) {
        return null;
    }
    String nextLinkString = nextLink.toString();
    try {
        List<NameValuePair> queryParameters = URLEncodedUtils.parse(new URI(nextLinkString), "utf8");
        for (NameValuePair pair : queryParameters) {
            String name = pair.getName();
            if (name.equals("page[cursor]")) {
                String cursorValue = pair.getValue();
                return cursorValue;
            }
        }
    } catch (URISyntaxException e) {
        LOG.error(e.getMessage());
    }
    return null;
}
 
开发者ID:Patreon,项目名称:patreon-java,代码行数:25,代码来源:PatreonAPI.java

示例15: splitQuery

import org.apache.http.client.utils.URLEncodedUtils; //导入方法依赖的package包/类
public static Map<String, List<String>> splitQuery(URI uri) {
  final Map<String, List<String>> queryPairs = new LinkedHashMap<>();
  List<NameValuePair> pairs = URLEncodedUtils.parse(uri, StandardCharsets.UTF_8.name());
  for (NameValuePair pair : pairs) {
    List<String> list = queryPairs.computeIfAbsent(pair.getName(), name -> {
      return new ArrayList<>();
    });
    list.add(pair.getValue());
  }
  return queryPairs;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:12,代码来源:URIEndpointObject.java


注:本文中的org.apache.http.client.utils.URLEncodedUtils.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。