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

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

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

NameValuePair.getName介绍

[英]Return the name.
[中]返回名称。

代码示例

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

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

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

NameValuePair pair = (NameValuePair) iter.next();
if (paramName.equals(pair.getName())) {
  iter.remove();
  removed = true;

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

/**
 * Returns parameter with the given name, if found. Otherwise null 
 * is returned
 *
 * @param name The name to search by.
 * @return NameValuePair parameter with the given name
 */
public NameValuePair getParameterByName(String name) {
  LOG.trace("enter HeaderElement.getParameterByName(String)");
  if (name == null) {
    throw new IllegalArgumentException("Name may not be null");
  } 
  NameValuePair found = null;
  NameValuePair parameters[] = getParameters();
  if (parameters != null) {
    for (int i = 0; i < parameters.length; i++) {
      NameValuePair current = parameters[ i ];
      if (current.getName().equalsIgnoreCase(name)) {
        found = current;
        break;
      }
    }
  }
  return found;
}

代码示例来源: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

NameValuePair pair = (NameValuePair) iter.next();
if (paramName.equals(pair.getName())
  && paramValue.equals(pair.getValue())) {
  iter.remove();

代码示例来源: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

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

throw new IllegalArgumentException("Attribute may not be null.");
if (attribute.getName() == null) {
  throw new IllegalArgumentException("Attribute Name may not be null.");
  throw new IllegalArgumentException("Cookie may not be null.");
final String paramName = attribute.getName().toLowerCase();
final String paramValue = attribute.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

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) {

代码示例来源: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

throw new IllegalArgumentException("Cookie may not be null.");
final String paramName = attribute.getName().toLowerCase();
final String paramValue = attribute.getValue();

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

for (int j = parameters.length - 1; j >= 0; j--) {
  NameValuePair param = parameters[j];
  attribmap.put(param.getName().toLowerCase(), param);

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

buffer.append(", ");
boolean noQuotes = "nc".equals(param.getName()) ||
          "qop".equals(param.getName());
this.formatter.setAlwaysUseQuotes(!noQuotes);
this.formatter.format(buffer, param);

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

throw new IllegalArgumentException("Cookie may not be null.");
final String paramName = attribute.getName().toLowerCase();
final String paramValue = attribute.getValue();

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

throw new IllegalArgumentException("Cookie may not be null.");
final String paramName = attribute.getName().toLowerCase();
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: 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;
}

相关文章