本文整理匯總了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() );
}