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


Java MediaType.TEXT_PLAIN属性代码示例

本文整理汇总了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);
    }
}
 
开发者ID:ibm-watson-data-lab,项目名称:sync-android-p2p,代码行数:24,代码来源:HttpListener.java

示例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);
    }
}
 
开发者ID:ibm-watson-data-lab,项目名称:sync-android-p2p,代码行数:23,代码来源:HttpListener.java

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

示例4: databaseNotFound

private Representation databaseNotFound() {
    getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
    return new StringRepresentation("404 - Database Not Found!", MediaType.TEXT_PLAIN);
}
 
开发者ID:ibm-watson-data-lab,项目名称:sync-android-p2p,代码行数:4,代码来源:HttpListener.java

示例5: getMessage

@Get
public Representation getMessage() {
    PseudoMfData.getInstance().initialize();
    return new StringRepresentation((Status.SUCCESS_OK).toString(), MediaType.TEXT_PLAIN);
}
 
开发者ID:o3project,项目名称:pseudoMF,代码行数:5,代码来源:McInitialize.java

示例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);
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:10,代码来源:StringRepresentation.java

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


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