org.apache.commons.httpclient.NameValuePair.getValue()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(72)

本文整理了Java中org.apache.commons.httpclient.NameValuePair.getValue()方法的一些代码示例,展示了NameValuePair.getValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NameValuePair.getValue()方法的具体详情如下:
包路径:org.apache.commons.httpclient.NameValuePair
类名称:NameValuePair
方法名:getValue

NameValuePair.getValue介绍

[英]Return the current value.
[中]返回当前值。

代码示例

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * 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);
  }
}

代码示例来源:origin: commons-httpclient/commons-httpclient

&& paramValue.equals(pair.getValue())) {
iter.remove();
return true;

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * 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);
  }
}

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Adds a new parameter to be used in the POST request body.
 *
 * @param param The parameter to add.
 *
 * @throws IllegalArgumentException if the argument is null or contains
 *         null values
 *
 * @since 2.0
 */
public void addParameter(NameValuePair param) 
throws IllegalArgumentException {
  LOG.trace("enter PostMethod.addParameter(NameValuePair)");
  if (param == null) {
    throw new IllegalArgumentException("NameValuePair may not be null");
  }
  addParameter(param.getName(), param.getValue());
}

代码示例来源:origin: commons-httpclient/commons-httpclient

/** 
 * 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;
}

代码示例来源:origin: commons-httpclient/commons-httpclient

this.charset = charsetPair.getValue();
} else if (charset != null && charsetPair == null) {

代码示例来源:origin: commons-httpclient/commons-httpclient

if (pair.getValue() != null) {
  buf.append(codec.encode(pair.getValue(), charset));

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Constructor with array of characters.
 *
 * @param chars the array of characters
 * @param offset - the initial offset.
 * @param length - the length.
 * 
 * @since 3.0
 */
public HeaderElement(char[] chars, int offset, int length) {
  this();
  if (chars == null) {
    return;
  }
  ParameterParser parser = new ParameterParser();
  List params = parser.parse(chars, offset, length, ';');
  if (params.size() > 0) {
    NameValuePair element = (NameValuePair) params.remove(0);
    setName(element.getName());  
    setValue(element.getValue());
    if (params.size() > 0) {
      this.parameters = (NameValuePair[])
        params.toArray(new NameValuePair[params.size()]);    
    }
  }
}

代码示例来源:origin: commons-httpclient/commons-httpclient

final String paramValue = attribute.getValue();

代码示例来源:origin: commons-httpclient/commons-httpclient

final String paramValue = attribute.getValue();

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Returns the character set from the <tt>Content-Type</tt> header.
 * 
 * @param contentheader The content header.
 * @return String The character set.
 */
protected String getContentCharSet(Header contentheader) {
  LOG.trace("enter getContentCharSet( Header contentheader )");
  String charset = null;
  if (contentheader != null) {
    HeaderElement values[] = contentheader.getElements();
    // I expect only one header element to be there
    // No more. no less
    if (values.length == 1) {
      NameValuePair param = values[0].getParameterByName("charset");
      if (param != null) {
        // If I get anything "funny" 
        // UnsupportedEncondingException will result
        charset = param.getValue();
      }
    }
  }
  if (charset == null) {
    charset = getParams().getContentCharset();
    if (LOG.isDebugEnabled()) {
      LOG.debug("Default charset used: " + charset);
    }
  }
  return charset;
}

代码示例来源:origin: commons-httpclient/commons-httpclient

final String paramValue = attribute.getValue();

代码示例来源:origin: commons-httpclient/commons-httpclient

String paramValue = attribute.getValue();

代码示例来源:origin: apache/cloudstack

/**
 * Builds parameters string with command and encoded param values
 * @param command
 * @param params
 * @return
 */
protected static String buildParams(String command, List<NameValuePair> params) {
  StringBuffer paramString = new StringBuffer("command=" + command);
  Iterator<NameValuePair> iter = params.iterator();
  try {
    while (iter.hasNext()) {
      NameValuePair param = iter.next();
      if (param.getValue() != null && !(param.getValue().isEmpty())) {
        paramString.append("&" + param.getName() + "=" + URLEncoder.encode(param.getValue(), "UTF-8"));
      }
    }
  } catch (UnsupportedEncodingException e) {
    s_logger.error(e.getMessage());
    return null;
  }
  return paramString.toString();
}

代码示例来源:origin: org.codehaus.xfire/xfire-core

/**
 * @return
 */

public boolean hasResponse()
{
  NameValuePair pair = postMethod.getResponseHeader("Content-Type");
  if(pair == null) return false;
  
  String ct = pair.getValue();
  
  return ct != null && ct.length() > 0;
}

代码示例来源:origin: info.kwarc.sally4/sally4-servlet

@Override
  public void process(Exchange exchange) throws Exception {
    HashMap<String, String> result = new HashMap<String, String>();
    for (NameValuePair pairs  : (List<NameValuePair>) parser.parse(exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class), '&')) {
      result.put(pairs.getName(), pairs.getValue());
    }
    exchange.getIn().setHeader(QueryMapHeader, result);
  }
}

代码示例来源:origin: org.jenkins-ci/htmlunit

/**
 * {@inheritDoc}
 */
public String getResponseHeaderValue(final String headerName) {
  for (final NameValuePair pair : responseData_.getResponseHeaders()) {
    if (pair.getName().equalsIgnoreCase(headerName)) {
      return pair.getValue();
    }
  }
  return null;
}

代码示例来源:origin: net.disy.htmlunit/htmlunit

/**
 * {@inheritDoc}
 */
public String getResponseHeaderValue(final String headerName) {
  for (final NameValuePair pair : responseData_.getResponseHeaders()) {
    if (pair.getName().equalsIgnoreCase(headerName)) {
      return pair.getValue();
    }
  }
  return null;
}

代码示例来源:origin: xmlrpc/xmlrpc-client

protected boolean isResponseGzipCompressed() {
  Header h = method.getResponseHeader( "Content-Encoding" );
  if (h == null) {
    return false;
  } else {
    return HttpUtil.isUsingGzipEncoding(h.getValue());
  }
}

代码示例来源:origin: org.apache.axis2/axis2-transport-http

private String processCookieHeader(HeaderElement element) {
  String cookie = element.getName() + "=" + element.getValue();
  NameValuePair[] parameters = element.getParameters();
  for (int j = 0; parameters != null && j < parameters.length; j++) {
    NameValuePair parameter = parameters[j];
    cookie = cookie + "; " + parameter.getName() + "=" + parameter.getValue();
  }
  return cookie;
}

相关文章