org.restlet.data.Method.equals()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(95)

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

Method.equals介绍

暂无

代码示例

代码示例来源:origin: org.sonatype.nexus.plugins/nexus-yum-repository-plugin

@Override
public Object getPayloadInstance(Method method) {
 if (POST.equals(method)) {
  return "";
 }
 return null;
}

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

/**
 * Indicates if the given method exposes its WADL description. By default,
 * HEAD and OPTIONS are not exposed. This method is called by
 * {@link #describe(String, ResourceInfo)}.
 * 
 * @param method
 *            The method
 * @return True if the method exposes its description, false otherwise.
 */
public boolean canDescribe(Method method) {
  return !(Method.HEAD.equals(method) || Method.OPTIONS.equals(method));
}

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

protected boolean getReadOnly() {
  return Method.GET.equals(getMethod());
}

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

/**
 * Indicates if a content is available and can be sent. Several conditions
 * must be met: the method must allow the sending of content, the content
 * must exists and have some available data.
 * 
 * @return True if a content is available and can be sent.
 */
@Override
public boolean isEntityAvailable() {
  if (getMethod().equals(Method.GET) || getMethod().equals(Method.HEAD)
      || getMethod().equals(Method.DELETE)) {
    return false;
  }
  return super.isEntityAvailable();
}

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

/**
 * Indicates if a content is available and can be sent. Several conditions
 * must be met: the method must allow the sending of content, the content
 * must exists and have some available data.
 * 
 * @return True if a content is available and can be sent.
 */
@Override
public boolean isEntityAvailable() {
  // The declaration of the "result" variable is a workaround for the GWT
  // platform.
  boolean result = (Method.GET.equals(getMethod())
      || Method.HEAD.equals(getMethod()));
  if (result) {
    return false;
  }
  return super.isEntityAvailable();
}

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

@Override
  protected void handleLocal(Request request, Response response,
      String decodedPath) {
    if (Method.GET.equals(request.getMethod())
        || Method.HEAD.equals(request.getMethod())) {
      handleEntityGet(request, response, getEntity(decodedPath));
    } else {
      response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
      response.getAllowedMethods().add(Method.GET);
      response.getAllowedMethods().add(Method.HEAD);
    }
  }
}

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

protected void handleFile(Request request, Response response, String decodedPath) {
  if (GET.equals(request.getMethod())
      || HEAD.equals(request.getMethod())) {
    handleEntityGet(request, response, getEntity(decodedPath));
  } else if (PUT.equals(request.getMethod())) {
    handleFilePut(request, response, decodedPath, new File(decodedPath));
  } else if (DELETE.equals(request.getMethod())) {
    handleFileDelete(response, new File(decodedPath));
  } else {
    response.setStatus(CLIENT_ERROR_METHOD_NOT_ALLOWED);
    response.getAllowedMethods().add(GET);
    response.getAllowedMethods().add(HEAD);
    response.getAllowedMethods().add(PUT);
    response.getAllowedMethods().add(DELETE);
  }
}

代码示例来源:origin: org.sonatype.nexus/nexus-rest-client-java

public Response sendRequest( Method method, String url, Representation representation )
{
  this.logger.debug( "Method: " + method.getName() + " url: " + url );
  Request request = new Request();
  request.setResourceRef( url );
  request.setMethod( method );
  if ( !Method.GET.equals( method ) && !Method.DELETE.equals( method ) )
  {
    request.setEntity( representation );
  }
  request.setChallengeResponse( this.challenge );
  return this.restClient.handle( request );
}

代码示例来源:origin: org.geowebcache/gwc-rest

public void handle(Request request, Response response) {
  if (request.getMethod().equals(Method.GET)) {
    doGet(request, response);
  } else {
    response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
  }
}

代码示例来源:origin: org.qi4j.library/org.qi4j.library.rest-server

private String getUsecaseName( Request request )
{
  if( request.getMethod().equals( org.restlet.data.Method.DELETE ) )
  {
    return "delete";
  }
  else
  {
    return request.getResourceRef().getLastSegment();
  }
}

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

/**
 * Indicates if the request is an attempt to log out and should be intercepted.
 * 
 * @param request
 *            The current request.
 * @param response
 *            The current response.
 * @return True if the request is an attempt to log out and should be intercepted.
 */
protected boolean isLoggingOut(final Request request, final Response response)
{
  return this.isInterceptingLogout()
      && this.getLogoutPath().equals(request.getResourceRef().getRemainingPart(false, false))
      && (Method.GET.equals(request.getMethod()) || Method.POST.equals(request.getMethod()));
}

代码示例来源:origin: apache/attic-polygene-java

private String getUsecaseName( Request request )
{
  if( request.getMethod().equals( org.restlet.data.Method.DELETE ) )
  {
    return "delete";
  }
  else
  {
    return request.getResourceRef().getLastSegment();
  }
}

代码示例来源:origin: org.geowebcache/gwc-rest

public void handle(Request request, Response response) {
  Method met = request.getMethod();
  if (met.equals(Method.GET)) {
    doGet(request, response);
  } else {
    throw new RestletException("Method not allowed", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
  }
}

代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.rest-server

private String getUsecaseName( Request request )
{
  if( request.getMethod().equals( org.restlet.data.Method.DELETE ) )
  {
    return "delete";
  }
  else
  {
    return request.getResourceRef().getLastSegment();
  }
}

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

/**
 * Indicates if the request is an attempt to log in and should be intercepted.
 * 
 * @param request
 *            The current request.
 * @param response
 *            The current response.
 * @return True if the request is an attempt to log in and should be intercepted.
 */
protected boolean isLoggingIn(final Request request, final Response response)
{
  return this.isInterceptingLogin()
      && this.getLoginPath().equals(request.getResourceRef().getRemainingPart(false, false))
      && Method.POST.equals(request.getMethod());
}

代码示例来源:origin: org.geowebcache/gwc-rest

public void handle(Request request, Response response) {
  Method met = request.getMethod();
  try {
    if (met.equals(Method.GET)) {
      doGet(request, response);
    } else {
      throw new RestletException("Method not allowed",
          Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
    }
  } catch (RestletException re) {
    response.setEntity(re.getRepresentation());
    response.setStatus(re.getStatus());
  } catch (Exception e) {
    // Either GeoWebCacheException or IOException
    response.setEntity(e.getMessage() + " " + e.toString(), MediaType.TEXT_PLAIN);
    response.setStatus(Status.SERVER_ERROR_INTERNAL);
    e.printStackTrace();
  }
}

代码示例来源:origin: org.geowebcache/gwc-rest

public void handle(Request request, Response response) {
  Method met = request.getMethod();
  try {
    if (met.equals(Method.GET)) {
      doGet(request, response);
    } else if (met.equals(Method.POST)) {
      doPost(request, response);
    } else {
      throw new RestletException("Method not allowed",
          Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
    }
  } catch (RestletException re) {
    response.setEntity(re.getRepresentation());
    response.setStatus(re.getStatus());
  } catch (IOException ioe) {
    response.setEntity("Encountered IO error " + ioe.getMessage(), MediaType.TEXT_PLAIN);
    response.setStatus(Status.SERVER_ERROR_INTERNAL);
  }
}

代码示例来源:origin: apache/attic-polygene-java

@Override
  public boolean writeRequest(Object requestObject, Request request) throws ResourceException
  {
   if (requestObject instanceof Form)
   {
     // Form as query parameters
     if (request.getMethod().equals(Method.GET))
      request.getResourceRef().setQuery(((Form)requestObject).getQueryString());
     else
      request.setEntity(((Form)requestObject).getWebRepresentation(CharacterSet.UTF_8));

     return true;
   }

   return false;
  }
}

代码示例来源:origin: org.geowebcache/gwc-rest

public void handle(Request request, Response response) {
  Method met = request.getMethod();
  try {
    if (met.equals(Method.POST)) {
      doPost(request, response);
    } else {
      throw new RestletException("Method not allowed",
          Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
    }
  } catch (RestletException re) {
    response.setEntity(re.getRepresentation());
    response.setStatus(re.getStatus());
  }
}

代码示例来源:origin: org.geowebcache/gwc-rest

public void handle(Request request, Response response) {
  Method met = request.getMethod();
  try {
    if (met.equals(Method.POST)) {
      doPost(request, response);
    } else {
      throw new RestletException("Method not allowed",
          Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
    }
  } catch (RestletException re) {
    response.setEntity(re.getRepresentation());
    response.setStatus(re.getStatus());
  } catch (IOException ioe) {
    response.setEntity("Encountered IO error " + ioe.getMessage(), MediaType.TEXT_PLAIN);
    response.setStatus(Status.SERVER_ERROR_INTERNAL);
  }
}

相关文章

微信公众号

最新文章

更多