Class IDRangeHelper

java.lang.Object
org.incenp.obofoundry.kgcl.robot.IDRangeHelper

public class IDRangeHelper extends Object
  • Constructor Details

    • IDRangeHelper

      public IDRangeHelper()
  • Method Details

    • findIDRangeFile

      public static String findIDRangeFile()
      Finds an ID range policy file in the current directory. This methods looks for a single file whose name ends with -idranges.owl in the current directory.
      Returns:
      The name of the ID range policy file, if such a file exists; otherwise null.
    • getIDGenerator

      public static IAutoIDGenerator getIDGenerator(org.semanticweb.owlapi.model.OWLOntology ontology, String rangeFile, String rangeName, String[] altNames, boolean random) throws IDRangePolicyException
      Gets an ID generator initialised with data from the specified range file.
      Parameters:
      ontology - The ontology to generate IDs for.
      rangeFile - The range file to initialise the generator with.
      rangeName - The name of the range to use. This should match the allocatedto annotation of one of the ranges in the file. May be null, in which case the method will look for a range that matches one of the alternative names instead. If not null and a corresponding range cannot be found, an exception will be thrown.
      altNames - A list of default range names to use if rangeName is null.
      random - If true, the generator will produce IDs picked at random within the target range; otherwise, IDs will be picked sequentially.
      Returns:
      A newly initialised ID generator.
      Throws:
      IDRangePolicyException - If the range file cannot be read for any reason, if the requested rangeName cannot be found, or if none of the default ranges can be found.
    • maybeGetIDGenerator

      public static IAutoIDGenerator maybeGetIDGenerator(org.semanticweb.owlapi.model.OWLOntology ontology, String rangeFile, String rangeName, String[] altNames, boolean random) throws IDRangePolicyException
      Gets an ID generator initialised with data from the specified range file, or a default file. This method is similar to getIDGenerator(OWLOntology, String, String, String[], boolean), except that if the rangeFile parameter is null, it tries to find a default range file (using the findIDRangeFile() method); in that case, no exception will be thrown.
      Parameters:
      ontology - The ontology to generate IDs for.
      rangeFile - The range file to initialise the generator with. If null, the method will try to find a default file.
      rangeName - The name of the range to use. This should match the allocatedto annotation of one of the ranges in the file. May be null, in which case the method will look for a range that matches one of the alternative names instead.
      altNames - A list of default range names to use if rangeName is null.
      random - If true, the generator will produce IDs picked at random within the target range; otherwise, IDs will be picked sequentially.
      Returns:
      A newly initialised ID generator or null if no range file has been specified and no suitable default file was found.
      Throws:
      IDRangePolicyException - Only if rangeFile is not null: iIf the range file cannot be read for any reason, if the requested rangeName cannot be found, or if none of the default ranges can be found.