本文整理汇总了Java中org.restlet.data.Metadata类的典型用法代码示例。如果您正苦于以下问题:Java Metadata类的具体用法?Java Metadata怎么用?Java Metadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Metadata类属于org.restlet.data包,在下文中一共展示了Metadata类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ClassResource
import org.restlet.data.Metadata; //导入依赖的package包/类
/** Creates a new instance of ClassResource */
public ClassResource(ClassLoader classLoader,String path)
{
setNegotiated(false);
this.classLoader = classLoader;
this.path = path;
int extPos = path.lastIndexOf('.');
Application app = this.getApplication();
type = app.getMetadataService().getDefaultMediaType();
if (extPos>=0) {
String ext = path.substring(extPos+1);
Metadata mdata = this.getApplication().getMetadataService().getMetadata(ext);
if (mdata!=null) {
type = MediaType.valueOf(mdata.getName());
}
}
}
示例2: ClassResource
import org.restlet.data.Metadata; //导入依赖的package包/类
/** Creates a new instance of ClassResource */
public ClassResource(Class baseClass,String path)
{
setNegotiated(false);
this.baseClass = baseClass;
this.path = path;
int extPos = path.lastIndexOf('.');
Application app = this.getApplication();
type = app.getMetadataService().getDefaultMediaType();
if (extPos>=0) {
String ext = path.substring(extPos+1);
Metadata mdata = this.getApplication().getMetadataService().getMetadata(ext);
if (mdata!=null) {
type = MediaType.valueOf(mdata.getName());
}
}
}
示例3: beforeHandle
import org.restlet.data.Metadata; //导入依赖的package包/类
@Override
protected int beforeHandle( Request request, Response response )
{
List<String> segments = request.getResourceRef().getSegments();
if( segments.get( segments.size() - 1 ).equals( "" ) )
{
return Filter.CONTINUE;
}
String extensions = request.getResourceRef().getExtensions();
if( extensions != null )
{
int idx = extensions.lastIndexOf( "." );
if( idx != -1 )
{
extensions = extensions.substring( idx + 1 );
}
MetadataService metadataService = getApplication().getMetadataService();
Metadata metadata = metadataService.getMetadata( extensions );
if( metadata != null && metadata instanceof MediaType )
{
request.getClientInfo()
.setAcceptedMediaTypes( Collections.singletonList( new Preference<MediaType>( (MediaType) metadata ) ) );
String path = request.getResourceRef().getPath();
path = path.substring( 0, path.length() - extensions.length() - 1 );
request.getResourceRef().setPath( path );
}
}
return Filter.CONTINUE;
}
示例4: beforeHandle
import org.restlet.data.Metadata; //导入依赖的package包/类
@Override
protected int beforeHandle( Request request, Response response )
{
List<String> segments = request.getResourceRef().getSegments();
if (segments.get( segments.size()-1 ).equals(""))
return Filter.CONTINUE;
String extensions = request.getResourceRef().getExtensions();
if( extensions != null )
{
int idx = extensions.lastIndexOf( "." );
if( idx != -1 )
{
extensions = extensions.substring( idx + 1 );
}
MetadataService metadataService = getApplication().getMetadataService();
Metadata metadata = metadataService.getMetadata( extensions );
if( metadata != null && metadata instanceof MediaType )
{
request.getClientInfo()
.setAcceptedMediaTypes( Collections.singletonList( new Preference<>( (MediaType) metadata ) ) );
String path = request.getResourceRef().getPath();
path = path.substring( 0, path.length() - extensions.length() - 1 );
request.getResourceRef().setPath( path );
}
}
return Filter.CONTINUE;
}
示例5: getName
import org.restlet.data.Metadata; //导入依赖的package包/类
/**
* Metadata name.
*
* @param metadata
* The metadata or null
* @return The name or null
*/
private static String getName( Metadata metadata )
{
return metadata == null ? null : metadata.getName();
}
示例6: nonNull
import org.restlet.data.Metadata; //导入依赖的package包/类
/**
* Makes sure to return a non-null string.
*
* @param metadata
* The metadata or null
* @return A string
*/
private static String nonNull( Metadata metadata )
{
return metadata == null ? "" : nonNull( metadata.getName() );
}