Package OWL2generator

Class SharedUtils

java.lang.Object
OWL2generator.SharedUtils

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 boolean GENERATE_HEADER
    Some methods generate OWL-fragments, and for testing purposes it can be useful to display their parameters as XML-comments
    private java.lang.String IRI
    Internationalized Resource Identifiers (IRIs) are a protocol element, a complement to URIs [RFC2396], and is used as prefix to each identifier.
    private static java.lang.String SEPARATOR
    W3C/defined separator between IRI and unique variable name
    private static java.lang.String XMLNS_XSD_IRI  
  • Constructor Summary

    Constructors 
    Constructor Description
    SharedUtils​(java.lang.String baseURI)  
  • Method Summary

    Modifier and Type Method Description
    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
    java.lang.String declareClass​(java.lang.String className)
    Declares an OWL class according to OWL2 XML Syntax
    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
    java.lang.String declareSubClass​(java.lang.String superClass, java.lang.String subClass)
    Declares OWL subclass according to OWL2 XML Syntax
    (package private) java.lang.String formatClassName​(java.lang.String className)
    Adds project-wide IRI to an OWL class name
    java.lang.String genAnnotationAssertion​(java.lang.String propertyName, java.lang.String annotation)
    Declaring property annotation assertion
    (package private) 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
    (package private) java.lang.String genIndividualAnnotationAssertion​(java.lang.String className, java.lang.String individualName, java.lang.String annotation)
    Associate assertion to an OWL class individual
    (package private) java.lang.String genIndividualClassAssertion​(java.lang.String className, java.lang.String individualName)
    Associate an individual to its OWL class
    (package private) java.lang.String genIndividualDeclaration​(java.lang.String individualName)
    Declares an individual
    (package private) java.lang.String genInverseObjProps​(java.lang.String objPropName_1, java.lang.String objPropName_2)
    Declares two object properties as inverses
    (package private) 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
    (package private) 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)
    (package private) java.lang.String genSubObjProp​(java.lang.String subObjPropName, java.lang.String superObjPropName)
    Associating a sub object property to its super object property
    (package private) java.lang.String genTriplet​(java.lang.String namedIndividual_1, java.lang.String objPropName, java.lang.String namedIndividual_2)
    Defining semantical triplet.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • GENERATE_HEADER

      private static final boolean GENERATE_HEADER
      Some 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 IRI
      Internationalized 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 SEPARATOR
      W3C/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 superclass
      suvClass - 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 property
      annotation - 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 class
      individualName - name of the individual as instance of the OWL class
      annotation - 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 class
      individualName - name of the individual as instance of the OWL class
      annotation - 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 class
      individualName - 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 name
      objPropName_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 property
      superObjPropName - name of the super object property
      annotation - 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 property
      domainClassName - name of the domain OWL class class
      rangeClassName - 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 property
      superObjPropName - 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 individual
      objPropName - the predicate as OWL object property
      namedIndividual_2 - the object as OWL class individual
      Returns:
      XML code snippet