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


Java RDFFormat.forMIMEType方法代码示例

本文整理汇总了Java中org.openrdf.rio.RDFFormat.forMIMEType方法的典型用法代码示例。如果您正苦于以下问题:Java RDFFormat.forMIMEType方法的具体用法?Java RDFFormat.forMIMEType怎么用?Java RDFFormat.forMIMEType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openrdf.rio.RDFFormat的用法示例。


在下文中一共展示了RDFFormat.forMIMEType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: formatFor

import org.openrdf.rio.RDFFormat; //导入方法依赖的package包/类
private static RDFFormat formatFor(final String mimeType) {
    final RDFFormat format = RDFFormat.forMIMEType(mimeType);
    if (format == null) {
        throw new IllegalArgumentException("No RDF format for MIME type '" + mimeType + "'");
    }
    return format;
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:8,代码来源:Serializer.java

示例2: forMIMEType

import org.openrdf.rio.RDFFormat; //导入方法依赖的package包/类
private RDFFormat forMIMEType(String contentType, RDFFormat fallback) {
	RDFFormat format = RDFFormat.forMIMEType(contentType);
	RDFParserRegistry registry = RDFParserRegistry.getInstance();
	if (format != null && registry.has(format))
		return format;
	return fallback;
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:8,代码来源:OntologyLoader.java

示例3: doQuery

import org.openrdf.rio.RDFFormat; //导入方法依赖的package包/类
@Override
protected void doQuery(QueryDefinition query, WriterConfig config,
		RepositoryConnection cxn, OutputStream os) throws Exception {
	final GraphQuery sailGraphQuery = cxn
			.prepareGraphQuery(query.getQueryLanguage(), query.getQuery(),
					config.getBaseUri());
	final RDFFormat format = RDFFormat.forMIMEType(config.getContentType(),
			RDFFormat.RDFXML);
	// final RDFFormat format = RDFWriterRegistry.getInstance()
	// .getFileFormatForMIMEType(config.getFormat());
	final RDFWriter w = RDFWriterRegistry.getInstance().get(format)
			.getWriter(os);
	applyConfig(w);
	sailGraphQuery.evaluate(w);
}
 
开发者ID:erfgoed-en-locatie,项目名称:artsholland-platform,代码行数:16,代码来源:GraphQueryTask.java

示例4: getRDFFormat

import org.openrdf.rio.RDFFormat; //导入方法依赖的package包/类
/**
 * Resolves an RDF2Go {@link Syntax} to an OpenRDF {@link RDFFormat}.
 * 
 * @param syntax The RDF2Go Syntax to resolve.
 * @return A RDFFormat for the specified syntax.
 * @throws SyntaxNotSupportedException When the Syntax could not be resolved to a
 *             RDFFormat.
 */
public static RDFFormat getRDFFormat(Syntax syntax) throws SyntaxNotSupportedException {
    for (String mimeType : syntax.getMimeTypes()) {
        RDFFormat format = RDFFormat.forMIMEType(mimeType);
        if (format != null) {
            return format;
        }
    }
	throw new SyntaxNotSupportedException("This version of Sesame seems to have no "
	        + "support for " + syntax);
}
 
开发者ID:semweb4j,项目名称:semweb4j,代码行数:19,代码来源:RepositoryModel.java

示例5: doProcessRequest

import org.openrdf.rio.RDFFormat; //导入方法依赖的package包/类
void doProcessRequest(HttpServletRequest request, HttpServletResponse response)
    throws IOException {
  ServletOutputStream out = response.getOutputStream();

  // get the RDF format (we check only the Accept header)
  RDFFormat format = RDFFormat.forMIMEType(request.getHeader("accept"));

  // get the query
  String query = request.getParameter("query");

  response.setContentType(format.getDefaultMIMEType());
  response.setHeader(
      "Content-Disposition",
      "attachment; filename=describe." + format.getDefaultFileExtension() + "; "
          + format.getCharset());

  try {
    describe(query, format.getName(), out);
    response.setStatus(HttpServletResponse.SC_OK);

  } catch (Exception e) {
    response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    out.print(ResponseMessages.getXMLHeader());
    out.print(ResponseMessages.getXMLException(e.getMessage()));
    out.print(ResponseMessages.getXMLFooter());
  } finally {
    out.flush();
  }
}
 
开发者ID:esarbanis,项目名称:strabon,代码行数:30,代码来源:DescribeBean.java

示例6: parseContentTypeHeader

import org.openrdf.rio.RDFFormat; //导入方法依赖的package包/类
/**
 * <p>Retrieves the MIME type for the content-type parameter.
 * The content-type parameter could be specified by the client as a parameter or 
 * a header in the HTTP request.
 * HTTP header has a higher priority.</p>
 * <p> Default (if no content-type parameter is given): RDF/XML.</p>
 * 
 * @param request - the HTTP request.
 * @return MIME type of the content-type parameter.
 */
public static String parseContentTypeHeader(final HttpServletRequest request) {

	String content_type = request.getHeader(Headers.CONTENT_TYPE);

	if (isNullOrEmptyString(content_type)) {
		content_type = getParameterValue(request, Parameters.CONTENT_TYPE);
	}

	if (isNotNullOrEmptyString(content_type)) {
		content_type = content_type.trim().toLowerCase();
	}

	if (RDFFormat.forMIMEType(content_type) == null) {

		/*
		 * default: MimeTypes.RDF_XML
		 */
		if ((content_type == null) || content_type.isEmpty()) {
			content_type = MimeTypes.RDF_XML;
		}
		/*
		 * guess MIME type
		 */
		else if (content_type.contains("htm")) {
			content_type = MimeTypes.TEXT_HTML;
		} else if (content_type.contains("xml")) {
			content_type = MimeTypes.RDF_XML;
		} else if (content_type.contains("rdf+json")) {
			content_type = MimeTypes.RDF_JSON;
		} else if (content_type.contains("json")) {
			content_type = MimeTypes.JSON_LD;
		} else if (content_type.contains("trix")) {
			content_type = MimeTypes.TRIX;
		} else if (content_type.contains("trig")) {
			content_type = MimeTypes.TRIG;
		} else if (content_type.contains("n3")) {
			content_type = MimeTypes.N3;
		} else if (content_type.contains("turtle") || content_type.contains("ttl")) {
			content_type = MimeTypes.TURTLE;
		} else if (content_type.contains("triple")) {
			content_type = MimeTypes.TEXT_PLAIN;
		} else if (content_type.contains("quad")) {
			content_type = MimeTypes.N_QUADS;
		} else if (content_type.contains("plain")) {
			content_type = MimeTypes.TEXT_PLAIN;
		} else if (content_type.contains("binary")) {
			content_type = MimeTypes.BINARY;
		}
		/*
		 * default: RDF/XML				
		 */
		else {
			content_type = MimeTypes.RDF_XML;
		}
	}

	return content_type;
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:69,代码来源:HttpProtocol.java

示例7: processRequest

import org.openrdf.rio.RDFFormat; //导入方法依赖的package包/类
/**
 * Processes the request made by a client of the endpoint that uses it as a service.
 *
 * @param request
 * @param response
 * @throws IOException
 */
private void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws IOException {
  // check whether we read from INPUT or URL
  boolean input = (request.getParameter(Common.SUBMIT_URL) == null);

  // graph
  String graph =
      (request.getParameter(Common.PARAM_GRAPH) != null) ? request
          .getParameter(Common.PARAM_GRAPH) : null;

  // inference
  Boolean inference =
      (request.getParameter(Common.PARAM_INFERENCE) != null) ? Boolean.valueOf(request
          .getParameter(Common.PARAM_INFERENCE)) : false;

  // RDF data to store
  String data = getData(request);

  if (data == null) {
    response.sendError(HttpServletResponse.SC_NO_CONTENT);
    return;
  }

  // the format of the data
  RDFFormat format = RDFFormat.forMIMEType(request.getHeader("accept"));

  if (format == null) { // unknown format
    response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
    return;
  }

  // store data
  try {

    store(data, graph, format.getName(), inference, !input);

    // store was successful, return the respective message
    response.sendError(HttpServletResponse.SC_OK);
  } catch (Exception e) {
    if (e instanceof RDFParseException || e instanceof IllegalArgumentException
        || e instanceof MalformedURLException) {
      response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);

    } else {
      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }

    logger.error("[StrabonEndpoint.StoreBean] " + e.getMessage());
  }
}
 
开发者ID:esarbanis,项目名称:strabon,代码行数:58,代码来源:StoreBean.java


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