本文整理汇总了Java中org.restlet.data.MediaType.TEXT_PLAIN属性的典型用法代码示例。如果您正苦于以下问题:Java MediaType.TEXT_PLAIN属性的具体用法?Java MediaType.TEXT_PLAIN怎么用?Java MediaType.TEXT_PLAIN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.restlet.data.MediaType
的用法示例。
在下文中一共展示了MediaType.TEXT_PLAIN属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handlePost
@Post("json")
public Representation handlePost(Representation entity) {
String path = getReference().getPath();
String dbname = getDatabaseName(path);
if (!dbNameExists(dbname)) {
return databaseNotFound();
}
else if (path.endsWith("/_revs_diff")) {
return handleRevsDiff(dbname);
}
else if (path.endsWith("/_ensure_full_commit")) {
return handleEnsureFullCommitPost(dbname);
}
else if (path.endsWith("/_bulk_docs")) {
return handleBulkDocsPost(dbname);
}
else {
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
return new StringRepresentation("{\"message\": \"Server error for request: " + getMethod() + " " + path + "\"}", MediaType.TEXT_PLAIN);
}
}
示例2: handlePut
@Put("json")
public Representation handlePut(Representation entity) {
String path = getReference().getPath();
String dbname = getDatabaseName(path);
String pathWithFirstAndLastSlashRemoved = path.replaceAll("^/", "").replaceAll("/$", "");
if (pathWithFirstAndLastSlashRemoved.equals(dbname)) {
// must be a PUT /target request
return handleCreateTargetPut(dbname);
}
else if (!dbNameExists(dbname)) {
return databaseNotFound();
}
else if (path.contains("/_local/")) {
return handleLocalPut(dbname);
} else {
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
return new StringRepresentation("{\"message\": \"Server error for request: " + getMethod() + " " + path + "\"}", MediaType.TEXT_PLAIN);
}
}
示例3: get
@Override
public Representation get( Variant variant )
throws ResourceException
{
if( variant.getMediaType().equals( MediaType.APPLICATION_RDF_XML ) )
{
return new RdfXmlOutputRepresentation();
}
else if( variant.getMediaType().equals( MediaType.APPLICATION_RDF_TRIG ) )
{
return new RdfTrigOutputRepresentation( MediaType.APPLICATION_RDF_TRIG );
}
else if( variant.getMediaType().equals( MediaType.TEXT_PLAIN ) )
{
return new RdfTrigOutputRepresentation( MediaType.TEXT_PLAIN );
}
return null;
}
示例4: databaseNotFound
private Representation databaseNotFound() {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation("404 - Database Not Found!", MediaType.TEXT_PLAIN);
}
示例5: getMessage
@Get
public Representation getMessage() {
PseudoMfData.getInstance().initialize();
return new StringRepresentation((Status.SUCCESS_OK).toString(), MediaType.TEXT_PLAIN);
}
示例6: StringRepresentation
/**
* Constructor. The following metadata are used by default: "text/plain"
* media type, no language and the UTF-8 character set.
*
* @param chars
* The characters array.
*/
public StringRepresentation(char[] chars) {
this(new String(chars), MediaType.TEXT_PLAIN);
}
示例7: CompressedStringRepresentation
/**
* Construction with media type "text/plain" and UTF-8.
*
* @param text
* The text
* @param encoding
* The encoding
* @throws IOException
* In case of a compression error
*/
public CompressedStringRepresentation( CharSequence text, Encoding encoding ) throws IOException
{
this( text, MediaType.TEXT_PLAIN, encoding );
}