org.ontoware.rdf2go.util
Class ModelUtils

java.lang.Object
  extended by org.ontoware.rdf2go.util.ModelUtils

public class ModelUtils
extends java.lang.Object

Find a lot of convenience functions that are slow but nice and didn't make it to the Model API.

Author:
voelkel

Constructor Summary
ModelUtils()
           
 
Method Summary
static Model complement(Model a, Model b, Model result)
           
static void convert(java.io.File[] inFiles, Syntax[] inSyntax, java.io.File out, Syntax outSyntax)
          Merge all input files into one model and export to outfile in output syntax
static void convert(java.io.File in, Syntax inSyntax, java.io.File out, Syntax outSyntax)
          Convert the input file, interpreted in the inputSyntax to outputFile, in outputSyntax.
static void copy(Model source, Model target)
          If the two models come from different implementations, copying blank nodes needs special care
static void copy(ModelSet source, ModelSet target)
          Copy data from the source modelset to the target modelset.
static Model intersection(Model a, Model b, Model result)
           
static Model loadFromFile(java.io.File in, Syntax inSyntax)
          Deprecated. This method creates new models via RDF2Go. If multiple model factories are used, this might be wrong. Use instead public static void loadFromFile(File in, Syntax inSyntax, Model sinkModel)
static void loadFromFile(java.io.File in, Syntax inSyntax, Model sinkModel)
          Convenience method to load data from file in in syntax inSyntax and write loaded triples to sinkModel.
static void removeFrom(ModelSet source, ModelSet target)
          Remove data that is listed in the source modelset from the target modelset.
static int size(java.lang.Iterable<?> it)
          Count statements in iterable 'it'
static int size(java.util.Iterator<?> i)
          Count statements in iterator 'it'
static Model union(Model a, Model b, Model result)
           
static void writeToFile(Model model, java.io.File outFile, Syntax outSyntax)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelUtils

public ModelUtils()
Method Detail

size

public static int size(java.lang.Iterable<?> it)
Count statements in iterable 'it'

Parameters:
it - the iterable
Returns:
the size

size

public static int size(java.util.Iterator<?> i)
Count statements in iterator 'it'

Parameters:
i - the iterator
Returns:
the size

copy

public static void copy(ModelSet source,
                        ModelSet target)
                 throws ModelRuntimeException
Copy data from the source modelset to the target modelset. Iterates through all named models of the source and adds each to the target. If a named graph already exists in the target, the data will be added to it, target models will not be replaced.

Parameters:
source - the source, data from here is taken
target - the target, data will be put here.
Throws:
ModelRuntimeException - if the copying process has an error

copy

public static void copy(Model source,
                        Model target)
If the two models come from different implementations, copying blank nodes needs special care

Parameters:
source -
target -

removeFrom

public static void removeFrom(ModelSet source,
                              ModelSet target)
                       throws ModelRuntimeException
Remove data that is listed in the source modelset from the target modelset. Iterates through all named models of the source and removes the listed triples from the target.

Parameters:
source - the source, data from here is evaluated
target - the target, data contained in source and target are removed from here
Throws:
ModelRuntimeException - if the deleting process has an error

intersection

public static Model intersection(Model a,
                                 Model b,
                                 Model result)
                          throws ModelRuntimeException
Parameters:
a -
b -
result -
Returns:
the result after executing the intersection
Throws:
ModelRuntimeException

union

public static Model union(Model a,
                          Model b,
                          Model result)
                   throws ModelRuntimeException
Parameters:
a -
b -
result -
Returns:
the result after executing the union
Throws:
ModelRuntimeException

complement

public static Model complement(Model a,
                               Model b,
                               Model result)
                        throws ModelRuntimeException
Parameters:
a -
b -
result -
Returns:
the result after executing the complement of b in a (a\b)
Throws:
ModelRuntimeException

convert

public static void convert(java.io.File in,
                           Syntax inSyntax,
                           java.io.File out,
                           Syntax outSyntax)
                    throws java.io.FileNotFoundException
Convert the input file, interpreted in the inputSyntax to outputFile, in outputSyntax.

Parameters:
in - input File
inSyntax -
out - output File
outSyntax -
Throws:
java.io.FileNotFoundException

loadFromFile

@Deprecated
public static Model loadFromFile(java.io.File in,
                                            Syntax inSyntax)
                          throws ModelRuntimeException,
                                 java.io.IOException
Deprecated. This method creates new models via RDF2Go. If multiple model factories are used, this might be wrong. Use instead public static void loadFromFile(File in, Syntax inSyntax, Model sinkModel)

Parameters:
in -
inSyntax -
Returns:
a model with the content from 'in'. Model is open.
Throws:
ModelRuntimeException
java.io.IOException

loadFromFile

public static void loadFromFile(java.io.File in,
                                Syntax inSyntax,
                                Model sinkModel)
                         throws ModelRuntimeException,
                                java.io.IOException
Convenience method to load data from file in in syntax inSyntax and write loaded triples to sinkModel.

Parameters:
in -
inSyntax -
sinkModel - where to write the loaded content. This model is not cleared. This model should be open.
Throws:
ModelRuntimeException
java.io.IOException

writeToFile

public static void writeToFile(Model model,
                               java.io.File outFile,
                               Syntax outSyntax)
                        throws ModelRuntimeException,
                               java.io.IOException
Throws:
ModelRuntimeException
java.io.IOException

convert

public static void convert(java.io.File[] inFiles,
                           Syntax[] inSyntax,
                           java.io.File out,
                           Syntax outSyntax)
                    throws ModelRuntimeException,
                           java.io.IOException
Merge all input files into one model and export to outfile in output syntax

Throws:
java.io.IOException
ModelRuntimeException


Copyright © 2005-2008 FZI - Forschungszentrum Informatik | Karlsruhe | Germany. All Rights Reserved.