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


Java Metadata类代码示例

本文整理汇总了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());
      }
   }
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:18,代码来源:ClassResource.java

示例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());
      }
   }
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:18,代码来源:LoginApplication.java

示例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;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:33,代码来源:ExtensionMediaTypeFilter.java

示例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;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:31,代码来源:ExtensionMediaTypeFilter.java

示例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();
}
 
开发者ID:tliron,项目名称:prudence,代码行数:12,代码来源:SqlCache.java

示例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() );
}
 
开发者ID:tliron,项目名称:prudence,代码行数:12,代码来源:CacheEntry.java


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