當前位置: 首頁>>代碼示例>>Java>>正文


Java NameValuePair.getName方法代碼示例

本文整理匯總了Java中org.apache.commons.httpclient.NameValuePair.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java NameValuePair.getName方法的具體用法?Java NameValuePair.getName怎麽用?Java NameValuePair.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.httpclient.NameValuePair的用法示例。


在下文中一共展示了NameValuePair.getName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseAttribute

import org.apache.commons.httpclient.NameValuePair; //導入方法依賴的package包/類
/**
 * Parse RFC 2965 specific cookie attribute and update the corresponsing
 * {@link org.apache.commons.httpclient.Cookie} properties.
 *
 * @param attribute {@link org.apache.commons.httpclient.NameValuePair} cookie attribute from the
 * <tt>Set-Cookie2</tt> header.
 * @param cookie {@link org.apache.commons.httpclient.Cookie} to be updated
 * @throws MalformedCookieException if an exception occurs during parsing
 */
public void parseAttribute(
        final NameValuePair attribute, final Cookie cookie)
        throws MalformedCookieException {
    if (attribute == null) {
        throw new IllegalArgumentException("Attribute may not be null.");
    }
    if (attribute.getName() == null) {
        throw new IllegalArgumentException("Attribute Name may not be null.");
    }
    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null.");
    }
    final String paramName = attribute.getName().toLowerCase();
    final String paramValue = attribute.getValue();

    CookieAttributeHandler handler = findAttribHandler(paramName);
    if (handler == null) {
        // ignore unknown attribute-value pairs
        if (LOG.isDebugEnabled())
            LOG.debug("Unrecognized cookie attribute: " +
                      attribute.toString());
    } else {
        handler.parse(cookie, paramValue);
    }
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:35,代碼來源:RFC2965Spec.java

示例2: doFormUrlEncode

import org.apache.commons.httpclient.NameValuePair; //導入方法依賴的package包/類
/**
 * Form-urlencoding routine.
 *
 * The default encoding for all forms is `application/x-www-form-urlencoded'. 
 * A form data set is represented in this media type as follows:
 *
 * The form field names and values are escaped: space characters are replaced 
 * by `+', and then reserved characters are escaped as per [URL]; that is, 
 * non-alphanumeric characters are replaced by `%HH', a percent sign and two 
 * hexadecimal digits representing the ASCII code of the character. Line breaks, 
 * as in multi-line text field values, are represented as CR LF pairs, i.e. `%0D%0A'.
 * 
 * @param pairs the values to be encoded
 * @param charset the character set of pairs to be encoded
 * 
 * @return the urlencoded pairs
 * @throws UnsupportedEncodingException if charset is not supported
 * 
 * @since 2.0 final
 */
 private static String doFormUrlEncode(NameValuePair[] pairs, String charset)
    throws UnsupportedEncodingException 
 {
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < pairs.length; i++) {
        URLCodec codec = new URLCodec();
        NameValuePair pair = pairs[i];
        if (pair.getName() != null) {
            if (i > 0) {
                buf.append("&");
            }
            buf.append(codec.encode(pair.getName(), charset));
            buf.append("=");
            if (pair.getValue() != null) {
                buf.append(codec.encode(pair.getValue(), charset));
            }
        }
    }
    return buf.toString();
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:41,代碼來源:EncodingUtil.java


注:本文中的org.apache.commons.httpclient.NameValuePair.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。