Package cz.cvut.kbss.jopa.owl2java
Class JavaNameGenerator
java.lang.Object
cz.cvut.kbss.jopa.owl2java.JavaNameGenerator
Generates Java names based on IRI identifiers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateJavaNameForIri
(org.semanticweb.owlapi.model.IRI iri) Returns a valid Java identifier extracted from the specified IRI.generatePrefixedJavaNameForIri
(org.semanticweb.owlapi.model.IRI iri, org.semanticweb.owlapi.model.OWLOntologyID ontologyId) Returns a valid Java identifier extracted from the specified IRI, prefixed with prefix registered for the specified ontology IRI (if available).getOntologyPrefix
(org.semanticweb.owlapi.model.IRI ontologyIri) Gets the prefix registered for an ontology with the specified identifier.boolean
hasPrefix
(org.semanticweb.owlapi.model.IRI ontologyIri) Checks whether a prefix exists for the specified ontology identifier.static String
makeNameValidJava
(String name) Returns the specified name sanitized for Java.static String
toCamelCaseNotation
(String name) Converts the specified name to the Java camel case notation.
-
Constructor Details
-
JavaNameGenerator
-
-
Method Details
-
generateJavaNameForIri
Returns a valid Java identifier extracted from the specified IRI.If the IRI contains a non-empty fragment, it is used. Otherwise, the part after the last slash is used as the name.
- Parameters:
iri
- IRI to extract name from- Returns:
- Java name based on the specified IRI
-
generatePrefixedJavaNameForIri
public String generatePrefixedJavaNameForIri(org.semanticweb.owlapi.model.IRI iri, org.semanticweb.owlapi.model.OWLOntologyID ontologyId) Returns a valid Java identifier extracted from the specified IRI, prefixed with prefix registered for the specified ontology IRI (if available).If the IRI contains a non-empty fragment, it is used. Otherwise, the part after the last slash is used as the name.
If the ontology is anonymous, no prefix is added to the extracted name. If no prefix is registered for the ontology, a prefix represented by extracting a java name from the ontology IRI is used.
- Parameters:
iri
- IRI to extract name fromontologyId
- Ontology identifier- Returns:
- Java name based on the specified IRI
-
getOntologyPrefix
Gets the prefix registered for an ontology with the specified identifier.- Parameters:
ontologyIri
- Ontology IRI- Returns:
- Optional ontology prefix
-
hasPrefix
public boolean hasPrefix(org.semanticweb.owlapi.model.IRI ontologyIri) Checks whether a prefix exists for the specified ontology identifier.- Parameters:
ontologyIri
- Ontology IRI- Returns:
true
if a prefix has been resolved for ontology IRI,false
otherwise
-
makeNameValidJava
Returns the specified name sanitized for Java.This means the result of this function can be used as/in a Java variable/field/class name.
- Parameters:
name
- The name to sanitize- Returns:
- Valid Java identifier
-
toCamelCaseNotation
Converts the specified name to the Java camel case notation.This process removes underscores used to generate the name.
- Parameters:
name
- Generated name- Returns:
- Converted camel case name
-