org.restlet.util.Series.getFirst()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(144)

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

Series.getFirst介绍

[英]Returns the first parameter found with the given name.
[中]返回使用给定名称找到的第一个参数。

代码示例

代码示例来源:origin: org.restlet/org.restlet

/**
 * Returns the first parameter found with the given name.
 * 
 * @param name
 *            The parameter name (case sensitive).
 * @return The first parameter found with the given name.
 */
public E getFirst(String name) {
  return getFirst(name, false);
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Returns the first parameter found with the given name.
 * 
 * @param name
 *            The parameter name (case sensitive).
 * @return The first parameter found with the given name.
 */
public T getFirst(String name) {
  return getFirst(name, false);
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

/**
 * Returns the first parameter found with the given name.
 * 
 * @param name
 *            The parameter name (case sensitive).
 * @return The first parameter found with the given name.
 */
public T getFirst(String name) {
  return getFirst(name, false);
}

代码示例来源:origin: ontopia/ontopia

public static Parameter getParameter(Context context, String name) {
  Series<Parameter> parameters = getParameters(context);
  if (parameters == null) {
    return null;
  }
  return parameters.getFirst(name);
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.wadl

/**
 * Returns the first parameter found in the current context (entity, query,
 * headers, etc) with the given name.
 * 
 * @param name
 *            The parameter name.
 * @return The first parameter found with the given name.
 */
protected NamedValue<String> getParameter(String name) {
  NamedValue<String> result = null;
  Series<? extends NamedValue<String>> set = getParameters(name);
  if (set != null) {
    result = set.getFirst(name);
  }
  return result;
}

代码示例来源:origin: org.restlet/org.restlet

/**
 * Returns the value of the first parameter found with the given name.
 * 
 * @param name
 *            The parameter name.
 * @param ignoreCase
 *            Indicates if the name comparison is case sensitive.
 * @param defaultValue
 *            The default value to return if no matching parameter found.
 * @return The value of the first parameter found with the given name or the
 *         default value.
 */
public String getFirstValue(String name, boolean ignoreCase,
    String defaultValue) {
  String result = defaultValue;
  final Parameter param = getFirst(name, ignoreCase);
  if (param != null) {
    result = param.getValue();
  }
  return result;
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs

public Object getFirst(String headerName) {
  if (this.jaxRsRespHeaders != null) {
    Object rt = this.jaxRsRespHeaders.getFirst(headerName);
    if (rt != null) {
      return rt;
    }
  }
  Series<Header> headers = getHeaders();
  if (headers != null) {
    Header first = headers.getFirst(headerName, true);
    if (first == null) {
      return null;
    }
    return first.getValue();
  }
  return null;
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

/**
 * Returns the value of the first parameter found with the given name.
 * 
 * @param name
 *            The parameter name.
 * @param ignoreCase
 *            Indicates if the name comparison is case sensitive.
 * @param defaultValue
 *            The default value to return if no matching parameter found or
 *            if the parameter has a null value.
 * @return The value of the first parameter found with the given name or the
 *         default value.
 */
public String getFirstValue(String name, boolean ignoreCase,
    String defaultValue) {
  String result = defaultValue;
  NamedValue<String> param = getFirst(name, ignoreCase);
  if ((param != null) && (param.getValue() != null)) {
    result = param.getValue();
  }
  return result;
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Returns the value of the first parameter found with the given name.
 * 
 * @param name
 *            The parameter name.
 * @param ignoreCase
 *            Indicates if the name comparison is case sensitive.
 * @param defaultValue
 *            The default value to return if no matching parameter found or
 *            if the parameter has a null value.
 * @return The value of the first parameter found with the given name or the
 *         default value.
 */
public String getFirstValue(String name, boolean ignoreCase,
    String defaultValue) {
  String result = defaultValue;
  NamedValue<String> param = getFirst(name, ignoreCase);
  if ((param != null) && (param.getValue() != null)) {
    result = param.getValue();
  }
  return result;
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs

/**
   * @param params
   * @param paramName
   * @return
   * @throws ConvertQueryParamException
   */
  Object getParamValue(final Series<Parameter> params,
      final String paramName) throws ConvertParameterException {
    Series<Parameter> parameters = params.subList(paramName);
    if (this.collType == null) { // no collection parameter
      Parameter firstFormParam = params.getFirst(paramName);
      String queryParamValue = WrapperUtil.getValue(firstFormParam);
      return convertParamValue(queryParamValue);
    }
    NamedValuesIter queryParamValueIter;
    queryParamValueIter = new NamedValuesIter(parameters);
    return convertParamValues(queryParamValueIter);
  }
}

代码示例来源:origin: com.github.ansell.restlet-utils/restlet-utils

/**
 * Restores credentials from the cookie named {@link #getCookieName()} if available. The usual
 * processing is the followed.
 */
@Override
protected boolean authenticate(final Request request, final Response response)
{
  // Restore credentials from the cookie
  final Cookie credentialsCookie = request.getCookies().getFirst(this.getCookieName());
  
  if(credentialsCookie != null)
  {
    ChallengeResponse credentials = this.parseCredentials(credentialsCookie.getValue());
    if(credentials == null)
    {
      response.getCookieSettings().removeAll(this.getCookieName());
    }
    else
    {
      request.setChallengeResponse(credentials);
    }
  }
  
  this.log.debug("Calling super.authenticate");
  return super.authenticate(request, response);
}

代码示例来源:origin: org.restlet.osgi/org.restlet

Parameter param = getParameters().get(i);
Parameter includedParam = includedMediaType
    .getParameters().getFirst(param.getName());

代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs

if (this.collType == null) { // no collection parameter
  String firstCookieValue = WrapperUtil.getValue(cookies
      .getFirst(cookieName));
  return convertParamValue(firstCookieValue);

代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs

@Override
  public Object getParamValue() {
    Series<Header> httpHeaders = Util.getHttpHeaders(this.tlContext
        .get().getRequest());
    String headerName = this.headerParam.value();
    try {
      if (this.collType == null) { // no collection parameter
        final String firstHeader = WrapperUtil.getValue(httpHeaders
            .getFirst(headerName, true));
        return convertParamValue(firstHeader);
      }
      return convertParamValues(new NamedValuesIter(
          httpHeaders.subList(headerName, true)));
    } catch (ConvertParameterException e) {
      throw new ConvertHeaderParamException(e);
    }
  }
}

代码示例来源:origin: org.restlet.jse/org.restlet.example

@Override
protected void afterHandle(Request request, Response response) {
  super.afterHandle(request, response);
  Cookie cookie = request.getCookies().getFirst("Credentials");
  if (request.getClientInfo().isAuthenticated() && (cookie == null)) {
    String identifier = request.getChallengeResponse().getIdentifier();
    String secret = new String(request.getChallengeResponse()
        .getSecret());
    CookieSetting cookieSetting = new CookieSetting("Credentials",
        identifier + "=" + secret);
    cookieSetting.setAccessRestricted(true);
    cookieSetting.setPath("/");
    cookieSetting.setComment("Unsecured cookie based authentication");
    cookieSetting.setMaxAge(30);
    response.getCookieSettings().add(cookieSetting);
  }
}

代码示例来源:origin: org.restlet.jse/org.restlet.example

@Override
protected void afterHandle(Request request, Response response) {
  super.afterHandle(request, response);
  Cookie cookie = request.getCookies().getFirst("Credentials");
  if (request.getClientInfo().isAuthenticated() && (cookie == null)) {
    String identifier = request.getChallengeResponse().getIdentifier();
    String secret = new String(request.getChallengeResponse()
        .getSecret());
    CookieSetting cookieSetting = new CookieSetting("Credentials",
        identifier + "=" + secret);
    cookieSetting.setAccessRestricted(true);
    cookieSetting.setPath("/");
    cookieSetting.setComment("Unsecured cookie based authentication");
    cookieSetting.setMaxAge(30);
    response.getCookieSettings().add(cookieSetting);
  }
}

代码示例来源:origin: org.restlet.jse/org.restlet.example

@Override
protected int beforeHandle(Request request, Response response) {
  Cookie cookie = request.getCookies().getFirst("Credentials");
  if (cookie != null) {
    // Extract the challenge response from the cookie
    String[] credentials = cookie.getValue().split("=");
    if (credentials.length == 2) {
      String identifier = credentials[0];
      String secret = credentials[1];
      request.setChallengeResponse(new ChallengeResponse(
          ChallengeScheme.HTTP_COOKIE, identifier, secret));
    }
  } else if (Method.POST.equals(request.getMethod())
      && request.getResourceRef().getQueryAsForm().getFirst("login") != null) {
    // Intercepting a login form
    Form credentials = new Form(request.getEntity());
    String identifier = credentials.getFirstValue("identifier");
    String secret = credentials.getFirstValue("secret");
    request.setChallengeResponse(new ChallengeResponse(
        ChallengeScheme.HTTP_COOKIE, identifier, secret));
    // Continue call processing to return the target representation if
    // authentication is successful or a new login page
    request.setMethod(Method.GET);
  }
  return super.beforeHandle(request, response);
}

代码示例来源:origin: org.restlet.jse/org.restlet.example

@Override
protected int beforeHandle(Request request, Response response) {
  Cookie cookie = request.getCookies().getFirst("Credentials");
  if (cookie != null) {
    // Extract the challenge response from the cookie
    String[] credentials = cookie.getValue().split("=");
    if (credentials.length == 2) {
      String identifier = credentials[0];
      String secret = credentials[1];
      request.setChallengeResponse(new ChallengeResponse(
          ChallengeScheme.HTTP_COOKIE, identifier, secret));
    }
  } else if (Method.POST.equals(request.getMethod())
      && request.getResourceRef().getQueryAsForm().getFirst("login") != null) {
    // Intercepting a login form
    Form credentials = new Form(request.getEntity());
    String identifier = credentials.getFirstValue("identifier");
    String secret = credentials.getFirstValue("secret");
    request.setChallengeResponse(new ChallengeResponse(
        ChallengeScheme.HTTP_COOKIE, identifier, secret));
    // Continue call processing to return the target representation if
    // authentication is successful or a new login page
    request.setMethod(Method.GET);
  }
  return super.beforeHandle(request, response);
}

代码示例来源:origin: com.github.ansell.restlet-utils/restlet-utils

CookieSetting credentialsCookie = response.getCookieSettings().getFirst(this.getCookieName());

代码示例来源:origin: org.restlet/org.restlet

if (oHeaders != null) {
  final Series<Parameter> headers = (Series<Parameter>) oHeaders;
  if (headers.getFirst("Content-Range", true) != null) {
    getResponse()
        .setStatus(

相关文章