Package OWL2generator

Class GetSectionsFromConfigFile

java.lang.Object
OWL2generator.GetSectionsFromConfigFile

public class GetSectionsFromConfigFile
extends java.lang.Object
GetSectionsFromConfigFile class parses a configuration file to extract sections delineated by specific start and end tokens, returning a data structure containing these sections. It serves as a foundational component within the simplified Java framework. By parsing configuration files, it provides structured data for subsequent OWL/XML ontology generation, likely independent of the specific ontology details.

Functionality:

Constructor: Takes the configuration file path, section start/end tokens, and comment character as input.

getSectionContent (private method): Reads the file line by line, accumulating lines within a section until the end token is encountered.

getSections (public method): Returns the extracted sections as a List of Lists (each inner list represents a section).

Key Points:

Leverages BufferedReader for efficient line-by-line file reading. Handles empty lines and comments within the configuration file. Employs ArrayList for dynamic storage of sections and their content (lines).

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/06/19
Version:
1-001
Author:
Edit Hlaszny (https://www.hlaszny.eu/ edithlaszny@gmail.com)
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private java.lang.String comment
    Any text following the comment string on the first position is ignored by this simple parser in the class
    private java.io.BufferedReader reader
    The text-file (the app uses several parameters files: each of them is ASCII flat text files) is read with BufferedReader method
    private java.util.List<java.util.List<java.lang.String>> sections
    The result of the parsing is a List<List<String>> class member, which can be accessed with the getSection() method
  • Constructor Summary

    Constructors 
    Constructor Description
    GetSectionsFromConfigFile​(java.lang.String configFilePath, java.lang.String sectionStartToken, java.lang.String sectionEndToken, java.lang.String comment)
    It sets the class members and reads the parameter file up to the beginning of the section and then calls the method processing the section.
  • Method Summary

    Modifier and Type Method Description
    private java.util.List<java.lang.String> getSectionContent​(java.lang.String sectionEndToken)
    It returns with an excerpt from a text file (limited by the constructor's start, and end token), which the calling method then appends to the result list.
    java.util.List<java.util.List<java.lang.String>> getSections()
    Returns an excerpt from a text file (limited by the constructor's start, and end token).

    Methods inherited from class java.lang.Object

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

    • comment

      private java.lang.String comment
      Any text following the comment string on the first position is ignored by this simple parser in the class
    • reader

      private java.io.BufferedReader reader
      The text-file (the app uses several parameters files: each of them is ASCII flat text files) is read with BufferedReader method
    • sections

      private java.util.List<java.util.List<java.lang.String>> sections
      The result of the parsing is a List<List<String>> class member, which can be accessed with the getSection() method
  • Constructor Details

    • GetSectionsFromConfigFile

      GetSectionsFromConfigFile​(java.lang.String configFilePath, java.lang.String sectionStartToken, java.lang.String sectionEndToken, java.lang.String comment)
      It sets the class members and reads the parameter file up to the beginning of the section and then calls the method processing the section. The sections will be added to the List<List<String>> sections one after the other.
      Parameters:
      configFilePath - Pathname of the configuration file.
      sectionStartToken - Denotes the start of a section.
      sectionEndToken - Denotes the end of a section.
      comment - Marks the line (until CR/LF) as comment.
      sections - The class member List<List<String>> sections contains all scanned sections as produced result of the class.
  • Method Details

    • getSectionContent

      private java.util.List<java.lang.String> getSectionContent​(java.lang.String sectionEndToken)
      It returns with an excerpt from a text file (limited by the constructor's start, and end token), which the calling method then appends to the result list.
      Parameters:
      sectionEndToken - (the end-of-cut token)
      Returns:
      one section (=list of one lines, extracted from a parameter/text file
      Throws:
      IOexception - (can be caused by a BufferedReader)
    • getSections

      public java.util.List<java.util.List<java.lang.String>> getSections()
      Returns an excerpt from a text file (limited by the constructor's start, and end token). Used by the classes: WriteDisjointClassDefs, WriteTriplets
      Parameters:
      none -
      Returns:
      list of sections, extracted from a parameter/text file