當前位置: 首頁>>代碼示例>>Java>>正文


Java RDFFormat.valueOf方法代碼示例

本文整理匯總了Java中org.openrdf.rio.RDFFormat.valueOf方法的典型用法代碼示例。如果您正苦於以下問題:Java RDFFormat.valueOf方法的具體用法?Java RDFFormat.valueOf怎麽用?Java RDFFormat.valueOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openrdf.rio.RDFFormat的用法示例。


在下文中一共展示了RDFFormat.valueOf方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadRdf

import org.openrdf.rio.RDFFormat; //導入方法依賴的package包/類
@RequestMapping(value = "/loadrdf", method = RequestMethod.POST)
public void loadRdf(@RequestParam(required = false) final String format,
        @RequestParam(value = RdfCloudTripleStoreConfiguration.CONF_CV, required = false) final String cv,
        @RequestParam(required = false) final String graph,
                    @RequestBody final String body,
                    final HttpServletResponse response)
        throws RepositoryException, IOException, RDFParseException {
    final List<Resource> authList = new ArrayList<Resource>();
    RDFFormat format_r = RDFFormat.RDFXML;
    if (format != null) {
        format_r = RDFFormat.valueOf(format);
        if (format_r == null) {
            throw new RuntimeException("RDFFormat[" + format + "] not found");
        }
    }
    if (graph != null) {
        authList.add(VALUE_FACTORY.createURI(graph));
    }
    SailRepositoryConnection conn = null;
    try {
        conn = repository.getConnection();

        if (conn.getSailConnection() instanceof RdfCloudTripleStoreConnection && cv != null) {
            final RdfCloudTripleStoreConnection<?> sailConnection = (RdfCloudTripleStoreConnection<?>) conn.getSailConnection();
            sailConnection.getConf().set(RdfCloudTripleStoreConfiguration.CONF_CV, cv);
        }

        conn.add(new StringReader(body), "", format_r);
        conn.commit();
    } finally {
        if (conn != null) {
            conn.close();
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:36,代碼來源:RdfController.java

示例2: getRDFFormat

import org.openrdf.rio.RDFFormat; //導入方法依賴的package包/類
private RDFFormat getRDFFormat(JobContext context) {
    String name = context.getConfiguration().get(FORMAT_PROP);
    return RDFFormat.valueOf(name);
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:5,代碼來源:RdfFileInputFormat.java

示例3: loadData

import org.openrdf.rio.RDFFormat; //導入方法依賴的package包/類
@CliCommand(value = LOAD_DATA_CMD, help = "Loads RDF Statement data from a local file to the connected Rya instance.")
public String loadData(
        @CliOption(key = { "file" }, mandatory = true, help = "A local file containing RDF Statements that is to be loaded.")
        final String file,
        @CliOption(key = { "format" }, mandatory = false, help = "The format of the supplied RDF Statements file. [RDF/XML, N-Triples, Turtle, N3, TriX, TriG, BinaryRDF, N-Quads, JSON-LD, RDF/JSON, RDFa]")
        final String format
        ) {
    // Fetch the command that is connected to the store.
    final ShellState shellState = state.getShellState();
    final RyaClient commands = shellState.getConnectedCommands().get();
    final Optional<String> ryaInstanceName = shellState.getRyaInstanceName();
    try {
        final long start = System.currentTimeMillis();

        // If the provided path is relative, then make it rooted in the user's home.
        Path rootedFile = Paths.get( file.replaceFirst("^~", System.getProperty("user.home")) );

        RDFFormat rdfFormat = null;
        // If a format was provided, then go with that.
        if (format != null) {
            rdfFormat = RDFFormat.valueOf(format);
            if (rdfFormat == null) {
                throw new RuntimeException("Unsupported RDF Statement data input format: " + format);
            }
        }

        // Otherwise try to figure it out using the filename.
        else if (rdfFormat == null) {
            rdfFormat = RDFFormat.forFileName(rootedFile.getFileName().toString());
            if (rdfFormat == null) {
                throw new RuntimeException("Unable to detect RDF Statement data input format for file: " + rootedFile);
            } else {
                consolePrinter.println("Detected RDF Format: " + rdfFormat);
                consolePrinter.flush();
            }
        }
        commands.getLoadStatementsFile().loadStatements(ryaInstanceName.get(), rootedFile, rdfFormat);

        final String seconds = new DecimalFormat("0.0##").format((System.currentTimeMillis() - start) / 1000.0);
        return "Loaded the file: '" + file + "' successfully in " + seconds + " seconds.";

    } catch (final RyaClientException | IOException e) {
        log.error("Error", e);
        throw new RuntimeException("Can not load the RDF Statement data. Reason: " + e.getMessage(), e);
    }
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:47,代碼來源:RyaCommands.java

示例4: processVIEWRequest

import org.openrdf.rio.RDFFormat; //導入方法依賴的package包/類
/**
 * Processes the request made from the HTML visual interface of Strabon Endpoint.
 *
 * @param request
 * @param response
 * @throws ServletException
 * @throws IOException
 */
private void processVIEWRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

  // check whether we read from INPUT or URL
  boolean input = (request.getParameter(Common.SUBMIT_URL) == null);

  // get the dispatcher for forwarding the rendering of the response
  RequestDispatcher dispatcher = request.getRequestDispatcher("store.jsp");

  // RDF data to store
  String data = getData(request);
  System.out.println(data);

  // the format of the data
  RDFFormat format =
      (request.getParameter(Common.PARAM_FORMAT) != null) ? RDFFormat.valueOf(request
          .getParameter(Common.PARAM_FORMAT)) : 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;

  if (data == null || format == null) {
    request.setAttribute(ERROR, PARAM_ERROR);

  } else {

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

      // store was successful, return the respective message
      request.setAttribute(INFO, STORE_OK);

    } catch (Exception e) {
      request.setAttribute(ERROR, STORE_ERROR + " " + e.getMessage());
    }
  }

  dispatcher.forward(request, response);

}
 
開發者ID:esarbanis,項目名稱:strabon,代碼行數:57,代碼來源:StoreBean.java

示例5: getRDFFormat

import org.openrdf.rio.RDFFormat; //導入方法依賴的package包/類
/**
 * Gets the RDF serialization format to use for parsing RDF files.
 * @param   conf    Configuration containing MapReduce tool options.
 * @return  The configured RDFFormat, or null if not set.
 */
public static RDFFormat getRDFFormat(Configuration conf) {
    return RDFFormat.valueOf(conf.get(FORMAT_PROP));
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:9,代碼來源:MRUtils.java


注:本文中的org.openrdf.rio.RDFFormat.valueOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。