• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ContentType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.jena.atlas.web.ContentType的典型用法代码示例。如果您正苦于以下问题:Java ContentType类的具体用法?Java ContentType怎么用?Java ContentType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ContentType类属于org.apache.jena.atlas.web包,在下文中一共展示了ContentType类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: executeAction

import org.apache.jena.atlas.web.ContentType; //导入依赖的package包/类
@Override
protected void executeAction(DeltaAction action) throws IOException {
    LOG.info("GET "+action.getURL());
    Id dsRef = Id.fromString(action.httpArgs.datasourceName);
    String filenameIRI = determineData(action, dsRef);
    ContentType ct = RDFLanguages.guessContentType(filenameIRI) ;
    String fn = IRILib.IRIToFilename(filenameIRI);
    Path path = Paths.get(fn);
    try ( InputStream in = Files.newInputStream(path) ) {
        action.response.setStatus(HttpSC.OK_200);
        action.response.setContentType(ct.getContentType());
        IOUtils.copy(in, action.response.getOutputStream());
    } catch (NoSuchFileException | FileNotFoundException ex) {
        throw new DeltaNotFoundException(action.getURL());
    }
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:17,代码来源:S_Data.java


示例2: validate

import org.apache.jena.atlas.web.ContentType; //导入依赖的package包/类
@Override
protected void validate(HttpAction action) {
    String method = action.getRequest().getMethod();
    switch(method) {
        case HttpNames.METHOD_POST:
        case HttpNames.METHOD_PATCH:
            break;
        default:
            ServletOps.errorMethodNotAllowed(method+" : Patch must use POST or PATCH");
    }
    String ctStr = action.request.getContentType();
    // Must be UTF-8 or unset. But this is wrong so often,
    // it is less trouble to just force UTF-8.
    String charset = action.request.getCharacterEncoding();
    if ( charset != null && ! WebContent.charsetUTF8.equals(charset) )
        ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Charset must be omitted or UTF-8, not "+charset); 

    // If no header Content-type - assume patch-text.
    ContentType contentType = ( ctStr != null ) ? ContentType.create(ctStr) : ctPatchText;
    if ( ! ctPatchText.equals(contentType) && ! ctPatchBinary.equals(contentType) ) 
        ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Allowed Content-types are "+ctPatchText+" or "+ctPatchBinary+", not "+ctStr); 
    if ( ctPatchBinary.equals(contentType) )
        ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, contentTypePatchBinary+" not supported yet");
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:25,代码来源:PatchApplyService.java


示例3: open

import org.apache.jena.atlas.web.ContentType; //导入依赖的package包/类
@Override
public TypedInputStream open(LookUpRequest request) {
    if (classLoader == null) {
        return null;
    }
    String resourceName = request.getFilenameOrURI();
    InputStream in = classLoader.getResourceAsStream(resourceName);
    if (in == null) {
        return null;
    }
    
    try {
        String ct = Files.probeContentType(Paths.get(new File(resourceName).getName()));
        return new TypedInputStream(in, ContentType.create(ct), resourceName);
    } catch (IOException ex) {
            log.trace("Error while trying to probe content type for " + resourceName + ": " + ex.getMessage());
        return new TypedInputStream(in, (String) null);
    } 
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:20,代码来源:LocatorClassLoaderAccept.java


示例4: isRDF

import org.apache.jena.atlas.web.ContentType; //导入依赖的package包/类
private static boolean isRDF(final MediaType requestContentType) {
    if (requestContentType == null) {
        return false;
    }

    final ContentType ctRequest = create(requestContentType.toString());

    // Text files and CSV files are not considered RDF to Fedora, though CSV is a valid
    // RDF type to Jena (although deprecated).
    if (matchContentType(ctRequest, ctTextPlain) || matchContentType(ctRequest, ctTextCSV)) {
        return false;
    }

    // SPARQL updates are done on containers.
    return isRdfContentType(requestContentType.toString()) || matchContentType(ctRequest, ctSPARQLUpdate);
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:17,代码来源:FedoraLdp.java


示例5: probeContentType

import org.apache.jena.atlas.web.ContentType; //导入依赖的package包/类
public String probeContentType(Path path) throws IOException {
    if(path == null) {
        throw new IOException();
    }
    String fileName = path.getFileName().toString();
    if(fileName.endsWith(SPARQLGenerate.EXT)) {
        return SPARQLGenerate.MEDIA_TYPE;
    }
    ContentType ct = RDFLanguages.guessContentType(fileName);
    if(ct==null) {
        throw new IOException();
    }
    return ct.getContentType();
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:15,代码来源:RDFFileTypeDetector.java


示例6: open

import org.apache.jena.atlas.web.ContentType; //导入依赖的package包/类
/**
 * Open anything that looks a bit like a file name
 */
@Override
public TypedInputStream open(LookUpRequest request) {
    String filenameIRI = request.getFilenameOrURI();
    String fn = toFileName(filenameIRI);
    if (fn == null) {
        log.debug("Cannot find a proper filename: " + filenameIRI);
        return null;
    }

    try {
        if (!exists$(fn)) {
            return null;
        }
    } catch (AccessControlException e) {
        log.debug("Security problem testing for file", e);
        return null;
    }

    try {
        InputStream in = IO.openFileEx(fn);
        try {
            String ct = Files.probeContentType(Paths.get(new File(filenameIRI).getName()));
            return new TypedInputStream(in, ContentType.create(ct), filenameIRI);
        } catch (Exception ex) {
            log.trace("Error while trying to probe content type for " + filenameIRI + ": " + ex.getMessage());
            return new TypedInputStream(in, (ContentType) null, filenameIRI);
        } 
    } catch (IOException ioEx) {
        // Includes FileNotFoundException
        // We already tested whether the file exists or not.
        log.debug("File unreadable (but exists): " + fn + " Exception: " + ioEx.getMessage());
        return null;
    }
}
 
开发者ID:thesmartenergy,项目名称:sparql-generate,代码行数:38,代码来源:LocatorFileAccept.java


示例7: fromMime

import org.apache.jena.atlas.web.ContentType; //导入依赖的package包/类
static Module.Format fromMime(final String aMime) {
	final ContentType expectedCT = ContentType.create(aMime);
	for(final Module.Format format:values()) {
		final ContentType candidateCT=format.lang.getContentType();
		if(candidateCT.getType().equals(expectedCT.getType()) && candidateCT.getSubType().equals(expectedCT.getSubType())) {
			return format;
		}
	}
	return null;
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:11,代码来源:Module.java


示例8: mime

import org.apache.jena.atlas.web.ContentType; //导入依赖的package包/类
public String mime() {
	final ContentType contentType = this.lang.getContentType();
	return contentType.getType()+"/"+contentType.getSubType();
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:5,代码来源:Module.java


示例9: read

import org.apache.jena.atlas.web.ContentType; //导入依赖的package包/类
@Override
public void read(InputStream in, String baseURI, ContentType ct, StreamRDF output, Context context) {
    Item item = SSE.parse(in) ;
    read(item, baseURI, ct, output, context) ;

}
 
开发者ID:xcurator,项目名称:xcurator,代码行数:7,代码来源:ExRIOT_5.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Drawable类代码示例发布时间:2022-05-23
下一篇:
Java PushBufferDataSource类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap