Package org.semanticweb.owlapi.util

Examples of org.semanticweb.owlapi.util.DefaultPrefixManager


        IRI ontologyIRI = IRI.create("http://example.com/owl/families/");
        OWLOntology ontology = manager.createOntology(ontologyIRI);
        // Get hold of a data factory from the manager and set up a prefix
        // manager to make things easier
        OWLDataFactory factory = manager.getOWLDataFactory();
        PrefixManager pm = new DefaultPrefixManager(null, null,
                ontologyIRI.toString());
        // Let's specify the :John has a wife :Mary Get hold of the necessary
        // individuals and object property
        OWLNamedIndividual john = factory.getOWLNamedIndividual(":John", pm);
        OWLNamedIndividual mary = factory.getOWLNamedIndividual(":Mary", pm);
View Full Code Here


        // :Person Create an ontology manager to work with
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        OWLDataFactory dataFactory = manager.getOWLDataFactory();
        // The IRIs used here are taken from the OWL 2 Primer
        String base = "http://example.com/owl/families/";
        PrefixManager pm = new DefaultPrefixManager(null, null, base);
        // Get the reference to the :Person class (the full IRI will be
        // <http://example.com/owl/families/Person>)
        OWLClass person = dataFactory.getOWLClass(":Person", pm);
        // Get the reference to the :Mary class (the full IRI will be
        // <http://example.com/owl/families/Mary>)
View Full Code Here

            // System.out.print("    ");
        }
    }

    private static void printNode(@Nonnull Node<OWLClass> node) {
        DefaultPrefixManager pm = new DefaultPrefixManager(null, null,
                "http://owl.man.ac.uk/2005/07/sssw/people#");
        // Print out a node as a list of class names in curly brackets
        for (Iterator<OWLClass> it = node.getEntities().iterator(); it
                .hasNext();) {
            OWLClass cls = it.next();
            // User a prefix manager to provide a slightly nicer shorter name
            String shortForm = pm.getShortForm(cls);
            assertNotNull(shortForm);
        }
    }
View Full Code Here

            InstantiationException {
        OWLOntology o = makeOwlOntologyWithDeclarationsAndAnnotationAssertions(
                annotationProperty, entities);
        for (int i = 0; i < 10; i++) {
            PrefixDocumentFormat format = formatClass.newInstance();
            format.setPrefixManager(new DefaultPrefixManager(null, null,
                    "http://localhost#"));
            o = roundTrip(o);
        }
        assertEquals("annotationCount", entities.length,
                o.getAxioms(AxiomType.ANNOTATION_ASSERTION).size());
View Full Code Here

            OWLDocumentFormat format) {
        super(ontology, format);
        this.format = checkNotNull(format, "format cannot be null");
        this.writer = new PrintWriter(writer);
        pending = new HashSet<>();
        pm = new DefaultPrefixManager();
        if (!ontology.isAnonymous()) {
            String ontologyIRIString = ontology.getOntologyID()
                    .getOntologyIRI().get().toString();
            String defaultPrefix = ontologyIRIString;
            if (!ontologyIRIString.endsWith("/")) {
View Full Code Here

@SuppressWarnings("javadoc")
public class DefaultPrefixManagerTestCase {

    @Test
    public void getPrefixIRIEmpty() {
        DefaultPrefixManager pm = new DefaultPrefixManager();
        pm.setPrefix("foaf:", "http://xmlns.com/foaf/0.1/");
        assertEquals("foaf:",
                pm.getPrefixIRI(IRI("http://xmlns.com/foaf/0.1/")));
    }
View Full Code Here

                pm.getPrefixIRI(IRI("http://xmlns.com/foaf/0.1/")));
    }

    @Test
    public void testContainsDefaultPrefixNames() {
        PrefixManager pm = new DefaultPrefixManager();
        assertTrue(pm.containsPrefixMapping("owl:"));
        assertTrue(pm.containsPrefixMapping("rdf:"));
        assertTrue(pm.containsPrefixMapping("rdfs:"));
        assertTrue(pm.containsPrefixMapping("xml:"));
        assertTrue(pm.containsPrefixMapping("xsd:"));
        assertFalse(pm.containsPrefixMapping(":"));
        assertNull(pm.getDefaultPrefix());
    }
View Full Code Here

        assertNull(pm.getDefaultPrefix());
    }

    @Test
    public void testPrefixIRIExpansion() {
        PrefixManager pm = new DefaultPrefixManager();
        IRI iri = pm.getIRI("rdfs:comment");
        assertEquals(iri, OWLRDFVocabulary.RDFS_COMMENT.getIRI());
    }
View Full Code Here

    }

    @Test
    public void testDefaultPrefixExpansion() {
        String defaultPrefix = "http://www.semanticweb.org/test/ont";
        PrefixManager pm = new DefaultPrefixManager();
        pm.setDefaultPrefix(defaultPrefix);
        assertTrue(pm.containsPrefixMapping(":"));
        assertNotNull(pm.getDefaultPrefix());
        assertEquals(pm.getDefaultPrefix(), pm.getPrefix(":"));
        String expansion = defaultPrefix + 'A';
        IRI iri = pm.getIRI(":A");
        assertEquals(iri.toString(), expansion);
    }
View Full Code Here

    /**
     * Constructs a short form provider that reuses any prefix name mappings from the specified ontology format
     * @param format The format from which prefix name mappings will be reused
     */
    public ManchesterOWLSyntaxPrefixNameShortFormProvider(OWLOntologyFormat format) {
        prefixManager = new DefaultPrefixManager();
        if(format instanceof PrefixOWLOntologyFormat) {
            PrefixOWLOntologyFormat prefixFormat = (PrefixOWLOntologyFormat) format;
            for(String prefixName : prefixFormat.getPrefixName2PrefixMap().keySet()) {
                prefixManager.setPrefix(prefixName, prefixFormat.getPrefix(prefixName));
            }
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.util.DefaultPrefixManager

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.