本文整理匯總了Java中org.restlet.Request.getAttributes方法的典型用法代碼示例。如果您正苦於以下問題:Java Request.getAttributes方法的具體用法?Java Request.getAttributes怎麽用?Java Request.getAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.restlet.Request
的用法示例。
在下文中一共展示了Request.getAttributes方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import org.restlet.Request; //導入方法依賴的package包/類
@Override
public T create( Class<T> entityType, Request request, Response response, Context context )
{
final Map<String, Object> attributes = request.getAttributes();
String id = (String) attributes.get( "id" );
ValueBuilder<T> builder = vbf.newValueBuilderWithState(
resourceType,
descriptor -> findValue( attributes, descriptor ),
descriptor -> null,
descriptor -> null,
descriptor -> null
);
//noinspection unchecked
ServerResource.Parameters<T> params = builder.prototypeFor( ServerResource.Parameters.class );
params.id().set( id );
params.entityType().set( entityType );
params.context().set( this.context );
params.request().set( request );
params.router().set( router );
params.response().set( response );
return builder.newInstance();
}
示例2: getExistingDocumentDescriptor
import org.restlet.Request; //導入方法依賴的package包/類
/**
* The existing document descriptor.
*
* @param request
* The request
* @param clear
* Whether to clear it
* @return The existing document descriptor
*/
@SuppressWarnings("unchecked")
public static DocumentDescriptor<Executable> getExistingDocumentDescriptor( Request request, boolean clear )
{
ConcurrentMap<String, Object> attributes = request.getAttributes();
if( clear )
return (DocumentDescriptor<Executable>) attributes.remove( DOCUMENT_DESCRIPTOR_ATTRIBUTE );
else
return (DocumentDescriptor<Executable>) attributes.get( DOCUMENT_DESCRIPTOR_ATTRIBUTE );
}
示例3: clearExistingValidDocumentName
import org.restlet.Request; //導入方法依賴的package包/類
/**
* Removes existing valid document names.
*
* @param request
* The request
*/
public static void clearExistingValidDocumentName( Request request )
{
ConcurrentMap<String, Object> attributes = request.getAttributes();
attributes.remove( DelegatedResource.class.getCanonicalName() + VALID_DOCUMENT_NAME_ATTRIBUTE );
attributes.remove( GeneratedTextResource.class.getCanonicalName() + VALID_DOCUMENT_NAME_ATTRIBUTE );
}
示例4: getValidDocumentName
import org.restlet.Request; //導入方法依賴的package包/類
/**
* The valid document name, based on the remaining part (wildcard) of the
* reference.
* <p>
* Cached as a request attribute.
*
* @param request
* The request
* @return The valid document name
* @throws ResourceException
*/
public String getValidDocumentName( Request request ) throws ResourceException
{
ConcurrentMap<String, Object> attributes = request.getAttributes();
String documentName = (String) attributes.get( prefix + VALID_DOCUMENT_NAME_ATTRIBUTE );
if( documentName == null )
{
documentName = request.getResourceRef().getRemainingPart( true, false );
documentName = this.attributes.validateDocumentName( documentName );
attributes.put( prefix + VALID_DOCUMENT_NAME_ATTRIBUTE, documentName );
}
return documentName;
}
示例5: beforeHandle
import org.restlet.Request; //導入方法依賴的package包/類
@Override
protected int beforeHandle( Request request, Response response )
{
ConcurrentMap<String, Object> attributes = request.getAttributes();
for( Map.Entry<String, Object> entry : values.entrySet() )
{
Object value = entry.getValue();
if( value instanceof Template )
value = ( (Template) value ).format( request, response );
attributes.put( entry.getKey(), value );
}
return CONTINUE;
}
示例6: getExistingKey
import org.restlet.Request; //導入方法依賴的package包/類
/**
* The existing cache key.
*
* @param request
* The request
* @param clear
* Whether to clear it
* @return The existing cache key
*/
public static String getExistingKey( Request request, boolean clear )
{
ConcurrentMap<String, Object> attributes = request.getAttributes();
if( clear )
return (String) attributes.remove( CACHE_KEY_ATTRIBUTE );
else
return (String) attributes.get( CACHE_KEY_ATTRIBUTE );
}
示例7: getExistingKeyForEncoding
import org.restlet.Request; //導入方法依賴的package包/類
/**
* The existing cache key for the encoding.
*
* @param request
* The request
* @param clear
* Whether to clear it
* @return The existing cache key for the encoding
*/
public static String getExistingKeyForEncoding( Request request, boolean clear )
{
ConcurrentMap<String, Object> attributes = request.getAttributes();
if( clear )
return (String) attributes.remove( CACHE_KEY_FOR_ENCODING_ATTRIBUTE );
else
return (String) attributes.get( CACHE_KEY_FOR_ENCODING_ATTRIBUTE );
}
示例8: getExistingValidEntry
import org.restlet.Request; //導入方法依賴的package包/類
/**
* The existing valid cache entry.
*
* @param request
* The request
* @param clear
* Whether to clear it
* @return The existing cache entry
*/
public static CacheEntry getExistingValidEntry( Request request, boolean clear )
{
ConcurrentMap<String, Object> attributes = request.getAttributes();
if( clear )
return (CacheEntry) attributes.remove( VALID_CACHE_ENTRY_ATTRIBUTE );
else
return (CacheEntry) attributes.get( VALID_CACHE_ENTRY_ATTRIBUTE );
}