public class OWLJavaFileGenerator extends Object implements OntologyModelBuilder, JavaFileGenerator
addRDF methods.
Afterwards Java files can be generated by a call to generateJavaFiles(OntGenerationConfig, File)
providing an appropriate configuration (see OntGenerationConfig).
All implicit information about the ontology is inferred before the files are generated.
OntGenerationConfig config = new OntGenerationConfig();
// Adopt your config here...
JavaFileGenerator generator = new OWLJavaFileGenerator();
generator.addRDF("http://example.de/my_ontology.rdf.xml");
File outputDir = new File("out");
generator.generateJavaFiles(config, outputDir);
OntologyModelBuilder.RDFSModelBuildingExceptionJavaFileGenerator.InvalidOntologyException, JavaFileGenerator.JavaFileGenerationException| Constructor and Description |
|---|
OWLJavaFileGenerator()
Initializes the generator without a connection to an external repository,
i.e.
|
OWLJavaFileGenerator(Anno4j anno4j)
Initializes the generator with an Anno4j instance which connected repository
will receive the ontology information (including inferred statements) after a call
to
build() or generateJavaFiles(OntGenerationConfig, File). |
| Modifier and Type | Method and Description |
|---|---|
void |
addRDF(InputStream rdfInput,
String format)
Adds RDF statements to the model.
|
void |
addRDF(InputStream rdfInput,
String base,
String format)
Adds RDF statements to the model.
|
void |
addRDF(String url)
Adds RDF statements to the underlying model.
|
void |
addRDF(String url,
String format)
Adds RDF statements to the model.
|
void |
addRDF(String url,
String base,
String format)
Adds RDF statements to the model.
|
void |
build()
Builds an ontology model for the RDF data added before using
addRDF methods. |
void |
generateJavaFiles(OntGenerationConfig config,
File outputDirectory)
Generates
.java files of resource objects (see ResourceObject)
and support classes (see ResourceObjectSupport) for
the classes defined in a ontology. |
Collection<BuildableRDFSClazz> |
getClazzes()
Returns the buildable named resource objects of RDFS classes that were found during
the last call to
build(). |
ObjectConnection |
getConnection()
Returns a connection to the object repository that receives the ontology information during a call
to
OntologyModelBuilder.build(). |
Collection<BuildableRDFSProperty> |
getProperties()
Returns the extended resource objects of RDFS properties that were found during
the last call to
build(). |
com.hp.hpl.jena.reasoner.ValidityReport |
validate()
Returns a validity report for the model build during the last call of
build(). |
public OWLJavaFileGenerator()
throws org.openrdf.repository.config.RepositoryConfigException,
org.openrdf.repository.RepositoryException
org.openrdf.repository.config.RepositoryConfigException - Thrown if the internal repository is not correctly configured.org.openrdf.repository.RepositoryException - Thrown if an error occurs regarding the setup of the internal repository.public OWLJavaFileGenerator(Anno4j anno4j)
build() or generateJavaFiles(OntGenerationConfig, File).anno4j - The Anno4j instance that will receive ontology information.public void addRDF(InputStream rdfInput, String format)
build() is required for committing the data to the model.addRDF in interface OntologyModelBuilderaddRDF in interface JavaFileGeneratorrdfInput - An input stream to RDF/XML data.format - The base uri to be used when converting relative URI's to absolute URI's.public void addRDF(String url, String format)
build() is required for committing the data to the model.addRDF in interface OntologyModelBuilderaddRDF in interface JavaFileGeneratorurl - An URL to RDF data in RDF/XML format.format - The base uri to be used when converting relative URI's to absolute URI's.public void addRDF(InputStream rdfInput, String base, String format)
build() is required for committing the data to the model.addRDF in interface OntologyModelBuilderaddRDF in interface JavaFileGeneratorrdfInput - An input stream to the RDF data. Its format is defined by the format parameter.base - The base uri to be used when converting relative URI's to absolute URI's.format - The format of the RDF data. One of "RDF/XML", "N-TRIPLE", "TURTLE" (or "TTL") and "N3"public void addRDF(String url, String base, String format)
build() is required for committing the data to the model.addRDF in interface OntologyModelBuilderaddRDF in interface JavaFileGeneratorurl - An URL to RDF data in the specified format.base - The base uri to be used when converting relative URI's to absolute URI's.format - The format of the RDF data. One of "RDF/XML", "N-TRIPLE", "TURTLE" (or "TTL") and "N3"public void addRDF(String url)
addRDF in interface OntologyModelBuilderurl - URL to a RDF/XML file containing the RDF data to be added.public Collection<BuildableRDFSClazz> getClazzes() throws org.openrdf.repository.RepositoryException
build().getClazzes in interface OntologyModelBuilderorg.openrdf.repository.RepositoryExceptionpublic Collection<BuildableRDFSProperty> getProperties() throws org.openrdf.repository.RepositoryException
build().getProperties in interface OntologyModelBuilderorg.openrdf.repository.RepositoryExceptionpublic com.hp.hpl.jena.reasoner.ValidityReport validate()
build().validate in interface OntologyModelBuilderValidityReport.isValid() to
check if the model built is valid.IllegalStateException - Thrown if the model was not previously built.public void build()
throws OntologyModelBuilder.RDFSModelBuildingException
addRDF methods.
After a call to this method, the classes and properties in the model can be queried
using getClazzes() and getProperties() respectively.build in interface OntologyModelBuilderRDFSModelBuildingException - Thrown if an error occurs during building the model.OntologyModelBuilder.RDFSModelBuildingExceptionpublic ObjectConnection getConnection() throws org.openrdf.repository.RepositoryException
OntologyModelBuilderOntologyModelBuilder.build().getConnection in interface OntologyModelBuilderorg.openrdf.repository.RepositoryException - Thrown if no connection could be established.public void generateJavaFiles(OntGenerationConfig config, File outputDirectory) throws JavaFileGenerator.JavaFileGenerationException, IOException, org.openrdf.repository.RepositoryException
JavaFileGenerator.java files of resource objects (see ResourceObject)
and support classes (see ResourceObjectSupport) for
the classes defined in a ontology.
Information about this ontology must be previously added with the addRDF methods.generateJavaFiles in interface JavaFileGeneratorconfig - The configuration object defining how java classes are generated from an ontology.
For example a preference for the language of generated JavaDoc can be set.outputDirectory - The directory where the generated .java files
(or their package directories respectively) are stored.
Will be created if it does not exist. If the directory is not empty
then existing files may be overwritten.JavaFileGenerator.JavaFileGenerationException - Thrown if an error occurred during file generation.IOException - Thrown if an error occurs while writing the generated files.org.openrdf.repository.RepositoryException - Thrown if an error occurs while querying the repository.Copyright © 2017 Chair of Distributed Information Systems - University of Passau. All rights reserved.