Search in sources :

Example 1 with PrefixDocumentFormat

use of org.semanticweb.owlapi.formats.PrefixDocumentFormat in project graal by graphik-team.

the class OWL2Parser method getShortFormProvider.

// /////////////////////////////////////////////////////////////////////////
// PRIVATE METHODS
// /////////////////////////////////////////////////////////////////////////
private ShortFormProvider getShortFormProvider(OWLOntology ontology) {
    OWLDocumentFormat format = this.manager.getOntologyFormat(this.ontology);
    DefaultPrefixManager pm = new DefaultPrefixManager();
    if (prefixEnable && format.isPrefixOWLOntologyFormat()) {
        PrefixDocumentFormat prefixFormat = format.asPrefixOWLOntologyFormat();
        Map<String, String> prefixMap = prefixFormat.getPrefixName2PrefixMap();
        Set<String> forbiddenPrefix = new TreeSet<>();
        forbiddenPrefix.add("xml:");
        forbiddenPrefix.add("rdf:");
        forbiddenPrefix.add("rdfs:");
        forbiddenPrefix.add("owl:");
        for (Map.Entry<String, String> entry : prefixMap.entrySet()) {
            String prefix = entry.getKey();
            if (!forbiddenPrefix.contains(prefix)) {
                pm.setPrefix(prefix, entry.getValue());
                prefix = prefix.substring(0, prefix.length() - 1);
                buffer.write(new Prefix(prefix, entry.getValue()));
            }
        }
    }
    return pm;
}
Also used : DefaultPrefixManager(org.semanticweb.owlapi.util.DefaultPrefixManager) TreeSet(java.util.TreeSet) OWLDocumentFormat(org.semanticweb.owlapi.model.OWLDocumentFormat) PrefixDocumentFormat(org.semanticweb.owlapi.formats.PrefixDocumentFormat) Prefix(fr.lirmm.graphik.util.Prefix) Map(java.util.Map)

Aggregations

Prefix (fr.lirmm.graphik.util.Prefix)1 Map (java.util.Map)1 TreeSet (java.util.TreeSet)1 PrefixDocumentFormat (org.semanticweb.owlapi.formats.PrefixDocumentFormat)1 OWLDocumentFormat (org.semanticweb.owlapi.model.OWLDocumentFormat)1 DefaultPrefixManager (org.semanticweb.owlapi.util.DefaultPrefixManager)1