當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。