本文整理汇总了Java中org.apache.http.NameValuePair.getName方法的典型用法代码示例。如果您正苦于以下问题:Java NameValuePair.getName方法的具体用法?Java NameValuePair.getName怎么用?Java NameValuePair.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.NameValuePair
的用法示例。
在下文中一共展示了NameValuePair.getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decodeExtras
import org.apache.http.NameValuePair; //导入方法依赖的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;
}
示例2: parseHeader
import org.apache.http.NameValuePair; //导入方法依赖的package包/类
public HeaderElement parseHeader(
final CharArrayBuffer buffer,
final ParserCursor cursor) throws ParseException {
if (buffer == null) {
throw new IllegalArgumentException("Char array buffer may not be null");
}
if (cursor == null) {
throw new IllegalArgumentException("Parser cursor may not be null");
}
NameValuePair nvp = parseNameValuePair(buffer, cursor);
List<NameValuePair> params = new ArrayList<NameValuePair>();
while (!cursor.atEnd()) {
NameValuePair param = parseNameValuePair(buffer, cursor);
params.add(param);
}
return new BasicHeaderElement(
nvp.getName(),
nvp.getValue(), params.toArray(new NameValuePair[params.size()]));
}
示例3: URLGet
import org.apache.http.NameValuePair; //导入方法依赖的package包/类
/**
* GET List<NameValuePair>请求
*
* @param pathUrl
* @param params
* @return
*/
public static String URLGet(String pathUrl, List<NameValuePair> params) {
String queryString = "";
StringBuilder repString = new StringBuilder();
try {
String path = pathUrl;
String keyValue;
if (null != params && params.size() > 0) {
for (NameValuePair nvp : params) {
String key = nvp.getName();
keyValue = nvp.getValue();
if (null != keyValue && !"".equals(keyValue)) {
queryString = queryString + key + "=" + keyValue + "&";
}
}
}
if (!"".equals(queryString)) {
path = path + "?" + queryString;
}
HttpsURLConnection.setDefaultHostnameVerifier(ignoreHostnameVerifier);
HttpsURLConnection connection = (HttpsURLConnection) (new URL(path)).openConnection();
// Prepare SSL Context
TrustManager[] tm = {ignoreCertificationTrustManger};
// SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, tm, new java.security.SecureRandom());
// 从上述SSLContext对象中得到SSLSocketFactory对象
SSLSocketFactory ssf = sslContext.getSocketFactory();
connection.setSSLSocketFactory(ssf);
InputStreamReader isr = new InputStreamReader(connection.getInputStream(), "utf-8");
BufferedReader br = new BufferedReader(isr);
String s;
while (null != (s = br.readLine())) {
repString.append(s);
}
isr.close();
connection.disconnect();
} catch (Exception ex) {
log.error("调用链接失败:pathUrl:" + pathUrl + "queryString:" + queryString);
ex.printStackTrace();
} finally {
log.info(repString.toString());
}
return repString.toString();
}
示例4: ExecuteGetRequest
import org.apache.http.NameValuePair; //导入方法依赖的package包/类
public void ExecuteGetRequest() throws Exception
{
String MixParams = "";
if(!ArrayListParams.isEmpty())
{
MixParams += "?";
for(NameValuePair p : ArrayListParams)
{
String paramString = p.getName() + "=" + URLEncoder.encode(p.getValue(),"UTF-8");
if(MixParams.length() > 1)
{
MixParams += "&" + paramString;
}
else
{
MixParams += paramString;
}
}
}
HttpGet httpGet = new HttpGet(UrlHolder + MixParams);
for(NameValuePair h : headers)
{
httpGet.addHeader(h.getName(), h.getValue());
}
executeRequest(httpGet, UrlHolder);
}
示例5: IridiumMessage
import org.apache.http.NameValuePair; //导入方法依赖的package包/类
public IridiumMessage(List<NameValuePair> params) {
for (NameValuePair param : params) {
switch (param.getName()) {
case PARAM_IMEI:
imei = param.getValue();
break;
case PARAM_MOMSN:
momsn = param.getValue();
break;
case PARAM_TRANSMIT_TIME:
transmitTime = param.getValue();
break;
case PARAM_IRIDIUM_LATITUDE:
iridiumLatitude = param.getValue();
break;
case PARAM_IRIDIUM_LONGITUDE:
iridiumLongitude = param.getValue();
break;
case PARAM_IRIDIUM_CEP:
iridiumCep = param.getValue();
break;
case PARAM_DATA:
data = param.getValue();
break;
}
}
}
示例6: parametersAsQueryString
import org.apache.http.NameValuePair; //导入方法依赖的package包/类
public String parametersAsQueryString() {
String s = "";
for (Iterator<NameValuePair> i = this.params.iterator(); i.hasNext(); ) {
NameValuePair nv = i.next();
s += "&" + nv.getName() + "=" + nv.getValue();
}
if (s.length() > 0) {
return "?" + s.substring(1);
}
return s;
}