コード例 #1
0
ファイル: JenaRepository.java プロジェクト: eschwert/rdfbean
 @Override
 public void load(Format format, InputStream is, UID context, boolean replace) {
   RDFReader reader;
   if (format == Format.RDFXML) {
     reader = new JenaReader();
   } else if (format == Format.TURTLE || format == Format.NTRIPLES) {
     reader = new TurtleReader();
   } else {
     throw new IllegalArgumentException(format.toString());
   }
   Model model =
       context == null ? dataset.getDefaultModel() : dataset.getNamedModel(context.getId());
   Assert.notNull(model, "model");
   reader.read(model, is, context != null ? context.getId() : null);
 }
コード例 #2
0
ファイル: JenaRepository.java プロジェクト: eschwert/rdfbean
  @Override
  public void export(Format format, Map<String, String> ns2prefix, UID context, OutputStream os) {
    RDFWriter writer;
    if (format == Format.RDFXML) {
      Basic w = new Basic();
      for (Map.Entry<String, String> entry : ns2prefix.entrySet()) {
        w.setNsPrefix(entry.getValue(), entry.getKey());
      }
      writer = w;
    } else if (format == Format.NTRIPLES) {
      writer = new NTripleWriter();
    } else if (format == Format.TURTLE || format == Format.N3) {
      writer = new N3TurtleJenaWriter();
    } else {
      throw new IllegalArgumentException(format.toString());
    }

    if (context != null) {
      writer.write(dataset.getNamedModel(context.getId()), os, null);
    } else {
      // TODO : export also other models
      writer.write(dataset.getDefaultModel(), os, null);
    }
  }