Java Code Examples for com.gargoylesoftware.htmlunit.util.NameValuePair#getValue()

The following examples show how to use com.gargoylesoftware.htmlunit.util.NameValuePair#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FormData.java    From htmlunit with Apache License 2.0 6 votes vote down vote up
/**
 * @param name the name of the field to check
 * @return the first value found for the give name
 */
@JsxFunction({CHROME, FF, FF68, FF60})
public String get(final String name) {
    if (StringUtils.isEmpty(name)) {
        return null;
    }

    final Iterator<NameValuePair> iter = requestParameters_.iterator();
    while (iter.hasNext()) {
        final NameValuePair pair = iter.next();
        if (name.equals(pair.getName())) {
            return pair.getValue();
        }
    }
    return null;
}
 
Example 2
Source File: FormData.java    From HtmlUnit-Android with Apache License 2.0 6 votes vote down vote up
/**
 * @param name the name of the field to check
 * @return the first value found for the give name
 */
@JsxFunction({CHROME, FF})
public String get(final String name) {
    if (StringUtils.isEmpty(name)) {
        return null;
    }

    final Iterator<NameValuePair> iter = requestParameters_.iterator();
    while (iter.hasNext()) {
        final NameValuePair pair = iter.next();
        if (name.equals(pair.getName())) {
            return pair.getValue();
        }
    }
    return null;
}
 
Example 3
Source File: WebResponse.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the value of the specified response header.
 * @param headerName the name of the header whose value is to be returned
 * @return the header value, {@code null} if no response header exists with this name
 */
public String getResponseHeaderValue(final String headerName) {
    for (final NameValuePair pair : responseData_.getResponseHeaders()) {
        if (pair.getName().equalsIgnoreCase(headerName)) {
            return pair.getValue();
        }
    }
    return null;
}
 
Example 4
Source File: WebResponseData.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
private static String getHeader(final List<NameValuePair> headers, final String name) {
    for (final NameValuePair header : headers) {
        final String headerName = header.getName().trim();
        if (name.equalsIgnoreCase(headerName)) {
            return header.getValue();
        }
    }

    return null;
}
 
Example 5
Source File: WebResponse.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the value of the specified response header.
 * @param headerName the name of the header whose value is to be returned
 * @return the header value, {@code null} if no response header exists with this name
 */
public String getResponseHeaderValue(final String headerName) {
    for (final NameValuePair pair : responseData_.getResponseHeaders()) {
        if (pair.getName().equalsIgnoreCase(headerName)) {
            return pair.getValue();
        }
    }
    return null;
}
 
Example 6
Source File: WebResponseData.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
private static String getHeader(final List<NameValuePair> headers, final String name) {
    for (final NameValuePair header : headers) {
        final String headerName = header.getName().trim();
        if (name.equalsIgnoreCase(headerName)) {
            return header.getValue();
        }
    }

    return null;
}