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


Java NameValuePair.getValue方法代码示例

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


在下文中一共展示了NameValuePair.getValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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

示例3: getCharset

import org.apache.commons.httpclient.NameValuePair; //导入方法依赖的package包/类
public String getCharset() {
    String charset = null;
    Header contenttype = this.headers.getFirstHeader("Content-Type");
    if (contenttype != null) {
        HeaderElement values[] = contenttype.getElements();
        if (values.length == 1) {
            NameValuePair param = values[0].getParameterByName("charset");
            if (param != null) {
                charset = param.getValue();
            }
        }
    }
    if (charset != null) {
        return charset;
    } else {
        return DEFAULT_CONTENT_CHARSET;
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:19,代码来源:SimpleRequest.java

示例4: getRedirectURL

import org.apache.commons.httpclient.NameValuePair; //导入方法依赖的package包/类
/**
 * Checks all present name value pairs for the existence of an entry with
 * name FRONTEND.REDIRECT_URL. The found entry will be returned, null if
 * there is none.
 * 
 * @param result
 *            The list of name value pairs to search in.
 * @return The redirect URL, null if it is not set.
 */
private String getRedirectURL(List<NameValuePair> result) {

    String redirectURL = null;
    for (NameValuePair nvp : result) {
        if (HeidelpayPostParameter.FRONTEND_REDIRECT_URL.equals(nvp
                .getName())) {
            redirectURL = nvp.getValue();
            break;
        }
    }

    return redirectURL;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:23,代码来源:PaymentServiceProviderBean.java

示例5: validateDeregistrationXMLResponse

import org.apache.commons.httpclient.NameValuePair; //导入方法依赖的package包/类
private void validateDeregistrationXMLResponse(PaymentInfo pi,
        NameValuePair[] requestBodyDetails, String pspPaymentTypeId)
        throws ParserConfigurationException, SAXException, IOException,
        XPathExpressionException {
    NameValuePair nameValuePair = requestBodyDetails[0];
    String value = nameValuePair.getValue();
    System.out.println(value);
    Document doc = XMLConverter.convertToDocument(value, true);
    Assert.assertEquals("1.0", XMLConverter.getNodeTextContentByXPath(doc,
            "/Request/@version"));
    Assert.assertEquals("securitySender", XMLConverter
            .getNodeTextContentByXPath(doc,
                    "/Request/Header/Security/@sender"));
    Assert.assertEquals("INTEGRATOR_TEST", XMLConverter
            .getNodeTextContentByXPath(doc, "/Request/Transaction/@mode"));
    Assert.assertEquals("txnChannel",
            XMLConverter.getNodeTextContentByXPath(doc,
                    "/Request/Transaction/@channel"));
    Assert.assertEquals("SYNC", XMLConverter.getNodeTextContentByXPath(doc,
            "/Request/Transaction/@response"));
    Assert.assertEquals("userLogin", XMLConverter
            .getNodeTextContentByXPath(doc,
                    "/Request/Transaction/User/@login"));
    Assert.assertEquals("userPwd", XMLConverter.getNodeTextContentByXPath(
            doc, "/Request/Transaction/User/@pwd"));
    Assert.assertEquals(
            String.valueOf(pi.getKey()),
            XMLConverter
                    .getNodeTextContentByXPath(doc,
                            "/Request/Transaction/Identification/TransactionID/text()"));
    Assert.assertEquals(
            "externalId",
            XMLConverter
                    .getNodeTextContentByXPath(doc,
                            "/Request/Transaction/Identification/ReferenceID/text()"));
    Assert.assertEquals(pspPaymentTypeId + ".DR", XMLConverter
            .getNodeTextContentByXPath(doc,
                    "/Request/Transaction/Payment/@code"));
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:40,代码来源:PaymentServiceProviderBeanTest.java

示例6: parseAttribute

import org.apache.commons.httpclient.NameValuePair; //导入方法依赖的package包/类
/**
  * Parse the cookie attribute and update the corresponsing {@link Cookie}
  * properties as defined by the Netscape draft specification
  *
  * @param attribute {@link NameValuePair} cookie attribute from the
  * <tt>Set- Cookie</tt>
  * @param cookie {@link 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 (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null.");
    }
    final String paramName = attribute.getName().toLowerCase();
    final String paramValue = attribute.getValue();

    if (paramName.equals("expires")) {

        if (paramValue == null) {
            throw new MalformedCookieException(
                "Missing value for expires attribute");
        }
        try {
            DateFormat expiryFormat = new SimpleDateFormat(
                "EEE, dd-MMM-yyyy HH:mm:ss z", Locale.US);
            Date date = expiryFormat.parse(paramValue);
            cookie.setExpiryDate(date);
        } catch (ParseException e) {
            throw new MalformedCookieException("Invalid expires "
                + "attribute: " + e.getMessage());
        }
    } else {
        super.parseAttribute(attribute, cookie);
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:42,代码来源:NetscapeDraftSpec.java

示例7: formatParam

import org.apache.commons.httpclient.NameValuePair; //导入方法依赖的package包/类
/**
 * Return a name/value string suitable for sending in a <tt>"Cookie"</tt>
 * header as defined in RFC 2109 for backward compatibility with cookie
 * version 0
 * @param buffer The string buffer to use for output
 * @param param The parameter.
 * @param version The cookie version 
 */
private void formatParam(final StringBuffer buffer, final NameValuePair param, int version) {
    if (version < 1) {
        buffer.append(param.getName());
        buffer.append("=");
        if (param.getValue() != null) {
            buffer.append(param.getValue());   
        }
    } else {
        this.formatter.format(buffer, param);
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:20,代码来源:RFC2109Spec.java

示例8: StringRequestEntity

import org.apache.commons.httpclient.NameValuePair; //导入方法依赖的package包/类
/**
 * Creates a new entity with the given content, content type, and charset.
 *  
 * @param content The content to set.
 * @param contentType The type of the content, or <code>null</code>.  The value retured 
 *   by {@link #getContentType()}.  If this content type contains a charset and the charset
 *   parameter is null, the content's type charset will be used.
 * @param charset The charset of the content, or <code>null</code>.  Used to convert the 
 *   content to bytes.  If the content type does not contain a charset and charset is not null,
 *   then the charset will be appended to the content type.
 */
public StringRequestEntity(String content, String contentType, String charset) 
    throws UnsupportedEncodingException {
    super();
    if (content == null) {
        throw new IllegalArgumentException("The content cannot be null");
    }
    
    this.contentType = contentType;
    this.charset = charset;
    
    // resolve the content type and the charset
    if (contentType != null) {
        HeaderElement[] values = HeaderElement.parseElements(contentType);
        NameValuePair charsetPair = null;
        for (int i = 0; i < values.length; i++) {
            if ((charsetPair = values[i].getParameterByName("charset")) != null) {
                // charset found
                break;
            }
        }
        if (charset == null && charsetPair != null) {
            // use the charset from the content type
            this.charset = charsetPair.getValue();
        } else if (charset != null && charsetPair == null) {
            // append the charset to the content type
            this.contentType = contentType + "; charset=" + charset; 
        }
    }
    if (this.charset != null) {
        this.content = content.getBytes(this.charset);
    } else {
        this.content = content.getBytes();
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:46,代码来源:StringRequestEntity.java

示例9: format

import org.apache.commons.httpclient.NameValuePair; //导入方法依赖的package包/类
/**
 * Produces textual representaion of the attribute/value pair using 
 * formatting rules defined in RFC 2616
 *  
 * @param buffer output buffer 
 * @param param the parameter to be formatted
 */
public void format(final StringBuffer buffer, final NameValuePair param) {
    if (buffer == null) {
        throw new IllegalArgumentException("String buffer may not be null");
    }
    if (param == null) {
        throw new IllegalArgumentException("Parameter may not be null");
    }
    buffer.append(param.getName());
    String value = param.getValue();
    if (value != null) {
        buffer.append("=");
        formatValue(buffer, value, this.alwaysUseQuotes);
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:22,代码来源:ParameterFormatter.java

示例10: getCharset

import org.apache.commons.httpclient.NameValuePair; //导入方法依赖的package包/类
public String getCharset() {
    String charset = DEFAULT_CONTENT_CHARSET;
    Header contenttype = this.headers.getFirstHeader("Content-Type");
    if (contenttype != null) {
        HeaderElement values[] = contenttype.getElements();
        if (values.length == 1) {
            NameValuePair param = values[0].getParameterByName("charset");
            if (param != null) {
                charset = param.getValue();
            }
        }
    }
    return charset;
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:15,代码来源:SimpleResponse.java

示例11: parseAttribute

import org.apache.commons.httpclient.NameValuePair; //导入方法依赖的package包/类
/**
  * Parse RFC 2109 specific cookie attribute and update the corresponsing
  * {@link Cookie} properties.
  *
  * @param attribute {@link NameValuePair} cookie attribute from the
  * <tt>Set- Cookie</tt>
  * @param cookie {@link 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 (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null.");
    }
    final String paramName = attribute.getName().toLowerCase();
    final String paramValue = attribute.getValue();

    if (paramName.equals("path")) {
        if (paramValue == null) {
            throw new MalformedCookieException(
                "Missing value for path attribute");
        }
        if (paramValue.trim().equals("")) {
            throw new MalformedCookieException(
                "Blank value for path attribute");
        }
        cookie.setPath(paramValue);
        cookie.setPathAttributeSpecified(true);
    } else if (paramName.equals("version")) {

        if (paramValue == null) {
            throw new MalformedCookieException(
                "Missing value for version attribute");
        }
        try {
           cookie.setVersion(Integer.parseInt(paramValue));
        } catch (NumberFormatException e) {
            throw new MalformedCookieException("Invalid version: " 
                + e.getMessage());
        }

    } else {
        super.parseAttribute(attribute, cookie);
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:51,代码来源:RFC2109Spec.java


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