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