public class SharedUtils
extends java.lang.Object
SharedUtils class offers a collection of utility methods
for OWL/XML ontology generation within the framework. It doesn't directly
belong to any specific class but functions as a helper.
SharedUtils acts as a utility class, providing reusable
functionalities for building the OWL ontology structure. It
helps in creating declarations for classes, individuals, properties,
and their relationships within the ontology based on text file
configurations.
Key Functionalities:
Generates OWL code snippets for various ontology elements:
- Classes (
declareClass,declareSubClass) - Individuals (
genIndividual) with their declarations, class assertions, and annotations - Object properties (
genObjPropDecl) with potential super-properties and annotations - Sub-object property relationships (
genSubObjProp) - Inverse object properties (
genInverseObjProps) - OWL class individual triplets (
genTriplet)
Formats class names with a project-wide IRI prefix (formatClassName)
Generates annotation assertions (genAnnotationAssertion)
Defines constants like IRI (Internationalized Resource Identifier)
Additional Notes:
The class utilizes a constant IRI (Internationalized Resource Identifier) to serve as a prefix for all identifiers within the generated ontology.
A boolean flag GENERATE_HEADER controls whether comments are included in
the generated XML for better human readability during development
(currently disabled).
Some methods (like genObjPropDomainAndRange) are currently not used,
suggesting potential future extensibility for associating domain and
range OWL classes with object properties.
Environment:
- IDE: Eclipse IDE for Java Developers
- Version: 2021-12 (4.22.0)
- Build id: 20211202-1639
- HW Model Name: iMac, MacOS Monterey, 12.5.1
- Processor Name: Quad-Core Intel Core i5
- Processor Speed: 3.2 GHz
- Memory: 32 GB 1867 MHz DDR3
- Disk: APPLE SSD SM0256G
- Serial: DGKRC080GG7V
- Since:
- 2024/05/24
- Version:
- 1-001
- Author:
- Edit Hlaszny (https://www.hlaszny.eu/ edithlaszny@gmail.com)
-
Field Summary
Fields Modifier and Type Field Description private static booleanGENERATE_HEADERSome methods generate OWL-fragments, and for testing purposes it can be useful to display their parameters as XML-commentsprivate java.lang.StringIRIInternationalized Resource Identifiers (IRIs) are a protocol element, a complement to URIs [RFC2396], and is used as prefix to each identifier.private static java.lang.StringSEPARATORW3C/defined separator between IRI and unique variable nameprivate static java.lang.StringXMLNS_XSD_IRI -
Constructor Summary
Constructors Constructor Description SharedUtils(java.lang.String baseURI) -
Method Summary
Modifier and Type Method Description java.lang.StringassertDataProperty(java.lang.String dataPropertyName, java.lang.String individualName, java.lang.String dataPropertyType, java.lang.String dataPropertyValue)Assert a data property: it's a threefold task: 1) assigns it to a named individual 2) define its type 3) also assigns a valuejava.lang.StringdeclareClass(java.lang.String className)Declares an OWL class according to OWL2 XML Syntaxjava.lang.StringdeclareDataProperty(java.lang.String dataPropertyName, java.lang.String superDataPropertyName, java.lang.String annotation)Declare a data property (1) per name (2) as a sub data property (3) associate an annotationjava.lang.StringdeclareSubClass(java.lang.String superClass, java.lang.String subClass)Declares OWL subclass according to OWL2 XML Syntax(package private) java.lang.StringformatClassName(java.lang.String className)Adds project-wide IRI to an OWL class namejava.lang.StringgenAnnotationAssertion(java.lang.String propertyName, java.lang.String annotation)Declaring property annotation assertion(package private) java.lang.StringgenIndividual(java.lang.String className, java.lang.String individualName, java.lang.String annotation)Generate OWL class individual: consists of three steps:
1) declaring the individual
2) associating it to its OWL class
3) adding annotation to the individual(package private) java.lang.StringgenIndividualAnnotationAssertion(java.lang.String className, java.lang.String individualName, java.lang.String annotation)Associate assertion to an OWL class individual(package private) java.lang.StringgenIndividualClassAssertion(java.lang.String className, java.lang.String individualName)Associate an individual to its OWL class(package private) java.lang.StringgenIndividualDeclaration(java.lang.String individualName)Declares an individual(package private) java.lang.StringgenInverseObjProps(java.lang.String objPropName_1, java.lang.String objPropName_2)Declares two object properties as inverses(package private) java.lang.StringgenObjPropDecl(java.lang.String objPropName, java.lang.String superObjPropName, java.lang.String annotation)Declares object property, consists of three steps:
1) declaring the object property
2) associating it to its super object property
3) adding annotation to the object property(package private) java.lang.StringgenObjPropDomainAndRange(java.lang.String objPropName, java.lang.String domainClassName, java.lang.String rangeClassName)Associating domain- and range classes to an object property (used only if OWL classes are the domains and ranges,- currently not used)(package private) java.lang.StringgenSubObjProp(java.lang.String subObjPropName, java.lang.String superObjPropName)Associating a sub object property to its super object property(package private) java.lang.StringgenTriplet(java.lang.String namedIndividual_1, java.lang.String objPropName, java.lang.String namedIndividual_2)Defining semantical triplet.
-
Field Details
-
GENERATE_HEADER
private static final boolean GENERATE_HEADERSome methods generate OWL-fragments, and for testing purposes it can be useful to display their parameters as XML-comments- See Also:
- Constant Field Values
-
IRI
private java.lang.String IRIInternationalized Resource Identifiers (IRIs) are a protocol element, a complement to URIs [RFC2396], and is used as prefix to each identifier. The class members are project-wide constant. -
XMLNS_XSD_IRI
private static final java.lang.String XMLNS_XSD_IRI- See Also:
- Constant Field Values
-
SEPARATOR
private static final java.lang.String SEPARATORW3C/defined separator between IRI and unique variable name- See Also:
- Constant Field Values
-
-
Constructor Details
-
SharedUtils
SharedUtils(java.lang.String baseURI)
-
-
Method Details
-
assertDataProperty
public java.lang.String assertDataProperty(java.lang.String dataPropertyName, java.lang.String individualName, java.lang.String dataPropertyType, java.lang.String dataPropertyValue)Assert a data property: it's a threefold task: 1) assigns it to a named individual 2) define its type 3) also assigns a value- Parameters:
dataPropertyName-individualName-dataPropertyType- (each element of the xlmns:xsd schema can be used)dataPropertyValue-- Returns:
- XML code snippet
-
declareClass
public java.lang.String declareClass(java.lang.String className)Declares an OWL class according to OWL2 XML Syntax- Parameters:
className- Name of the OWL class- Returns:
- XML code snippet
-
declareSubClass
public java.lang.String declareSubClass(java.lang.String superClass, java.lang.String subClass)Declares OWL subclass according to OWL2 XML Syntax- Parameters:
superClass- Name of the OWL superclasssuvClass- Name of the OWL subclass- Returns:
- XML code snippet
-
declareDataProperty
public java.lang.String declareDataProperty(java.lang.String dataPropertyName, java.lang.String superDataPropertyName, java.lang.String annotation)Declare a data property (1) per name (2) as a sub data property (3) associate an annotation- Parameters:
dataPropertyName-superDataPropertyName-annotation-- Returns:
- XML code snippet
-
formatClassName
java.lang.String formatClassName(java.lang.String className)Adds project-wide IRI to an OWL class name- Parameters:
className- OWL class name to be formatted- Returns:
- XML code snippet
-
genAnnotationAssertion
public java.lang.String genAnnotationAssertion(java.lang.String propertyName, java.lang.String annotation)Declaring property annotation assertion- Parameters:
propertyName- name of an OWL propertyannotation- annotation as literal text- Returns:
- XML code snippet
-
genIndividual
java.lang.String genIndividual(java.lang.String className, java.lang.String individualName, java.lang.String annotation)Generate OWL class individual: consists of three steps:
1) declaring the individual
2) associating it to its OWL class
3) adding annotation to the individual- Parameters:
className- name of the OWL classindividualName- name of the individual as instance of the OWL classannotation- annotation as literal text associated to the individual- Returns:
- XML code snippet
-
genIndividualAnnotationAssertion
java.lang.String genIndividualAnnotationAssertion(java.lang.String className, java.lang.String individualName, java.lang.String annotation)Associate assertion to an OWL class individual- Parameters:
className- name of the OWL classindividualName- name of the individual as instance of the OWL classannotation- annotation as literal text associated to the individual- Returns:
- XML code snippet
-
genIndividualClassAssertion
java.lang.String genIndividualClassAssertion(java.lang.String className, java.lang.String individualName)Associate an individual to its OWL class- Parameters:
className- name of the OWL classindividualName- name of the individual as instance of the OWL class- Returns:
- XML code snippet
-
genIndividualDeclaration
java.lang.String genIndividualDeclaration(java.lang.String individualName)Declares an individual- Parameters:
individualName- name of the individual- Returns:
- XML code snippet
-
genInverseObjProps
java.lang.String genInverseObjProps(java.lang.String objPropName_1, java.lang.String objPropName_2)Declares two object properties as inverses- Parameters:
objPropName_1- the first object property nameobjPropName_2- the second one- Returns:
- XML code snippet
-
genObjPropDecl
java.lang.String genObjPropDecl(java.lang.String objPropName, java.lang.String superObjPropName, java.lang.String annotation)Declares object property, consists of three steps:
1) declaring the object property
2) associating it to its super object property
3) adding annotation to the object property- Parameters:
objPropName- name of the object propertysuperObjPropName- name of the super object propertyannotation- annotation as literal text associated to the object property- Returns:
- XML code snippet
-
genObjPropDomainAndRange
java.lang.String genObjPropDomainAndRange(java.lang.String objPropName, java.lang.String domainClassName, java.lang.String rangeClassName)Associating domain- and range classes to an object property (used only if OWL classes are the domains and ranges,- currently not used)- Parameters:
objPropName- name of the object propertydomainClassName- name of the domain OWL class classrangeClassName- name of the range OWL class class- Returns:
- XML code snippet
-
genSubObjProp
java.lang.String genSubObjProp(java.lang.String subObjPropName, java.lang.String superObjPropName)Associating a sub object property to its super object property- Parameters:
subObjPropName- name of the sub object propertysuperObjPropName- name of the super object property- Returns:
- XML code snippet
-
genTriplet
java.lang.String genTriplet(java.lang.String namedIndividual_1, java.lang.String objPropName, java.lang.String namedIndividual_2)Defining semantical triplet. A triple consists of three components: a subject, a predicate, and an object. The predicate describes the relationship between two nodes, one the subject and the other the object. Each node can be both a subject and object simultaneously if it’s used in more than one triple.- Parameters:
namedIndividual_1- the subject as OWL class individualobjPropName- the predicate as OWL object propertynamedIndividual_2- the object as OWL class individual- Returns:
- XML code snippet
-