本文整理汇总了Java中org.restlet.data.MediaType.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java MediaType.valueOf方法的具体用法?Java MediaType.valueOf怎么用?Java MediaType.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.restlet.data.MediaType
的用法示例。
在下文中一共展示了MediaType.valueOf方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setResponseText
import org.restlet.data.MediaType; //导入方法依赖的package包/类
@Override
public StringRepresentation setResponseText( String text, String mediaTypeName, String languageName, String characterSetName )
{
MediaType mediaType = mediaTypeName == null ? getMediaType() : MediaType.valueOf( mediaTypeName );
Language language = languageName == null ? getLanguage() : Language.valueOf( languageName );
CharacterSet characterSet = characterSetName == null ? getCharacterSet() : CharacterSet.valueOf( characterSetName );
StringRepresentation representation = new StringRepresentation( text, mediaType, language, characterSet );
getResponse().setEntity( representation );
return representation;
}
示例2: setResponseBinary
import org.restlet.data.MediaType; //导入方法依赖的package包/类
@Override
public ByteArrayRepresentation setResponseBinary( byte[] byteArray, String mediaTypeName )
{
MediaType mediaType = mediaTypeName == null ? getMediaType() : MediaType.valueOf( mediaTypeName );
ByteArrayRepresentation representation = new ByteArrayRepresentation( byteArray, mediaType );
getResponse().setEntity( representation );
return representation;
}
示例3: getMediaType
import org.restlet.data.MediaType; //导入方法依赖的package包/类
/**
* Get a media type by its MIME type name.
*
* @param name
* The MIME type name
* @return The media type
*/
private static MediaType getMediaType( String name )
{
MediaType mediaType = MediaType.valueOf( name );
if( mediaType == null )
mediaType = Application.getCurrent().getMetadataService().getMediaType( name );
return mediaType;
}
示例4: toMediaType
import org.restlet.data.MediaType; //导入方法依赖的package包/类
@Converter
public static MediaType toMediaType(String name) {
return MediaType.valueOf(name);
}
示例5: readExternal
import org.restlet.data.MediaType; //导入方法依赖的package包/类
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
int tagsLength = in.readInt();
tags = new String[tagsLength];
for( int i = 0; i < tagsLength; i++ )
{
String tag = IoUtil.readUtf8( in );
tags[i] = tag;
}
if( in.readBoolean() )
{
bytes = new byte[in.readInt()];
in.readFully( bytes );
}
else
string = IoUtil.readUtf8( in );
mediaType = MediaType.valueOf( in.readUTF() );
language = Language.valueOf( in.readUTF() );
characterSet = CharacterSet.valueOf( in.readUTF() );
encoding = Encoding.valueOf( in.readUTF() );
int headersLength = in.readInt();
if( headersLength > 0 )
{
headers = new Series<Header>( Header.class );
for( int i = 0; i < headersLength; i++ )
{
String name = IoUtil.readUtf8( in );
String value = IoUtil.readUtf8( in );
headers.add( new Header( name, value ) );
}
}
String tagValue = in.readUTF();
tag = tagValue != null ? Tag.parse( tagValue ) : null;
modificationDate = new Date( in.readLong() );
expirationDate = new Date( in.readLong() );
documentModificationDate = new Date( in.readLong() );
}
示例6: SolrOutputRepresentation
import org.restlet.data.MediaType; //导入方法依赖的package包/类
public SolrOutputRepresentation() {
// No normalization, in case of a custom media type
super(MediaType.valueOf(contentType));
// TODO: For now, don't send the Vary: header, but revisit if/when content negotiation is added
getDimensions().clear();
}
示例7: setResponseText
import org.restlet.data.MediaType; //导入方法依赖的package包/类
/**
* A shortcut to set the response entity to a {@link StringRepresentation}.
*
* @param text
* The text
* @param mediaTypeName
* The media type or null to leave unchanged
* @param languageName
* The language or null to leave unchanged
* @param characterSetName
* The character set or null to leave unchanged
* @return The string representation
*/
public StringRepresentation setResponseText( String text, String mediaTypeName, String languageName, String characterSetName )
{
StringRepresentation representation = new StringRepresentation( text, MediaType.valueOf( mediaTypeName ), Language.valueOf( languageName ), CharacterSet.valueOf( characterSetName ) );
getResponse().setEntity( representation );
return representation;
}
示例8: setResponseBinary
import org.restlet.data.MediaType; //导入方法依赖的package包/类
/**
* A shortcut to set the response entity to a
* {@link ByteArrayRepresentation}.
*
* @param byteArray
* The byte array
* @param mediaTypeName
* The media type or null to leave unchanged
* @return The byte array representation
*/
public ByteArrayRepresentation setResponseBinary( byte[] byteArray, String mediaTypeName )
{
ByteArrayRepresentation representation = new ByteArrayRepresentation( byteArray, MediaType.valueOf( mediaTypeName ) );
getResponse().setEntity( representation );
return representation;
}
示例9: setMediaTypeName
import org.restlet.data.MediaType; //导入方法依赖的package包/类
/**
* @param mediaTypeName
* The media type name
* @see #setMediaType(MediaType)
*/
public void setMediaTypeName( String mediaTypeName )
{
mediaType = MediaType.valueOf( mediaTypeName );
}
示例10: getMediaTypeByName
import org.restlet.data.MediaType; //导入方法依赖的package包/类
/**
* Get a media type by its MIME type name.
*
* @param name
* The MIME type name
* @return The media type
*/
public MediaType getMediaTypeByName( String name )
{
return MediaType.valueOf( name );
}
示例11: getMediaType
import org.restlet.data.MediaType; //导入方法依赖的package包/类
/**
* The file media type.
*
* @return The file media type
* @see #getMediaTypeName()
*/
public MediaType getMediaType()
{
return MediaType.valueOf( mediaTypeName );
}