Package org.ontoware.rdf2go.model

Examples of org.ontoware.rdf2go.model.Model


  public ClosableIterator<Model> getModels() {
    List<Model> models = new ArrayList<Model>();
    ClosableIterator<? extends Model> it = super.getModels();
    // wrap all into NotifyingModels
    while (it.hasNext()) {
      Model model = it.next();
      NotifyingModelLayer notifyingModel = new NotifyingModelLayer(model);
      for (Map.Entry<ModelChangedListener, QuadPattern> entry : this.modelsetChangeListener
          .entrySet()) {
        notifyingModel.addModelChangedListener(entry.getKey(), entry
            .getValue());
View Full Code Here


   * @param target the target, data will be put here.
   * @throws ModelRuntimeException if the copying process has an error
   */
  public static void copy(ModelSet source, ModelSet target) throws ModelRuntimeException {
    for(Iterator<? extends Model> i = source.getModels(); i.hasNext();) {
      Model m = i.next();
      m.open();
      Model tm = target.getModel(m.getContextURI());
      tm.open();
      copy(m, tm);
    }
    // copy default model
    Model m = source.getDefaultModel();
    m.open();
    Model tm = target.getDefaultModel();
    tm.open();
    copy(m, tm);
  }
View Full Code Here

  public static void removeFrom(ModelSet source, ModelSet target) throws ModelRuntimeException {
    // remove
    ClosableIterator<? extends Model> it = source.getModels();
   
    while(it.hasNext()) {
      Model m = it.next();
      ClosableIterator<Statement> modelIt = m.iterator();
      target.getModel(m.getContextURI()).removeAll(modelIt);
      modelIt.close();
    }
    it.close();
    // remove stuff contained in default model
    ClosableIterator<Statement> modelIt = source.getDefaultModel().iterator();
View Full Code Here

      throw new FileNotFoundException("Input file " + in.getAbsolutePath() + " not found");
   
    if(!out.getParentFile().exists())
      out.getParentFile().mkdirs();
   
    Model m = RDF2Go.getModelFactory().createModel();
    m.open();
    FileReader fr = null;
    FileWriter fw = null;
    try {
      fr = new FileReader(in);
      m.readFrom(fr, inSyntax);
      fw = new FileWriter(out);
      m.writeTo(fw, outSyntax);
     
    } catch(ModelRuntimeException e) {
      throw new RuntimeException(e);
    } catch(IOException e) {
      throw new RuntimeException(e);
    } finally {
      if(fr != null)
        try {
          fr.close();
        } catch(IOException e) {
          throw new RuntimeException(e);
        }
      if(fw != null)
        try {
          fw.close();
        } catch(IOException e) {
          throw new RuntimeException(e);
        }
    }
    m.close();
  }
View Full Code Here

   *             sinkModel)
   */
  @Deprecated
  public static Model loadFromFile(File in, Syntax inSyntax) throws ModelRuntimeException,
          IOException {
    Model model = RDF2Go.getModelFactory().createModel();
    model.open();
    FileInputStream fin = new FileInputStream(in);
    model.readFrom(fin, inSyntax);
    return model;
  }
View Full Code Here

   * @throws IOException from file reading
   * @throws ModelRuntimeException from underlying IO errors, if any.
   */
  public static void convert(File[] inFiles, Syntax[] inSyntax, File out, Syntax outSyntax)
          throws ModelRuntimeException, IOException {
    Model merged = RDF2Go.getModelFactory().createModel();
   
    for(int i = 0; i < inFiles.length; i++) {
      Model inModel = loadFromFile(inFiles[i], inSyntax[i]);
      ClosableIterator<Statement> it = inModel.iterator();
      merged.addAll(it);
      it.close();
    }
    writeToFile(merged, out, outSyntax);
  }
View Full Code Here

        // extract text from pdf
        InputStream in = getResourceAsStream(testFile);
        assertNotNull("failed to load resource " + testFile, in);

        Model m = extractor.extract(in, new URIImpl("file://" + testFile), "application/pdf");
        String text = MetaxaCore.getText(m);
        // get expected result
        InputStream in2 = getResourceAsStream(testResultFile);
        assertNotNull("failed to load resource " + testResultFile, in2);
View Full Code Here

        // extract text from html
        InputStream in = getResourceAsStream(testFile);
        assertNotNull("failed to load resource " + testFile, in);

        Model m = extractor.extract(in, new URIImpl("file://" + testFile), "text/html");
        String text = MetaxaCore.getText(m);
        // get expected result
        InputStream in2 = getResourceAsStream(testResultFile);
        assertNotNull("failed to load resource " + testResultFile, in2);
View Full Code Here

        // extract text from RDFa annotated html
        InputStream in = getResourceAsStream(testFile);
        assertNotNull("failed to load resource " + testFile, in);

        Model m = extractor.extract(in, new URIImpl("file://" + testFile), "text/html");
        String text = MetaxaCore.getText(m);
        // get expected result
        InputStream in2 = getResourceAsStream(testResultFile);
        assertNotNull("failed to load resource " + testResultFile, in2);
View Full Code Here

    @Test
    public void testMailExtraction() throws Exception {
      String testFile = "mail-multipart-test.eml";
      InputStream in = getResourceAsStream(testFile);
      assertNotNull("failed to load resource " + testFile, in);
      Model m = extractor.extract(in, new URIImpl("file://" + testFile), "message/rfc822");
      boolean textContained = m.contains(Variable.ANY, NMO.plainTextMessageContent, Variable.ANY);
      assertTrue(textContained);
    }
View Full Code Here

TOP

Related Classes of org.ontoware.rdf2go.model.Model

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.