/** * Gets a suggested default namespace bases on the ID of an ontology. If the ontology has an IRI then * this IRI will be used to suggest a default namespace, otherwise, the OWL namespace will be returned * as the default namespace * @param ontology The ontology * @return A suggested default namespace */ private static String getDefaultNamespace(OWLOntology ontology, OWLOntologyFormat format) { if(format instanceof PrefixOWLOntologyFormat) { PrefixOWLOntologyFormat prefixOWLOntologyFormat = (PrefixOWLOntologyFormat) format; String defaultPrefix = prefixOWLOntologyFormat.getDefaultPrefix(); if(defaultPrefix != null) { return defaultPrefix; } } if(ontology.getOntologyID().isAnonymous()) { // What do we return here? Just return the OWL namespace for now. return Namespaces.OWL.toString(); } else { String base = ontology.getOntologyID().getOntologyIRI().toString(); if (!base.endsWith("#") && !base.endsWith("/")) { base += "#"; } return base; } }
/** * Gets a suggested default namespace bases on the ID of an ontology. If the ontology has an IRI then * this IRI will be used to suggest a default namespace, otherwise, the OWL namespace will be returned * as the default namespace * @param ontology The ontology * @return A suggested default namespace */ private static String getDefaultNamespace(OWLOntology ontology, OWLOntologyFormat format) { if(format instanceof PrefixOWLOntologyFormat) { PrefixOWLOntologyFormat prefixOWLOntologyFormat = (PrefixOWLOntologyFormat) format; String defaultPrefix = prefixOWLOntologyFormat.getDefaultPrefix(); if(defaultPrefix != null) { return defaultPrefix; } } if(ontology.getOntologyID().isAnonymous()) { // What do we return here? Just return the OWL namespace for now. return Namespaces.OWL.toString(); } else { String base = ontology.getOntologyID().getOntologyIRI().toString(); if (!base.endsWith("#") && !base.endsWith("/")) { base += "#"; } return base; } }
/** * Gets a suggested default namespace bases on the ID of an ontology. If the ontology has an IRI then * this IRI will be used to suggest a default namespace, otherwise, the OWL namespace will be returned * as the default namespace * @param ontology The ontology * @return A suggested default namespace */ private static String getDefaultNamespace(OWLOntology ontology, OWLOntologyFormat format) { if(format instanceof PrefixOWLOntologyFormat) { PrefixOWLOntologyFormat prefixOWLOntologyFormat = (PrefixOWLOntologyFormat) format; String defaultPrefix = prefixOWLOntologyFormat.getDefaultPrefix(); if(defaultPrefix != null) { return defaultPrefix; } } if(ontology.getOntologyID().isAnonymous()) { // XXX What do we return here? Just return the OWL namespace for // now. return Namespaces.OWL.toString(); } else { String base = ontology.getOntologyID().getOntologyIRI().toString(); if (!base.endsWith("#") && !base.endsWith("/")) { base += "#"; } return base; } }