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


Java NameValuePair類代碼示例

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


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

示例1: removeParameter

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
/**
 * Removes all parameters with the given paramName. If there is more than
 * one parameter with the given paramName, all of them are removed.  If
 * there is just one, it is removed.  If there are none, then the request
 * is ignored.
 *
 * @param paramName The parameter name to remove.
 *
 * @return true if at least one parameter was removed
 *
 * @throws IllegalArgumentException When the parameter name passed is null
 *
 * @since 2.0
 */
public boolean removeParameter(String paramName) 
throws IllegalArgumentException {
    LOG.trace("enter PostMethod.removeParameter(String)");

    if (paramName == null) {
        throw new IllegalArgumentException(
            "Argument passed to removeParameter(String) cannot be null");
    }
    boolean removed = false;
    Iterator iter = this.params.iterator();

    while (iter.hasNext()) {
        NameValuePair pair = (NameValuePair) iter.next();

        if (paramName.equals(pair.getName())) {
            iter.remove();
            removed = true;
        }
    }
    return removed;
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:36,代碼來源:PostMethod.java

示例2: toString

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
/**
 * 將NameValuePairs數組轉變為字符串
 * 
 * @param nameValues
 * @return
 */
protected String toString(NameValuePair[] nameValues) {
    if (nameValues == null || nameValues.length == 0) {
        return "null";
    }

    StringBuffer buffer = new StringBuffer();

    for (int i = 0; i < nameValues.length; i++) {
        NameValuePair nameValue = nameValues[i];

        if (i == 0) {
            buffer.append(nameValue.getName() + "=" + nameValue.getValue());
        } else {
            buffer.append("&" + nameValue.getName() + "=" + nameValue.getValue());
        }
    }

    return buffer.toString();
}
 
開發者ID:dianbaer,項目名稱:epay,代碼行數:26,代碼來源:HttpProtocolHandler.java

示例3: testUpdateUserResponseAsJSON

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
/**
 * Test for SLING-1677
 */
@Test 
public void testUpdateUserResponseAsJSON() throws IOException, JsonException {
	testUserId = H.createTestUser();
	
       String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".update.json";

	List<NameValuePair> postParams = new ArrayList<NameValuePair>();
	postParams.add(new NameValuePair("displayName", "My Updated Test User"));
	postParams.add(new NameValuePair("url", "http://www.apache.org/updated"));
	Credentials creds = new UsernamePasswordCredentials(testUserId, "testPwd");
	String json = H.getAuthenticatedPostContent(creds, postUrl, HttpTest.CONTENT_TYPE_JSON, postParams, HttpServletResponse.SC_OK);

	//make sure the json response can be parsed as a JSON object
	JsonObject jsonObj = JsonUtil.parseObject(json);
	assertNotNull(jsonObj);
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-launchpad-integration-tests,代碼行數:20,代碼來源:UpdateUserTest.java

示例4: toString

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
/**
 * 將NameValuePairs數組轉變為字符串
 *
 * @param nameValues
 * @return
 */
protected String toString(NameValuePair[] nameValues) {
	if (nameValues == null || nameValues.length == 0) {
		return "null";
	}

	StringBuffer buffer = new StringBuffer();

	for (int i = 0; i < nameValues.length; i++) {
		NameValuePair nameValue = nameValues[i];

		if (i == 0) {
			buffer.append(nameValue.getName() + "=" + nameValue.getValue());
		} else {
			buffer.append("&" + nameValue.getName() + "=" + nameValue.getValue());
		}
	}

	return buffer.toString();
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:26,代碼來源:HttpProtocolHandler.java

示例5: formatCookie

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
/**
 * Return a string suitable for sending in a <tt>"Cookie"</tt> header as
 * defined in RFC 2965
 * @param cookie a {@link org.apache.commons.httpclient.Cookie} to be formatted as string
 * @return a string suitable for sending in a <tt>"Cookie"</tt> header.
 */
public String formatCookie(final Cookie cookie) {
    LOG.trace("enter RFC2965Spec.formatCookie(Cookie)");

    if (cookie == null) {
        throw new IllegalArgumentException("Cookie may not be null");
    }
    if (cookie instanceof Cookie2) {
        Cookie2 cookie2 = (Cookie2) cookie;
        int version = cookie2.getVersion();
        final StringBuffer buffer = new StringBuffer();
        this.formatter.format(buffer, new NameValuePair("$Version", Integer.toString(version)));
        buffer.append("; ");
        doFormatCookie2(cookie2, buffer);
        return buffer.toString();
    } else {
        // old-style cookies are formatted according to the old rules
        return this.rfc2109.formatCookie(cookie);
    }
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:26,代碼來源:RFC2965Spec.java

示例6: initPostParametersForReRegistration

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
/**
 * Initializes the parameters required for the POST call to the PSP for
 * re-registration..
 * 
 * @param paymentInfo
 *            The current payment information object.
 * @param paymentType
 *            The payment type the iframe should be pre-configured for.
 * @param supplierId
 *            Supplier context
 * @return The properties required for the connection to the PSP in order to
 *         register the credit card or direct debit.
 */
private List<NameValuePair> initPostParametersForReRegistration(
        RequestData data) {

    List<NameValuePair> regParams = new ArrayList<NameValuePair>();
    setBasicPostParameters(regParams, data);

    // operation code for re-registration, we use credit card as default.
    regParams.add(new NameValuePair(HeidelpayPostParameter.PAYMENT_CODE,
            getHeidelPayPaymentType(data.getPaymentTypeId()) + ".RR"));

    // also set the already stored reference id
    regParams.add(new NameValuePair(
            HeidelpayPostParameter.IDENTIFICATION_REFERENCEID, data
                    .getExternalIdentifier()));

    initGeneralRegistrationPostData(regParams, data);

    return regParams;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:33,代碼來源:PaymentServiceProviderBean.java

示例7: setWPFControlParameters

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
/**
 * Sets the parameters required to enable the WPF
 * 
 * @param regParams
 *            The list of name value pairs the WPF control parameters will
 *            be added to.
 */
private void setWPFControlParameters(RequestData data,
        List<NameValuePair> regParams) {

    regParams.add(new NameValuePair(
            HeidelpayPostParameter.FRONTEND_ENABLED, "true"));
    regParams.add(new NameValuePair(HeidelpayPostParameter.FRONTEND_POPUP,
            "false"));
    regParams.add(new NameValuePair(HeidelpayPostParameter.FRONTEND_MODE,
            "DEFAULT"));
    regParams.add(new NameValuePair(
            HeidelpayPostParameter.FRONTEND_LANGUAGE, data
                    .getCurrentUserLocale()));
    regParams.add(new NameValuePair(
            HeidelpayPostParameter.FRONTEND_ONEPAGE, "true"));
    regParams.add(new NameValuePair(
            HeidelpayPostParameter.FRONTEND_NEXT_TARGET,
            "self.location.href"));

}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:27,代碼來源:PaymentServiceProviderBean.java

示例8: testRemoveAce

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
public void testRemoveAce() throws IOException, JsonException {
	String folderUrl = createFolderWithAces(false);
	
	//remove the ace for the testUser principal
	String postUrl = folderUrl + ".deleteAce.html"; 
	List<NameValuePair> postParams = new ArrayList<NameValuePair>();
	postParams.add(new NameValuePair(":applyTo", testUserId));
       Credentials creds = new UsernamePasswordCredentials("admin", "admin");
	assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);

	//fetch the JSON for the acl to verify the settings.
	String getUrl = folderUrl + ".acl.json";

	String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
	assertNotNull(json);

	JsonObject jsonObject = JsonUtil.parseObject(json);
	assertNotNull(jsonObject);
	assertEquals(0, jsonObject.size());
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-launchpad-integration-tests,代碼行數:21,代碼來源:RemoveAcesTest.java

示例9: determineReregistrationLink

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
@Override
public RegistrationLink determineReregistrationLink(RequestData data)
        throws PSPCommunicationException {

    if (data == null) {
        throw new IllegalArgumentException("requestData must not be null!");
    }

    setProxyForHTTPClient(data);
    List<NameValuePair> registrationParameters = initPostParametersForReRegistration(data);
    String regLinkDetails = retrieveRegistrationLinkDetails(
            registrationParameters, data);
    String result = validateLinkDetails(regLinkDetails);
    RegistrationLink link = new RegistrationLink(result, "");

    return link;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:18,代碼來源:PaymentServiceProviderBean.java

示例10: testRemoveAuthorizables

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
public void testRemoveAuthorizables() throws IOException {
	String userId = createTestUser();
	String groupId = createTestGroup();
	
       Credentials creds = new UsernamePasswordCredentials("admin", "admin");

	String getUrl = HTTP_BASE_URL + "/system/userManager/user/" + userId + ".json";
	assertAuthenticatedHttpStatus(creds, getUrl, HttpServletResponse.SC_OK, null); //make sure the profile request returns some data

	getUrl = HTTP_BASE_URL + "/system/userManager/group/" + groupId + ".json";
	assertAuthenticatedHttpStatus(creds, getUrl, HttpServletResponse.SC_OK, null); //make sure the profile request returns some data
	
	String postUrl = HTTP_BASE_URL + "/system/userManager.delete.html";
	List<NameValuePair> postParams = new ArrayList<NameValuePair>();
	postParams.add(new NameValuePair(":applyTo", "group/" + groupId));
	postParams.add(new NameValuePair(":applyTo", "user/" + userId));
	assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
	
	getUrl = HTTP_BASE_URL + "/system/userManager/user/" + userId + ".json";
	assertAuthenticatedHttpStatus(creds, getUrl, HttpServletResponse.SC_NOT_FOUND, null); //make sure the profile request returns some data

	getUrl = HTTP_BASE_URL + "/system/userManager/group/" + groupId + ".json";
	assertAuthenticatedHttpStatus(creds, getUrl, HttpServletResponse.SC_NOT_FOUND, null); //make sure the profile request returns some data
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-launchpad-integration-tests,代碼行數:25,代碼來源:RemoveAuthorizablesTest.java

示例11: getParameter

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
/**
 * Gets the parameter of the specified name. If there exists more than one
 * parameter with the name paramName, then only the first one is returned.
 *
 * @param paramName name of the parameter
 *
 * @return If a parameter exists with the name argument, the coresponding
 *         NameValuePair is returned.  Otherwise null.
 *
 * @since 2.0
 * 
 */
public NameValuePair getParameter(String paramName) {
    LOG.trace("enter PostMethod.getParameter(String)");

    if (paramName == null) {
        return null;
    }

    Iterator iter = this.params.iterator();

    while (iter.hasNext()) {
        NameValuePair parameter = (NameValuePair) iter.next();

        if (paramName.equals(parameter.getName())) {
            return parameter;
        }
    }
    return null;
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:31,代碼來源:PostMethod.java

示例12: extractParams

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
/** 
 * Extracts a map of challenge parameters from an authentication challenge.
 * Keys in the map are lower-cased
 *
 * @param challengeStr the authentication challenge string
 * @return a map of authentication challenge parameters
 * @throws MalformedChallengeException when the authentication challenge string
 *  is malformed
 * 
 * @since 2.0beta1
 */
public static Map extractParams(final String challengeStr)
  throws MalformedChallengeException {
    if (challengeStr == null) {
        throw new IllegalArgumentException("Challenge may not be null"); 
    }
    int idx = challengeStr.indexOf(' ');
    if (idx == -1) {
        throw new MalformedChallengeException("Invalid challenge: " + challengeStr);
    }
    Map map = new HashMap();
    ParameterParser parser = new ParameterParser();
    List params = parser.parse(
        challengeStr.substring(idx + 1, challengeStr.length()), ',');
    for (int i = 0; i < params.size(); i++) {
        NameValuePair param = (NameValuePair) params.get(i);
        map.put(param.getName().toLowerCase(), param.getValue());
    }
    return map;
}
 
開發者ID:jenkinsci,項目名稱:lib-commons-httpclient,代碼行數:31,代碼來源:AuthChallengeParser.java

示例13: deregisterPaymentInformation_CreditCard

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
@Test
public void deregisterPaymentInformation_CreditCard()
        throws PaymentDeregistrationException, XPathExpressionException,
        ParserConfigurationException, SAXException, IOException {

    // setup
    RequestData requestData = createRequestData(CREDIT_CARD);
    PostMethodStub.setStubReturnValue(sampleResponse);
    PaymentInfo pi = createPaymentInfo(
            PaymentCollectionType.PAYMENT_SERVICE_PROVIDER,
            PaymentInfoType.CREDIT_CARD.name());
    pi.setKey(2L);

    // execute
    psp.deregisterPaymentInformation(requestData);

    // assert
    NameValuePair[] requestBodyDetails = PostMethodStub
            .getRequestBodyDetails();
    Assert.assertNotNull("A request must have been generated",
            requestBodyDetails);
    Assert.assertEquals("Wrong number of parameters for the request", 1,
            requestBodyDetails.length);
    validateDeregistrationXMLResponse(pi, requestBodyDetails, "CC");
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:26,代碼來源:PaymentServiceProviderBeanTest.java

示例14: deregisterPaymentInformation_DirectDebit

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
@Test
public void deregisterPaymentInformation_DirectDebit()
        throws PaymentDeregistrationException, XPathExpressionException,
        ParserConfigurationException, SAXException, IOException {

    // setup
    RequestData requestData = createRequestData(DIRECT_DEBIT);
    PostMethodStub.setStubReturnValue(sampleResponse);
    PaymentInfo pi = createPaymentInfo(
            PaymentCollectionType.PAYMENT_SERVICE_PROVIDER,
            PaymentInfoType.CREDIT_CARD.name());
    pi.setKey(2L);

    // execute
    psp.deregisterPaymentInformation(requestData);

    // assert
    NameValuePair[] requestBodyDetails = PostMethodStub
            .getRequestBodyDetails();
    Assert.assertNotNull("A request must have been generated",
            requestBodyDetails);
    Assert.assertEquals("Wrong number of parameters for the request", 1,
            requestBodyDetails.length);
    validateDeregistrationXMLResponse(pi, requestBodyDetails, "DD");
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:26,代碼來源:PaymentServiceProviderBeanTest.java

示例15: testValidatingCorrectFormCredentials

import org.apache.commons.httpclient.NameValuePair; //導入依賴的package包/類
@Test
public void testValidatingCorrectFormCredentials() throws Exception {
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new NameValuePair("j_username", "admin"));
    params.add(new NameValuePair("j_password", "admin"));
    params.add(new NameValuePair("j_validate", "true"));
    HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_OK,
            params, null);
    assertTrue(post.getResponseBodyAsString().length() == 0);

    List<NameValuePair> params2 = new ArrayList<NameValuePair>();
    params2.add(new NameValuePair("j_validate", "true"));
    HttpMethod post2 = H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_OK,
            params2, null);
    assertTrue(post2.getResponseBodyAsString().length() == 0);
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-launchpad-integration-tests,代碼行數:17,代碼來源:AuthenticationResponseCodeTest.java


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