当前位置: 首页>>代码示例>>Java>>正文


Java Response.getEntity方法代码示例

本文整理汇总了Java中org.restlet.Response.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java Response.getEntity方法的具体用法?Java Response.getEntity怎么用?Java Response.getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.restlet.Response的用法示例。


在下文中一共展示了Response.getEntity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: populateRestletProducerException

import org.restlet.Response; //导入方法依赖的package包/类
protected RestletOperationException populateRestletProducerException(Exchange exchange, Response response, int responseCode) {
    RestletOperationException exception;
    String uri = response.getRequest().getResourceRef().toString();
    String statusText = response.getStatus().getDescription();
    Map<String, String> headers = parseResponseHeaders(response, exchange);
    String copy;
    if (response.getEntity() != null) {
        try {
            copy = response.getEntity().getText();
        } catch (Exception ex) {
            copy = ex.toString();
        }
    } else {
        copy = response.toString();
    }
    if (responseCode >= 300 && responseCode < 400) {
        String redirectLocation;
        if (response.getStatus().isRedirection()) {
            redirectLocation = response.getLocationRef().getHostIdentifier();
            exception = new RestletOperationException(uri, responseCode, statusText, redirectLocation, headers, copy);
        } else {
            //no redirect location
            exception = new RestletOperationException(uri, responseCode, statusText, null, headers, copy);
        }
    } else {
        //internal server error(error code 500)
        exception = new RestletOperationException(uri, responseCode, statusText, null, headers, copy);
    }

    return exception;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:32,代码来源:RestletProducer.java

示例2: readResponse

import org.restlet.Response; //导入方法依赖的package包/类
@Override
public Object readResponse( Response response, Class<?> resultType )
{
   if (resultType.equals(Representation.class))
      return response.getEntity();

   for (ResponseReader responseReader : responseReaders)
   {
      Object result = responseReader.readResponse( response, resultType );
      if (result != null)
         return result;
   }

   return null;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:16,代码来源:ResponseReaderDelegator.java

示例3: toRepresentation

import org.restlet.Response; //导入方法依赖的package包/类
@Override
public Representation toRepresentation( Status status, Request request, Response response )
{
	if( isEnabled() )
	{
		ConcurrentMap<String, Object> attributes = response.getAttributes();

		Object passthrough = attributes.get( PASSTHROUGH_ATTRIBUTE );
		if( ( passthrough != null ) && (Boolean) passthrough )
			// Pass through
			return response.getEntity();

		Restlet handler = handlers.get( status.getCode() );
		if( handler != null )
		{
			// Reset the response
			response.setStatus( Status.SUCCESS_OK );
			response.setEntity( null );

			// Clean up saved information
			CachingUtil.clearExistingValidDocumentName( request );

			// Delegate
			handler.handle( request, response );

			// Return the status
			response.setStatus( status );

			Representation representation = response.getEntity();
			if( representation != null )
			{
				// Avoid client caching, which would require other
				// interchanges with the client that we can't handle from
				// here
				representation.setExpirationDate( null );
				representation.setModificationDate( null );
				representation.setTag( null );
			}

			attributes.put( PASSTHROUGH_ATTRIBUTE, true );
			return representation;
		}

		if( isFallback )
			// Fallbacks don't override the entity if there are no handlers
			return response.getEntity();

		if( isDebugging() && ( status.getThrowable() != null ) )
		{
			// Use the debug representation for exceptions
			attributes.put( PASSTHROUGH_ATTRIBUTE, true );
			if( debugHeader != null )
				RestletUtil.getResponseHeaders( response ).set( debugHeader, "error" );
			return createDebugRepresentation( status, request, response );
		}
	}

	return super.toRepresentation( status, request, response );
}
 
开发者ID:tliron,项目名称:prudence,代码行数:60,代码来源:DelegatedStatusService.java


注:本文中的org.restlet.Response.getEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。