Package org.semanticweb.owlapi.formats

Examples of org.semanticweb.owlapi.formats.PrefixDocumentFormat


     */
    public ManchesterOWLSyntaxPrefixNameShortFormProvider(
            OWLDocumentFormat format) {
        prefixManager = new DefaultPrefixManager();
        if (format instanceof PrefixDocumentFormat) {
            PrefixDocumentFormat ontFormat = (PrefixDocumentFormat) format;
            prefixManager.copyPrefixesFrom(ontFormat);
            prefixManager.setPrefixComparator(ontFormat.getPrefixComparator());
        }
    }
View Full Code Here


        checkNotNull(format, "format cannot be null");
        try {
            OWLXMLWriter w = new OWLXMLWriter(writer, ontology);
            w.startDocument(ontology);
            if (format instanceof PrefixDocumentFormat) {
                PrefixDocumentFormat fromPrefixFormat = (PrefixDocumentFormat) format;
                Map<String, String> map = fromPrefixFormat
                        .getPrefixName2PrefixMap();
                for (String prefixName : map.keySet()) {
                    String prefix = map.get(prefixName);
                    if (prefix != null && !prefix.isEmpty()) {
                        w.writePrefix(prefixName, prefix);
View Full Code Here

        return ontology;
    }

    private final void processOntology() {
        if (ontologyFormat instanceof PrefixDocumentFormat) {
            PrefixDocumentFormat namespaceFormat = (PrefixDocumentFormat) ontologyFormat;
            Map<String, String> namespacesByPrefix = namespaceFormat
                    .getPrefixName2PrefixMap();
            for (String prefixName : namespacesByPrefix.keySet()) {
                String xmlnsPrefixName = prefixName.substring(0,
                        prefixName.length() - 1);
                String xmlnsPrefix = namespacesByPrefix.get(prefixName);
View Full Code Here

    private static String getDefaultNamespace(@Nonnull OWLOntology ontology,
            @Nonnull OWLDocumentFormat format) {
        checkNotNull(ontology, "ontology cannot be null");
        checkNotNull(format, "format cannot be null");
        if (format instanceof PrefixDocumentFormat) {
            PrefixDocumentFormat prefixOWLOntologyFormat = (PrefixDocumentFormat) format;
            String defaultPrefix = prefixOWLOntologyFormat.getDefaultPrefix();
            if (defaultPrefix != null) {
                return defaultPrefix;
            }
        }
        if (ontology.getOntologyID().isAnonymous()) {
View Full Code Here

    @SuppressWarnings("null")
    private void copyPrefixes(OWLDocumentFormat ontologyFormat) {
        if (!(ontologyFormat instanceof PrefixDocumentFormat)) {
            return;
        }
        PrefixDocumentFormat prefixFormat = (PrefixDocumentFormat) ontologyFormat;
        for (Map.Entry<String, String> e : prefixFormat
                .getPrefixName2PrefixMap().entrySet()) {
            setPrefix(e.getKey(), e.getValue());
        }
    }
View Full Code Here

            pm.setDefaultPrefix(defaultPrefix);
        }
        // copy prefixes out of the given format if it is a
        // PrefixOWLOntologyFormat
        if (format instanceof PrefixDocumentFormat) {
            PrefixDocumentFormat prefixFormat = (PrefixDocumentFormat) format;
            pm.copyPrefixesFrom(prefixFormat);
            pm.setPrefixComparator(prefixFormat.getPrefixComparator());
        }
        // base = "";
    }
View Full Code Here

    @SuppressWarnings("null")
    @Override
    public void handleNamespace(String prefix, String uri) {
        RDFDocumentFormat format = getOntologyFormat();
        if (format instanceof PrefixDocumentFormat) {
            PrefixDocumentFormat prefixDocumentFormat = (PrefixDocumentFormat) format;
            prefixDocumentFormat.setPrefix(prefix + ':', uri);
        }
    }
View Full Code Here

    }

    @Test
    public void shouldRoundTrip() throws Exception {
        OWLOntology ontology = buildOntology();
        PrefixDocumentFormat format = new ManchesterSyntaxDocumentFormat();
        format.setPrefix("piz", NS + '#');
        OWLOntology roundtripped = roundTrip(ontology, format);
        assertEquals(ontology.getLogicalAxioms(),
                roundtripped.getLogicalAxioms());
    }
View Full Code Here

    @Override
    protected OWLOntology createOntology() {
        OWLOntology ont;
        try {
            ont = m.createOntology();
            PrefixDocumentFormat format = (PrefixDocumentFormat) ont
                    .getOWLOntologyManager().getOntologyFormat(ont);
            assert format != null;
            format.setDefaultPrefix("http://default.com");
            format.setPrefix("a", "http://ontology.com/a#");
            format.setPrefix("b", "http://ontology.com/b#");
            return ont;
        } catch (OWLOntologyCreationException e) {
            throw new OWLRuntimeException(e);
        }
    }
View Full Code Here

            throws OWLOntologyStorageException, OWLOntologyCreationException {
        StringDocumentTarget target = new StringDocumentTarget();
        OWLDocumentFormat fromFormat = m.getOntologyFormat(ont);
        if (fromFormat.isPrefixOWLOntologyFormat()
                && format.isPrefixOWLOntologyFormat()) {
            PrefixDocumentFormat fromPrefixFormat = fromFormat
                    .asPrefixOWLOntologyFormat();
            PrefixDocumentFormat toPrefixFormat = format
                    .asPrefixOWLOntologyFormat();
            toPrefixFormat.copyPrefixesFrom(fromPrefixFormat);
        }
        boolean addMissingTypes = true;
        if (format instanceof RDFDocumentFormat) {
            format.setAddMissingTypes(addMissingTypes);
        }
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.formats.PrefixDocumentFormat

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.